Jeff Smith

Text

Schedule Local Backups With iCal and Automator

A while back “Matt Brett”:http://mattbrett.com posted a “message on twitter”:http://twitter.com/mattbrett/statuses/3134673 that he was looking for a simple backup/sync solution for OSX. I dropped him an email with my backup solution and thought to myself that it would be a good idea to post it here as well. Of course, time passed and I still hadn’t gotten around to getting anything written up, until “Matt posted an article on his site”:http://mattbrett.com/archives/2007/05/the-power-of-twitter/ about the power of twitter, and mentioned my backup script. Since then I’ve had a constant stream of emails flowing into my inbox about my backup script, so finally, here it is.

The first thing to do is grab the example Automator workflow here .

Step 1
Next, open the script in Automator and in Step 1, add the path to the folder that you want to back up. ‘~/”Local Folder”’ is the folder that is in my home directory that I want to back up and “/Volumes/DiskName/Backup” is the back up folder on my external drive that I want to copy the files to. You can repeat that command on a new line for other folders that you want to back up and it will copy them to the Backup folder on your external drive. The particular rsync command that I’m using here will only copy over changed files so that it doesn’t have to copy every single file over to your backup every day. For more information on other rsync commands, type “man rsync” in the Terminal, or “[“view the manual online”:http://everythinglinux.org/rsync/. You might want to look into the ‘—delete’ parameter if you like file to be deleted on your backup drive as you delete them from your local folders.
Step 2
Step 2 pops up a growl notification when the backup process is complete. If you haven’t installed growl yet, definitely give it a try, “it’s a very handy little app”:http://growl.info. You could also have the workflow send you an email when the backup is done, if you prefer. The one caveat here is that you won’t get confirmation if the backup was actually successful, this notification will display even if the rsync command fails (which it shouldn’t unless your external drive isn’t mounted, or if you have errors in some of your folder paths above). After you get that all set up, head to “File > Save As Plug-in, change the “Plug-in for” format to “iCal Alarm”, enter a name like “Local Backup” and save.
Step 3
After the new plug-in is saved, iCal should open automatically and create a new calendar event on the current day in your default calendar. This part is a personal preference, but I like to keep all of my scheduled scripts in a calendar by themselves (called Backups) just for organization’s sake. Now, the choice is up to you how often you’d like your backup to run and at what time, change the repeat field to be whatever you’d like it to be (I set mine to daily), adjust the time that the script is executed (I set mine to a time I know I won’t be using my computer — 4:30am), and you should be good to go for local backups. Something else to note is that you can use this method in iCal to run just about any type of application/process/script you wish, it’s just a matter of changing the alarm time for an event to “Open file” or “Run script”. A new field right below that will appear to allow you to select the file you’d like to run. Over the next couple of weeks, I’ll show you how I use this method to back up my local files to a remote server, as well as how I grab daily MySQL backups from my webserver. Feel free to leave any questions in the comments below if I’ve left anything out, or if you get stuck with the process.

* Please note that this is vastly updated from my network backup workflow that I posted a couple of years back.

View comments
Posted on Thursday, June 14 2007.

Jeff Smith This is the home of Jeff Smith, a web developer, designer, and craft beer connoisseur living in Amherst, Nova Scotia. This blog was formerly known as "From Away".

You can find out more about me by viewing my work, following my tweets, or by following my growing photography skills. Feel free to get in touch if you'd like to chat about anything.
PortfolioPhotosContact
Previous Next