diff --git a/README.md b/README.md index 6d26109..865ec4c 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,8 @@ convert infile.md in the current folder to a pdf file (outfile.pdf) with code bl ### flatten.sh move all the files in $1 subdirectories to $1. **Careful**, this operation is irreversible and manually moving back all the files to where they were supposed to be will be a pain if you flatten your home folder. + +### backupfirefox.sh +script to backup firefox config directory and restore the latest backup +adapt the hostnames and paths to what you need, not made to be easily configured with environment variables. +**Careful**, firefox config folder includes all your profiles, including their cookies and localstorage (access tokens of your accounts can be there). diff --git a/backupfirefox.sh b/backupfirefox.sh new file mode 100755 index 0000000..8c5b38e --- /dev/null +++ b/backupfirefox.sh @@ -0,0 +1,23 @@ +#!/bin/bash +DATE=$(date --iso-8601=hours) +if [[ "$1" = "--restore" ]] then + FILENAME="/home/fire/Downloads/$DATE.tar.gz" + tar -czf $FILENAME -C /home/fire/.mozilla ./firefox + echo "backed up current firefox data to $FILENAME" + case $HOSTNAME in + (HentaiStash) RESTORE="/home/storage/storage/code/browser/firefox/"$(ls -t /home/storage/storage/code/browser/firefox/ | head -n1);; + (ArchLaptop) RESTORE="/home/fire/Nextcloud/storage/code/browser/firefox/"$(ls -t /home/fire/Nextcloud/storage/code/browser/firefox/ | head -n1);; + (*) echo "include device in script"; exit 1;; + esac + echo "restoring $RESTORE" + rm -rf /home/fire/.mozilla/firefox + tar -xzf $RESTORE -C /home/fire/.mozilla +else + case $HOSTNAME in + (HentaiStash) FILENAME="/home/storage/storage/code/browser/firefox/$DATE.tar.gz";; + (ArchLaptop) FILENAME="/home/fire/Nextcloud/storage/code/browser/firefox/$DATE.tar.gz";; + (*) echo "include device in script"; exit 1;; + esac + echo "backing up current firefox data" + tar -czf $FILENAME -C /home/fire/.mozilla ./firefox +fi