My daily backup

I recently recovered my files from my daily backup, which had actually worked!

(Pop quiz: this is how I deleted half my home dir – what is wrong with this Makefile?


blah: blah1


    rm -rf $TMPDIR/



Anyway, I am extremely grateful that the backup did work, but a slight problem was that I have been backing up absolutely everything, and never deleting anything that was backed up until I ran out of disk space.

So when I restored from backup, every file I had ever deleted (since I started backing up) re-appeared. This included files and dirs (and email) that had just been moved somewhere else – I now had 2 copies of them.

I’ve spent the night deleting stuff that I didn’t actually want restored, and this has encouraged me to create an improved backup script that puts deleted stuff into a separate folder, named after the day it was deleted. I can delete those folders at my leisure when they get too big, but when a disaster happens like it did on Wednesday, I can restore back to a sane state by just ignoring any irrelevant deleted folders.

It’s quite simple, but I hadn’t thought of it before, so it might be helpful to others. Enjoy:


# Copy this to /etc/cron.daily and make it owned by root, and executable

# Back up everything important from my main drive (hda) to the backup
# drive (hdb).

# Keep stuff that has been deleted from the real drive in a separate
# backup dir, named after the day it was deleted.


FLAGS="-a --delete-during --max-delete 100 --backup"

DT=`date +%F`

function run_rsync

    echo rsync $FLAGS --backup-dir=$BKP_DRIVE/$DELETED_DIR$THIS_DIR \
    rsync $FLAGS --backup-dir=$BKP_DRIVE/$DELETED_DIR$THIS_DIR \

run_rsync /home/andy \
    "--exclude /iRiver --exclude /downloads --exclude /.Trash --exclude /misc/qemu"

run_rsync /etc

run_rsync /var

run_rsync /boot

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.