?

Log in

No account? Create an account
 
 
13 February 2006 @ 02:28 pm
Finally have a backup scheme in place: free backups to my iPod.  
There's always the possibility of killing my laptop, either by dropping it, destroying it with a massive electric discharge, losing it to an opportunistic theft, offending the computer gods, or just lettigna friend with Bad Computer juju borrow it "just to check my email."

Finally, after shocking myself with a spark to my headphones after walking back into my office, I decided to sit down and make sure my data is backed up. I have an iPod with a ginormous amount of unused storage plugged in as an external firewire drive fairly often, so I decided to take advantage of this portable hard drive for backup purposes.

These directions do require a small amount of unix geekery. Given a little time, I could probably abstract this into a trivial little tool. Perhaps I could query iTunes for the iPod's name via Applescript, provide a trivial GUI for controlling the files and folders backed up, and provide a simple "click me" tool for setting up the cron job and the script. All this for only $19.95...

Step 1: Enable the iPod as a generic hard drive
In the iTunes preferences, click on 'iPod" and check "enable disk use".

Step (geekery) 2: learn how rsync works
basics man page
General usage: rsync file_to_back place_where_backups_go
Delete option: use the --delete flag to indicate that files in the backup folder should be deleted if you delete the originals.
Sane default: -a does most of what you want (recurse folders, preserve permissions and ownership, etc.)
Verbose: -v will tell you what rsync is doing.

Step 3: make a backup folder
In your iPod (/Volumes/iPod) make a folder named Backup

Step 4: try backing up a single file
Make a file name "todo.txt" on your desktop. In the terminal, run
rsync -vaE ~/Desktop/todo.txt /Volumes/iPod/Backup/
Check to make sure the file was correctly copied into your iPod's "Backup" folder.

Step 5: try backing up a folder
In the terminal, run
rsync -vaE ~/Documents /Volumes/iPod/Backup/
Make sure your entire Documents folder was copied over to Backup/Documents
Try the above command again, to see how fast an "incremental" backup can go with rsync.

Step 6: Create a backup shell script.
I put the following in the shell script "backup2ipod", detailing which files I want backed up.
#!/bin/bash
if test -d /Volumes/iPod/Backup;
then
# iPod folder exists means iPod is available for a backup
echo "Backing up";
# home directory configuration files
rsync -vaE ~/.bash_profile ~/.reminders ~/.ssh ~/.vimrc /Volumes/iPod/Backup/
#utility scripts (like this file)
mkdir /Volumes/iPod/Backup/bin
rsync -vaE --delete ~/bin/* /Volumes/iPod/Backup/bin/
#some desktop files
mkdir /Volumes/EvilGenius/Backup/Desktop
rsync -vaE --delete ~/Desktop/*.sxc /Volumes/iPod/Backup/Desktop/
rsync -vaE --delete ~/Desktop/*.txt /Volumes/iPod/Backup/Desktop/
# Documents folder
rsync -vaE --delete ~/Documents /Volumes/iPod/Backup/
# latest source code snapshot from subversion
rsync -vaE --delete ~/trunk /Volumes/iPod/Backup/
echo "Done";
fi

Save this to a text file named backup2ipod, edit it with the name of your iPod, and make it executable with the command chmod +x backup2ipod

Step 7: Set up a cron job
Using crontab -e and your text editor of choice, add the following line for hourly backup attempts:
0 * * * * ~/bin/backup2ipod

Now my laptop does a simple backup to the iPod every hour, provided the iPod is connected.
 
 
 
Stupendous Manfarmalloc on February 13th, 2006 11:35 pm (UTC)
Yeah rsync is sweet. When I worked at isilon I used it all the time. I had my desktop user account mounted via nfs from one of the latest longevity clusters. I kept an hourly rsync going to back up the data off the cluster onto my desktop machine in-case the cluster got fried.
Turning the Schmaltz up to 11pullthestars on February 14th, 2006 12:04 am (UTC)
considering that I haven't borrowed your fracking laptop in what, 2 years now? you ought to be clear of that problem.
St. Sean the Amused: kermitseanb on February 14th, 2006 12:13 am (UTC)
Kris, it's not always about you.
Other people borrowed my computers long before I met you, and I'm not quite ready to go to a universal "no, you cannot use my computer".
Turning the Schmaltz up to 11pullthestars on February 14th, 2006 12:22 am (UTC)
Re: Kris, it's not always about you.
sorry about the assumption.