Mac Swift Tips – Schedule your backup with Automator, Calendar and Shell (rsync)

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.

Automator_1

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.

Automator_2

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.
Automator_3

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.

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 .

Lascia una risposta

L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati *

Immagine CAPTCHA

*

È possibile utilizzare questi tag ed attributi XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">