Add some tools for copying data out of Firefox, for backups.
This commit is contained in:
76
copy_firefox_data.sh
Executable file
76
copy_firefox_data.sh
Executable file
@ -0,0 +1,76 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# This script makes local backups of tabs and passwords from Firefox, and then regularly copies them to a backup server
|
||||
#
|
||||
# firefox_decrypt.py is available from https://github.com/Unode/firefox_decrypt
|
||||
#
|
||||
# firefox_tabgroups_export.py is available from https://gist.github.com/ssokolow/35097553e5173935e597
|
||||
# The version in this repo modifes the original to export only as text
|
||||
#
|
||||
|
||||
epoch=$( date +%Y%m%d%H%M );
|
||||
#server=10.25.0.1
|
||||
server=treehouse.org.za
|
||||
backups=~/Downloads/firefox
|
||||
|
||||
copy() {
|
||||
content=$1
|
||||
if [ -e ${content} ] && ping -qc1 ${server} >/dev/null; then
|
||||
rsync -a --delete -e 'ssh -i ~/.ssh/id_rsa-firefox_pass' ${content} ${server}:remember/
|
||||
#scp -ri ~/.ssh/id_rsa-firefox_pass ${backups}/firefox_tabs.${epoch} ${server}:remember/tabs
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -x ~/bin/firefox_tabgroups_export.py ]; then
|
||||
do_copy=0
|
||||
mkdir -p ${backups}/tabs
|
||||
mkdir -p ${backups}/tabs/sessionstore
|
||||
previous=$( ls ${backups}/tabs/firefox_tabs.* | tail -1 )
|
||||
~/bin/firefox_tabgroups_export.py > ${backups}/tabs/firefox_tabs.${epoch}
|
||||
if [ -f ${previous} ]; then
|
||||
if diff -q ${previous} ${backups}/tabs/firefox_tabs.${epoch} >/dev/null; then
|
||||
# No difference, remove this file
|
||||
rm ${backups}/tabs/firefox_tabs.${epoch}
|
||||
else
|
||||
do_copy=1
|
||||
fi
|
||||
else
|
||||
do_copy=1
|
||||
fi
|
||||
|
||||
# Delete backups older than $time
|
||||
find ${backups}/tabs -ctime +365 -delete
|
||||
|
||||
if [ ${do_copy} ]; then
|
||||
for session in ~/.mozilla/firefox/*/sessionstore*/*; do
|
||||
sessionfile=$( basename ${session} )
|
||||
cp ${session} ${backups}/tabs/sessionstore/${epoch}_${sessionfile}
|
||||
done
|
||||
copy ${backups}/tabs
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -x ~/bin/firefox_decrypt.py ]; then
|
||||
do_copy=0
|
||||
mkdir -p ${backups}/passwords
|
||||
previous=$( ls ${backups}/passwords/firefox_passwords.* | tail -1 )
|
||||
echo '' | ~/bin/firefox_decrypt.py > ${backups}/passwords/firefox_passwords.${epoch}
|
||||
if [ -f ${previous} ]; then
|
||||
if diff -q ${previous} ${backups}/passwords/firefox_passwords.${epoch} >/dev/null; then
|
||||
# No difference, remove this file
|
||||
rm ${backups}/passwords/firefox_passwords.${epoch}
|
||||
else
|
||||
do_copy=1
|
||||
fi
|
||||
else
|
||||
do_copy=1
|
||||
fi
|
||||
|
||||
# Delete backups older than $time
|
||||
find ${backups}/passwords -ctime +1 -delete
|
||||
|
||||
if [ ${do_copy} ]; then
|
||||
ln -srf ${backups}/passwords/firefox_passwords.${epoch} ${backups}/passwords/firefox_passwords
|
||||
copy ${backups}/passwords
|
||||
fi
|
||||
fi
|
Reference in New Issue
Block a user