Automated and Secure iPod Backups

As my digital life becomes more complicated I’ve run across numerous backup strategies that have been helpful. However, I recently discovered an easy way to keep a digitally secure copy of my most critical documents with me at any point in time. This article is a shortened version of a larger article I am working on regarding comprehensive mac backup strategies.

The Goal

Make a portable, secure, and do-not-have-to-think-about-it backup solution for my critical documents.

As an MBA student who is working on lots of projects at any point time, having an easy and secure backup on my iPod seems like the most practical solution. However, being a busy MBA student, this is not something I want to have to think about every week or even every day.

I have a 15″ MacBookPro, a 4GB iPod Nano, and OSX 10.4.6. Lets go…

My personal files, including tax forms, receipts, assignments and documents do not total more than 1GB presently. With the rate of iPod storage expansion and cheap online hard drive space, I don’t ever think I will be ahead of the curve. That being said, it seems really reasonable to carve out a 1/4th of my iPod for this purpose.

The Solution

Following this article at Non-stop Mac and using Apple’s Disk Utility, create an AES-encrypted disk image on the iPod using Disk Utility. Here I’ve selected one for 1GB which should be more than enough. You could also create a sparse disk image – however other folks seem not to recommend it since they can become corrupt at times. Make sure you assign a strong password to it.

iPod Backup Screen 1

Open the .dmg file you just created on your iPod. When the Finder prompts you for the password, enter the password and make sure you add it to your keychain. This will allow the script we will run later to automatically mount it. Continue by unmounting the image you just mounted.

iPod Backup Screen 2

The next step is a little scripting magic that will make life easier. By using rsync, we can keep a copy of whatever is in your ~/Documents directory to your Documents.dmg disk image. I keep a folder of scripts that I use and I’ve written a little shell script to execute the following code.

#! /bin/sh

if [ -d "/Volumes/BlackPod" ] ; then
echo "###########################"
echo "Starting iPod Documents Backup on `date`"

echo "Attaching to Documents.dmg"
hdiutil attach -private /Volumes/BlackPod/Documents.dmg

echo "Running rsync against /Volumes/Documents"
/usr/bin/rsync -rlptE --size-only --delete /Users/username/Documents/ /Volumes/Documents/

echo "Detaching"
hdiutil detach /Volumes/Documents

echo "Backup completed on `date`"
echo "###########################"
fi

Store this file in place you will remember. My script file is stored in ~/Backup/ and it is named ipod_documents_backup. Additionally you will need to execute chmod go+rx in order to allow it to execute. Open the Terminal and change the directory containing your script. To then test it type ./ipod_documents_backup (assuming you used the same name as me).

iPod Backup Screen 3

You should see something similar to the image above.

Now the final step is to schedule this to run periodically. The script checks for the existence of your iPod volume before proceeding. If it finds it, it will go ahead and run, if not it will quit quietly. We can use the power of cron and schedule this to run whenever we feel is necessary. I won’t give you a detailed cron tutorial, you can find those on the web. But here is the entry I used:

0,15,30,45 * * * * /Users/username/Backup/ipod_documents_backup

I’ve scheduled mine to run every 15 minutes since I usually do not have my iPod plugged in for extended periods of time. Usually once in the morning during coffee time to sync with updated Podcasts and once in the evening to update what’s been listened to. Your mileage may very.

The Results

You now have a copy of your documents on your iPod that is updated with reasonable frequency while plugged in. You can access those documents from any Mac by simply plugging in your iPod and mounting the image with knowledge of your password. Additionally, if your iPod is stolen, it is unlikely that someone will be able to brute-force guess the password of your AES encrypted image.

As a side-note, Apple’s Backup 3.0 with .Mac integration is a decent alternative, but a bit useless unless you have access to another machine with Backup installed and you can alter their system to use your .Mac password. Additionally, I don’t quite trust .Mac fully from a security perspective, but I digress…

I’m sure there are additional error checks and script tweaks that could be achieved if I knew more about shell scripting had time to dive into it. Your comments and suggestions for improvement are welcome. I hope this is useful. Enjoy and good luck!

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.