Backing Up On OS X

posted January 16, 2010 by daniel

Using Apple's Time Machine backup system isn't really possible with FileVault because you have to log out for the files to be backed up. This is a collection of scripts that backs up any files or folders you choose to an encrypted disk image. The backup images can be on external USB drives or on a remote machine. The remote system does not need to be formatted for HFS+ file systems or even understand HFS+, so a Linux or Windows backup server will work fine.

Download Scripts

Create Backup Disk Image

The first step is to create an encrypted backup disk image. Mount your USB drive, or network folder and navigate there in Terminal. The mksimg.sh script takes one parameter: the name for the encrypted disk image. The name can be anything you want. When the script runs, it will ask for a password to protect the image. The image will be created in a few minutes. Create Backup Image

cd /Volumes/<backup drive>
mksimg.sh <backup image name>
<enter password>

Navigate to the new backup disk image in Finder and open it. When you are asked for the password, enter it and be sure to check the option to save the password in your Keychain. Once the image is mounted, you can eject it again. From now on, the image will mount without asking for the password. Create Backup Image

Edit Backup Paths

The second step is to edit the backup script (backup.sh) with your paths. Set the name of your backup drive and your short user name (/Users/your_name_is_here). Since you probably don't want to back up all of your files, you can edit the backup_includes.txt file listing the files and folders you want to back up. This file is a standard rsync include/exclude file. Lines starting with '+' are included and lines with '-' are excluded.

Running Backup

The backup.sh script uses syncf2d.sh (sync-folder-to-disc) and syncfiles.sh to mount the encrypted disk image and rsync your files to the backup image. You can run the backup script from Terminal, or create a repeating iCal event and run the script as the alarm.
iCal Backup Alarm