Sunday, August 23, 2009

Quick USB backup from a Mac

I find it very relaxing to keep with me at all times the data I don't want to loose. While I work an external drive is plugged in and Time Machine keeps regular backups on a 100GB partition of it. However, although this drive is very small and light, I don't bring it everywhere. What I keep everywhere is an up-to-date copy of my work on a tiny 8GB USB key attached to my key-ring.

So whenever I leave after work I update the key, and this is how it gets done.



Mac OS X detects the new device and mounts it as it does normally. In addition the key is recognized, its contents are synchronized, and the key is ejected. This can be automated with the following steps.

Step 1: Download and install Rsyncx.

Step 2: Create this workflow with Automator.

Drag and drop Run Shell Script action. Copy and paste the following script in a single line. Replace [KeyName] and [FolderPath] with your values.

if mount | grep -qs '[KeyName]'; then time sudo rsync -s -e ssh "[FolderPath]" /Volumes/[KeyName]/; fi

Drag and drop Get Specified Finder Items action, click "Add...", type a slash and a box appears. In the box type /Volumes/[KeyName] .

Drag and drop Eject Disk action.

Step 3: Save the workflow as plugin for folder actions attached to folder /Volumes . Save it as a workflow as well if you want to modify it later.

Step 4: Enable folder actions at startup.

To deactivate the workflow and use the USB key normally, Ctrl-click on any item in Finder, moseover "More", click "Configure Folder Actions...". The workflow is associated to "Volumes". Uncheck it.

6 comments:

  1. I cannot for the life of me find out how to save the workflow as a plugin, did this change in snow leopard?

    ReplyDelete
  2. Hi XAG, I've been wrestling with your cool little hint for a good hour now to no avail. At this point I can only assume I've installed RsyncX incorrectly, as I've tried the rest of it over and over. I even thought you had a spelling mistake in your code since the screen grab kind of looked like it was "rsync -a -e ssh" rather than -s .

    Anyways, any advice you can give me would be appreciated.

    ReplyDelete
  3. While the basic trick of using rsync and Automator is a good idea, the instructions here seem to make no sense.

    The example uses an encrypted ssh connection, even though the copy is from a local drive to another local drive!!

    Because of this, I conclude the author doesn't quite understand what he is doing, and I wouldn't trust any of the instructions on this page.

    Still, thanks for the rsync/Automator idea.

    ReplyDelete
  4. Can you add code to choose which way to backup first (USB>Computer or Computer>USB) Or does this automatically transfer in the right order? I'd like to use it to transfer work done on one computer to another and vice versa, but i don't want it to backup from the computer that i'm trying to ADD files to.
    Thanks.

    ReplyDelete
  5. Shop from a wide range of USB flash drives from Officeworks. We have something to suit any budget. Buy online or visit us ordernow.co.za.

    ReplyDelete