Interruptible link-dest Backup Solution

I was inspired by Time Machine for every Unix out there to use the link-dest technique for backing up one external disk to another, however I found some limitations in its implementation, so I modified the script.

  1. Moved Source and Destination into variables.
  2. Added a Progress directory so the script can be interrupted and resumed.
  3. Added an exclude file to the Source directory so that the External disk’s special folders (Spotlight, etc) are not copied.
  4. Added the -E flag to rsync so it copies Extended Attributes on Mac OS X (remove if you are not using Mac OS X).
  5. Added the -x flag to rsync so it does not span disks.
  6. Added the –delete flag to rsync so if rsync fails upon re-running the script files deleted from the source are deleted from the Progress directory.
  7. Modified the Date format to mimic Time Machine’s.
  8. Modified the Destination so that it directly uses it rather than a subdirectory.
  9. Modified the symbolic link command so it removes the old Latest link and creates the new one in one step.
  10. Use && to ensure commands don’t occur if rsync fails.

The script (Updated to fix bug):

#!/bin/sh

source="/Volumes/Gray"
destination="/Volumes/Gray Backup"

mkdir -p "$destination/Progress"
rsync -aPEx --delete --exclude-from="$source/.exclude" \
            --link-dest="$destination/Latest" \
            "$source" "$destination/Progress" \
    && date=`date "+%Y-%m-%d-%H%M%S"` \
    && mv "$destination/Progress" "$destination/$date" \
    && ln -sfh "$date" "$destination/Latest"

4 Responses to “Interruptible link-dest Backup Solution”


  1. 1 Michael

    Hi!

    Awesome additions; much cleaner than mine :-)

    Cheers, Michael

  2. 2 stefan

    He, this script looks good! I’m tempted to use this on my mac to backup to an NFS file system.

    Do you have any experience by now, did you have any issues on the long term…?

  3. 3 Cortland Klein

    I ended up using Time Machine directly, as it handles the cleanup of old snapshots automatically. However, this script may still be useful for those just wanting their own custom solution.

  4. 4 stefan

    I see. I think I would also opt for time machine, but I cannot get it to work on NFS. As I don’t want to push Time Machine into doing things it’s not supposed, I think it will be better to make my own aolution. Putting in cleanup of old snapshots shouldn’t be to hard either I think.

Leave a Reply