Firefox and Thunderbird backup script

Simple script I run from cron to backup Firefox and Thunderbird. replace YOURHOMEDIR with your actual home directory or make it a variable.

#!/bin/bash

TODAY=$(date +%F)
YESTERDAY=$(date -d “-1 day” +%F)
THUNDDIR=”/home/YOURHOMEDIR/.mozilla-thunderbird”
THUNTAR=”/home/YOURHOMEDIR/.mozilla-thunderbird-$TODAY.tar.gz”
OLDTHUNTAR=”/home/YOURHOMEDIR/.mozilla-thunderbird-$YESTERDAY.tar.gz”
FOXDIR=”/home/YOURHOMEDIR/.mozilla”
FOXTAR=”/home/YOURHOMEDIR/.mozilla-$TODAY.tar.gz”
OLDFOXTAR=”/home/YOURHOMEDIR/.mozilla-$YESTERDAY.tar.gz”

#back up thunderbird
function back_up_thunderbird
{
tar -czf $THUNTAR $THUNDDIR; RCTHUN=$?
if [ “$RCTHUN” -eq “0” ]; then
if [ $(test -e $OLDTHUNTAR)$? = “0” ] ; then
rm -f $OLDTHUNTAR
else
echo “$OLDTHUNTAR not found”
exitstat=1
fi
else
echo “$THUNTAR error $RCTHUN”
exitstat=1
fi
}

#back up mozila
function back_up_mozila
{
tar -czf $FOXTAR $FOXDIR; RCFOX=$?
if [ “$RCFOX” -eq “0” ]; then
if [ $(test -e $OLDFOXTAR)$? = “0” ] ; then
rm -f $OLDFOXTAR
else
echo “$OLDFOXTAR not found”
exitstat=1
fi
else
echo “$FOXTAR error $RCFOX”
exitstat=1
fi
}
if [ $(test -e $THUNTAR)$? = “0” ]; then
exitstat=0
else
back_up_thunderbird
fi

if [ $(test -e $FOXTAR)$? = “0” ]; then
exitstat=0
else
back_up_mozila
fi

exit $exitstat

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*