advertisement

Article:
  Automated Backups on Tiger Using rsync
Subject:   rsync backup script - now Incremental with little storage impact
Date:   2006-12-04 14:18:08
From:   Inspector71
Response to: rsync backup script

Hi TheBronx,


Thanks for your script - it really helped. I was wanting to do a similar thing, but I found out you can do incrtemental backups that don't copy the files across each time - only the hard links (so you need very little extra storage space); so I used yours and amended it as follows:


I got it to check if the HDD was available or not before continuing (I'm using a MacBook so I can't guarantee that the backup drive will be plugged in) and to exit if not.


I also implemented incremental backups so that I have copies of the state of my source for the last 9 times it was backed up (in case I backup an error). I liberally used the code on this page: http://www.macosxhints.com/article.php?story=200310240137579


Lastly, I fiddled with some of the shell scripts to exclude .Trashes and Volumes folders as well as the Downloads folder on my system. The /Volumes exception is important as the first time I did this I not only backed up my internal HDD but also the other partition on my external one, as rsync followed the symbolic links.


I also found that Spotlight kicked in and started indexing my backup very quickly, with enormous performance consequences. I recommend you start off by disabling indexing on your backup drive by following the advice here: http://www.thexlab.com/faqs/stopspotlightindex.html, then try running the script.


As TheBronx suggests, find out what the name of your disk is using diskutil list and replace it into here. My partition for backing up is called Backup and I have folders 01-09 for increments within that. I have it set to backup my entire internal HDD (/).


The only problem I am having now is that unless I run it as root (which I haven't done yet) I lose all file ownerships and everything reverts to my user.


Here it is, have fun:



do shell script "echo ================================ rsync Backup script ================================= >>~/rsync.log"
do shell script "date >>~/rsync.log"


-- Make sure Firewire HDD is available, otherwise quit
do shell script "ls /Volumes/"
if result does not contain "Backup" then
do shell script "echo ==Mounting Backup Disk: >>~/rsync.log"
do shell script "diskutil mountDisk disk1s2"
do shell script "ls /Volumes/"
if result does not contain "Backup" then
do shell script "echo : Could Not Mount Backup Disk - Exiting =============!!!============= >>~/rsync.log"
return
else
do shell script "echo : Backup Disk Mounted >>~/rsync.log"
end if
end if


-- Rotate Backup dirs, deleting the oldest
do shell script "echo ==Rotating Backup Directories== >>~/rsync.log"
do shell script "rm -rf /Volumes/Backup/09"
do shell script "mv /Volumes/Backup/08 /Volumes/Backup/09"
do shell script "mv /Volumes/Backup/07 /Volumes/Backup/08"
do shell script "mv /Volumes/Backup/06 /Volumes/Backup/07"
do shell script "mv /Volumes/Backup/05 /Volumes/Backup/06"
do shell script "mv /Volumes/Backup/04 /Volumes/Backup/05"
do shell script "mv /Volumes/Backup/03 /Volumes/Backup/04"
do shell script "mv /Volumes/Backup/02 /Volumes/Backup/03"
--do shell script "cpio -pdl /Volumes/Backup/01 /Volumes/Backup/02"
do shell script "cd /Volumes/Backup/01 && find . -print | cpio -pdla /Volumes/Backup/02"


do shell script "echo ==Directories Successfully Rotated== >>~/rsync.log"


-- Do rsync
do shell script "echo ==start rsync logging== >>~/rsync.log"
do shell script "rsync -aE --progress --delete-after --exclude=Volumes/ --exclude=Downloads/ --exclude=.Trashes / /Volumes/Backup/01 >>~/rsync.log || echo -n"
do shell script "echo =rsync Backup Ended== >>~/rsync.log"


on idle
return 60
end idle


do shell script "diskutil unmount disk1s2"
do shell script "echo =====Backup Complete===== >>~/rsync.log"


Cheers,


Marcel



1 to 1 of 1
  1. rsync backup script - now Incremental with little storage impact
    2006-12-04 14:25:36  Inspector71 [View]

1 to 1 of 1