BCK to temp hoster

· EOG, like EOF


Shell scripting and systemd configurations can be tricky, especially when dealing with quoting and escaping characters. Your attention to detail and willingness to learn are commendable.

tgpt --provider sky

.

² Backup normally to FTP server (here: dFiles.com) #

Option #0 : ftp #

Pros: Already installed Cons: Works only w/ physical files from disk

cd ~

# mkfifo del.zip
zip -r   del.zip *                  &&
ftp -n   ftpupload1.dfiles.eu <<EOG
user     annakarenina 1234567890
binary
# lcd    ~/prf/ais.cmc..ads/
put      del.zip
bye
EOG

# rm     del.zip

.

Option #1 : Install lftp ==TODO== #

sudo pacman -Syu lftp

.

² Backup on-the-fly to Catbox / Litterbox.Catbox #

Use a) catbox.moe & delete after uploading
or
b) litterbox.catbox.moe with autodlete

a) Catbox.moe #

https://catbox.moe/tools.php

Does catbox.moe give a delete code? reqtype="deletefiles" userhash="####" files="eh871k.png d9pove.gif"

Upload functions

catbox (){ 
    curl https://catbox.moe/user/api.php \
        -F "reqtype=fileupload" \
        -F "fileToUpload=@$1"
}

# catbox wateram.jpg 
#=> https://files.catbox.moe/vmigtc.jpg

catbox_url (){
   echo curl https://catbox.moe/user/api.php \
        -F "reqtype=urlupload" \
        -F "url=$1"
}
catbox_url https://files.catbox.moe/vmigtc.jpg

b) Litterbox.catbox.moe w/ autodlete after 1h, 12h, 24h or 72h #

FINAl FUNCTION:

Pipe the compressed dir into cURL to upload to catbox.moe AND ... ... cURL the resulting URL to ntfy.sh

f_send_to_litterbox_then_ntfy (){

    for i in ~/.mozilla/firefox/*/sessionstore-backups; do
      curl -d "$(
       tar -C "$i" -cJvf- ../sessionstore-backups |
        curl https://litterbox.catbox.moe/resources/internals/api.php \
            -F 'time=72h' \
            -F 'reqtype=fileupload' \
            -F "fileToUpload=@-"
                )" ntfy.sh/diviennes-bck-ffx; done
}

Usage of litterbox.catbox.moe

https://litterbox.catbox.moe/tools.php

curl https://litterbox.catbox.moe/resources/internals/api.php \
    -F "time=72h" \
    -F "reqtype=fileupload" \
    -F "fileToUpload=@${fileToUpload}" 

.

3. Send resulting URL to https://ntfy.sh #

Usage of ntfy.sh

curl -d "${result_url}" ntfy.sh/diviennes-bck

Test: Send pic

f_send_to_litterbox_then_ntfy (){
    curl -d "$(
     curl https://litterbox.catbox.moe/resources/internals/api.php \
        -F "time=1h" \
        -F "reqtype=fileupload"  \
        -F "fileToUpload=@$1"
           )" ntfy.sh/diviennes-bck
}

# f_send_to_litterbox_then_ntfy foo.jpg
#=> "topic":"diviennes-bck","message":"https://litter.catbox.moe/bar.jpg"

Create foo.zip from foo/sessionstore-backups/

for i in ~/.mozilla/firefox/*/sessionstore-backups; do
 zip -r $(
  cut -d/ -f6 <<<"$i").zip $i; done

#=> zip -r  foo.zip  ~/.mozilla/firefox/foo/sessionstore-backups/

Tests #

KO : 'Command substitution'

for i in ~/.mozilla/firefox/*/sessionstore-backups; 
do
 curl -X POST https://litterbox.catbox.moe/resources/internals/api.php \
     -F 'reqtype=fileupload' \
     -F "fileToUpload=@'$(zip -r "$(cut -d/ -f6 <<<"$i").zip" "$i")'" \
     -F "filename='$(cut -d/ -f6 <<<"$i").zip'"
done

#=> curl: (26) Failed to open/read local data from file/application

KO : 'Process substitution'

echo curl https://litterbox.catbox.moe/resources/internals/api.php \
    -F 'time=72h' \
    -F 'reqtype=fileupload' \
    -F "fileToUpload=@<(tar -cf - ~/.mozilla/firefox/jyvhpi6d.default-release/sessionstore-backups)" \
    
#=> curl: (26) Failed to open/read local data from file/application

OK : Piping

tar -cvf - ~/.mozilla/firefox/jyvhpi6d.default-release/sessionstore-backups |
 curl https://litterbox.catbox.moe/resources/internals/api.php \
    -F 'time=72h' \
    -F 'reqtype=fileupload' \
    -F "fileToUpload=@-"

#=> https://litter.catbox.moe/i7s4fy

Now send catbox URL to ntfy #

OK : Test using echo

for i in ~/.mozilla/firefox/*/sessionstore-backups; do
 pushd "$i"
  echo curl -d "$(
   echo tar -cvf - ../sessionstore-backups 
    echo curl https://litterbox.catbox.moe/resources/internals/api.php \
        -F 'time=72h' \
        -F 'reqtype=fileupload' \
        -F "fileToUpload=@-"
            )" ntfy.sh/diviennes-bck-ffx
 popd
done

#=> sessionstore-backups/ -> pzxf21 (tar)
#=> "topic":"diviennes-bck-ffx","message":"https://litter.catbox.moe/pzxf21"

Excursus: "Tips" from man tar #

  -C, --directory=DIR        change to directory DIR
  -J, --xz                   filter the archive through xz

Result, see on top #

last updated: