01 June 2010

Backup with rsync

rsync is an amazing piece of software that can be used as a powerful backup tool. I made a very small and very simple backup script using rsync to save important files to a usb pendrive. After some trial and error, it is very handy.
I devised a small trick which consists in putting a dot at the end of only the files I want to include in the backup. This way, when I create a directory that I want to have copied to the usb I only have to name it with a dot at the end and it's done. The script is as follows:

#! /bin/bash
#This is a very simple backup script using rsync. It copies files to a usb pendrive assuming that it is already mounted. If not, use the mount command as root or pmount (Maybe better)
#The ampersand sign is used to redirect standard error to a logfile.
#Good idea to use it with cron. My crontab is 0 21 * * *
rsync -rlptoDvh  --delete /home/chals/*. /media/KINGSTON/ &> asb.log

I named the script 'asb'. It is a play on words with the name of our internet association (asc). 'asb' stands for advanced system backup. lol