Using Automator to Back Up Your Server

Posted Nov 20, 2007 | by David Risley  

Automator IconThere is a tool inside of OS X called Automator. Automator is a very undervalued utility that is bundled with OS X. It is one of those things that I wish came with Windows, but sadly it does not. Automator is a utility which allows you to create a workflow, a series of software actions your computer will take, and then run it. This allows you to have your computer do work for you on automatic – hence the name.

What I like about Automator is how it really is a WYSIWYG way of programming. It allows a non-programmer to essentially create scripts which will have the computer do things for you. With Windows, you can use VBScript and create batch files, but that is beyond the skills of most (including me). There are utilities for Windows that do similar work as Automator, but they are not cheap. For example, a program called Automise for Windows does provide an environment for creating scripts, but it is more complicated and it costs $195. That is more than the entire OS X operating system. On the contrary, Automator is bundled with OS X and it is pretty easy to use.

To use Automator, you will still need to think like a programmer. You will not need to get into actual coding (unless you want to make some seriously powerful Automator workflows by coupling it with AppleScript), but you do need to be able to apply a little bit of logic in order to place actions in the right order. Essentially, Automator gives you a list of actions. You combine those actions into meaningful workflows that accomplish something. Using an action is a simple drag-and-drop into the workspace. You set a few parameters on the action and it is in place.

To illustrate my first use of Automator, I will walk you through the steps I used to create workflow designed to download my database backups from my server to my Mac. I will then show you how to use CRON to run that workflow automatically. In my case, I run that workflow every night so that I constantly have the backups here on my Mac. CRON is that operating system service that comes on all UNIX operating systems that is designed to run things at certain times. It is very commonly used in web servers that are using a UNIX-based operating system. Well, Mac OS X is also based on Unix, so it uses CRON as well.

In my example, I used my FTP client Transmit to perform the actual file transfer. Here is how I do it.

  1. Drag the “Launch Application” action to the workspace. In the dropdown menu for this action, I selected Transmit (my FTP client).
  2. Drag the “Synchronize Folder” action into the workspace. In my case, Transmit comes with this action and it puts it into Automator. So, the action is specifically programmed to work with Transmit. I specify the server name, login, the folder on the local side I want to download to, the folder on the remote site (my server) where the backups are, and the direction for synchronization (Download).
  3. I then drag the “Quit Application” action into the workspace and select Transmit.
  4. I save the work as a workflow. You can hit the “Run” button in Automator to test the workflow and view results. I do this and I can see that the workflow works. Cool.
  5. Next, I want to run this workflow via CRON. You can set up cron jobs via the command line, but I install and launch CronniX, a program which provides access to CRON via the usual graphical interface.
  6. I use the following command to run the workflow:automator /Users/davidrisley/Documents/Workflows/GetDatabaseBackups.workflow/Contents/document.wflowNote you need to put “automator” into the command so that the system knows how to open the file. Also, while the “workflow” document will appear as a file in Finder, it is actually what is called a “Package”. If you right-click on it and select “View Package Contents” you will see that it actually consists of a bunch of files. So, you need to delve into it and get to the actual script to run it via CRON.
  7. Set it up to run whenever you want.
  8. You’re done.

Here is a screenshot of Automator with the above workflow in it. Note the library of actions on the left side, all of which are draggable into the workspace to create a wide range of different workflows.

Automator Workflow

Note that this whole procedure necessitates that you have something on your server ready to backup. If you are grabbing your site files, then good. If you want to grab database backups, you will, of course, need something on your server that is doing database dumps and placing those files in your server’s file system.

Automator is capable of some really powerful things. This workflow is actually really basic, but was of use for me.

So, are any of you using Automator? I’d be interested in your comments on what things you have done with it.

Which Of These Traits Applies To YOUR Computing Life?...

5 Responses to “Using Automator to Back Up Your Server”

  1. Ray says:

    You can use iCal and attach the workflow to a recurring event rather than than installing a crontab

  2. brian says:

    I’m just starting to use Automator/Transmit to backup desktop files to a remote server. Wondering if you can help me with a problem I’m having.

    There are certain files that Transmit uploads even though they were just uploaded the night before. The transcript says “No such file or directory” but the exact same files, with the same names are already on the server. This only happens with certain files.

    I’m running the “Synchronize Files” script and have specified “upload” and “update.”

    Any help would be much appreciated.

  3. Matthew says:

    You can simplify this a bit. By using Automator, you don’t have to add a “Launch Program” step to the workflow. Transmit Installs an action right in to Automator (maybe not when this was written though) so you can drag the Transmit action directly in as your first step. After you set the paths and such for the destination folder, just drag in a “Quit Application” action. I save as an app and added it to my Open at Login list. Kudos to the first comment by Ray, I didn’t even think to create a backup schedule using iCal. Great idea!

    This saves a step.

  4. konrad says:

    Great guide and comments! Thanks!

Leave a Reply