Friday, July 4th, 2008

Backing up your Mac on an external disk

Filed under: Science and Technology — lemire @ 19:28

A couple of weeks ago, I needed to backup my MacBook Pro to an external disk (a firewire G-Drive) because my hard drive was failing. I started shopping for a good backup solution, but none of them had the following features:

  • support for incremental backups: if a change is made, you only backup the files that differ;
  • adequate handling of IO errors (no all-out abort);
  • inexpensive.

Indeed, I tried two different tools, but they refused to backup my disk due to numerous IO errors. They would not even tell me how to fix my problem.

As it turns out, your Mac has already all it needs, by default, to do just that. First, create a file called “backup.sh”, make it executable (chmod +x backup.sh) and copy the following content to it:


#!/bin/sh
RSYNC="/usr/bin/rsync -E"
# my external disk is located
# at /Volumes/G-DRIVE\ MINI/
sudo $RSYNC -a -x -S --delete --exclude-from backup_excludes.txt $* /Volumes/G-DRIVE\ MINI/
sudo bless -folder /Volumes/G-DRIVE\ MINI/System/Library/CoreServices

Then run it! Go to a shell and type “./backup.sh”. It will ask for you root password.

If you ever need to restore your files, then create a file called “restore.sh” with the following content:


#!/bin/sh
RSYNC="/usr/bin/rsync -E"
sudo $RSYNC -a -x -S --delete --exclude-from backup_excludes.txt $* /Volumes/G-DRIVE\ MINI/ /Volumes/Macintosh\ HD/
sudo bless -folder /Volumes/Macintosh\ HD/System/Library/CoreServices

Executing restore.sh may prove dangerous. Make sure you have tried booting from the external disk first. To boot from an external disk, I think you have to hold down the command key while rebooting.

4 Comments »

  1. Daniel,

    I have been using rsync to backup at work, with a different set of options (-Cavuz); I’ll check the options you use.

    I actually put the command in a Makefile so I just “make backup” every now and then.

    Have you figured out a way to automate the backup? I experimented a bit with Automator and Calendar but never could make it work properly.

    At home I use Retrospect Express, which came free with an external disk I bought. It does reasonably good incremental backups, but I find it quite slow.

    Comment by Cyril Goutte — 11/7/2008 @ 9:50

  2. What is wrong with cron jobs? Type “crontab -e” to insert a new cron job. Of course, you must deal with a syntax from the seventies, but it is well documented.

    Comment by Daniel Lemire — 11/7/2008 @ 11:42

  3. # my external disk is located
    # at /Volumes/G-DRIVE\ MINI/

    OK… how do I find out where *my* external disk is located?

    (p.s. related to the math question - I’m not so good at addition - heh)

    Comment by Stephen Downes — 30/7/2008 @ 20:09

  4. All disks on a Mac are located in /Volumes/. So go to shell and type “ls /Volumes/”. You should find it.

    Comment by Daniel Lemire — 31/7/2008 @ 13:45

RSS feed for comments on this post.

Leave a comment

Warning: When entering a long comment, please ensure that you make copy of your text prior to submitting it. If the server should fail or if you hit a bug, you might lose your work. I am not responsible for your lost effort.

To spammers: I carefully review every single post and make sure that spam gets deleted. You are wasting your time if you are manually entering spam using this form. Read my terms of use to see what I consider to be abusive.

Example: I + II + IX= XII. Yes, you have to enter a roman numeral. (Answer must be in upper case.)

« Blog's main page

29 queries. 0.516 seconds. Valid XHTML

Powered by WordPress

Subscribe to this blog in a reader or by Email.