Last week I was trying Backblaze in order to achieve a full backup of my files on my 2 macs. I quickly realised that a complete backup of more than 1 TB of data was really going to take a lot of time.
What to do in the meantime?
I decided to do a backup of the folder of my works on the Airport Time Capsule connected to my LAN (but it could be whatever hard drive you have).
To take it to the next level, I thought it could be easily become my scheduled backup of the weekend, so that I could always have two levels of backup: local and cloud.
I know Automator was going to be my friend, so let’s dive deep into the workflow.
Automator has a cool option that lets you create a Calendar Alarm.
File –> New Document –> Calendar Alarm.
Those kind of automator workflows are triggered by calendar events.
The first block of our workflow is a simple dialog asking if we want to go on: Ask for Confirmation.
Then, we run the actual shell script that performs the backup (of which we will see the code in a moment): Run Shell Script.
If we like to, we can put the result of the last operation into a text file that will act as the log of our backup: New Text File, with the option of File format: same as input text. We can also choose were to save this log.
After everything is finished, we notify ourselves so that we can go to sleep in perfect peace of mind (many thanks to the beautiful new notification center) : Display Notification.
Now, we only have to create our event in Calendar.
We can create a new event and set it to repeat every week, and as alert type choose custom –> open file –> pick our automator workflow.
Now, we’re all set up!
At the time we have chosen, Calendar will load the workflow and run it.
Pretty neat, isn’t it?
Here’s the source code of the shell script.
# Rsync backup branched on different macs MAC_PRO="hw.model: MacPro6,1" MACBOOK_PRO="hw.model: MacBookPro8,2" # sysctl returns the model of our mac CURRENT_MAC=$(sysctl hw.model) echo $CURRENT_MAC if [ "$CURRENT_MAC" == "$MAC_PRO" ]; then echo "-- Starting Backup of Mac Pro --" # Here's a sample rsync command # remove the first # to uncomment: # rsync -avzPi --delete "/Users/yourname/Test\ Source\ Folder/" "/Users/yourname/Test\ Target\ Folder/" else echo "-- Starting Backup of MacBook Pro --" # Here's a sample rsync command # remove the first # to uncomment: # rsync -avzPi --delete "/Users/yourname/Test\ Source\ Folder/" "/Users/yourname/Test\ Target\ Folder/" fi
Note that rsync is a REALLY POWERFUL and FAST command, do not use it unless you know what you’re doing.
My backup is currently branched depending on the models of my two macs, feel free to cut and edit it for your purpose.
For more infos on rsync and its args, have a look here: http://www.computerhope.com/unix/rsync.htm .