Using Rsynch to Backup Directories ****************************************** Intro - We want to backup files on a given volume. Ideally, we'd have multiple backups of the file at different stages of development. Traditionally, you'd use tar to make an archive on another volume. Then, each day we'd run an incremental backup and add an addendum to the archive. However, with rsynch we can do a much neater trick. We maintain directory trees for each time (eg. LAST_WEEK, 2_WEEKS, 3_WEEKS) which just consist of links. Each weeks we shift the links. 3_WEEKS is deleted. 2_WEEKS -> 3_WEEKS LAST_WEEK -> 2_WEEKS LAST_WEEK = rsynch copy of source. If a source file (eg. FILEA) matches 2_WEEKS/FILEA then LAST_WEEK/FILEA is just a link to the same physical file as 2_WEEKS/FILEA. If the source file has changed, then version two of FILEA is copied to the backup volume. LAST_WEEK/FILEA linsk to version 2. 2_WEEKS/FILEA links to version 1. This is described more fully in rsynch_backup.html crucial commands are, cp -al (archive and link) rsync -av --delete --exclude-from=$FILE_LIST / /$Rsynch_Path/current ******************************************* Implimentation Tried this out backing up my home directory on BIGBRO II. Goal - Keep hourly, daily, weekly and monthly backups. Scripts are in /usr/local/sbin Each backup type done by - hourly_backup daily_backup weekly_backup monthly_backup Files to backup specified by backup_list Files written to /mnt/hdb/backup current hourly1 -> 1 to 2 hours old hourly2 -> 2 to 3 hours old hourly3 -> 3 to 4 hours old daily1 -> 0 to 1 days old daily2 -> 1 to 2 days old weekly1, weekly2 monthly1, monthly2 - 1 to 2 months old Scripts are symbolically linked to /etc/cron.hourly /etc/cron.daily /etc/cron.weekly /etc/cron.monthly Each script logs to /var/log/backup monthly_date weekly_date daily_date hourly_date hourly_error --> errors in maintaing main links. hourly -> report on copying backup archive. ************************ Shifting directory trees around. Consider weekly_backup. The main part is at the end where we, rm -rf weekly2 mv weekly1 weekly2 cp -al current weekly1 Hourly is different in that it uses, rsync -av --delete --exclude-from=$FILE_LIST / /$Rsynch_Path/current to generate the current folder. ************************ Selecting files to backup. We use the --exclude-from option for this. In the present example we back up /home/toombes but exclude the sub-trees /home/toombes/bigsis and /home/toombes/bigbro as these are mounts to other machines. Our exclude file, (backup_list) works like this - /home/toombes/bigbro - /home/toombes/bigsis # Ditch the two mounts + /home # Descend into /home + /home/toombes # Descend into /home/toombes + /home/toombes/** # Descend into all subdirectories of /home/toombes - * # Ditch if it doesn't match this pattern. ************************ References rsynch_backups.html by Mike Rubel http://samba.anu.edu.au/rsync/