blog

4 June 2006

Automated Backups

by Anton Piatek

I recently wrote about Backup Options but never mentioned how I actually kicked off the backups.

I use a crontab to start my backups, it looks like this:

@daily unison -times -batch /home/anton/Documents ssh://MyServer/Documents -servercmd /home/anton/bin/unison >> $HOME/cron.unison.log 2>&1
@weekly rsync –stats -auv –delete –exclude “*.db” –exclude “*/.pics/” “/home/anton/My Photos/” home:”~/My Photos/” >> $HOME/cron.rsync.log 2>&1

I am sure you can achieve this under windows with either cywin (which you will probably want for a good command line ssh client/unison anyway) or with the scheduled tasks and a batch file.

The commands are fairly simple, and redirect all output to cron..log (the “»” redirect means it will append to the file and “2>&1” will redirect all errors as well)

Rsync lets me exclude certain files. In this case I am excluding windows .db files (windows explorer thumbnails) and .pics directories (Digikam thumbnails), though I could copy them too.

The reason my photos are weekly as opposed to daily is because I might change/add enough photos for the upload to take more than 24 hours on a slow broadband connection (I do not want two scripts running at once, though there are defenitely better ways of achieving this i.e. writing a script to do the backup that checks for a lockfile)

tags: