If you’ve been using computers for a while, chances are you’ve lost valuable data more than once. Most computers nowadays come with CD writers (and many with DVD writers) which is great for the occasional manual backup – there is even the nice OSX-specific iSync tool which remind you when to perform the backup, and can manage the files being backed up too. However what would be better would be an automatic solution.
The rsync tool ships with OSX, Linux, and even Windows. Rather than copying and overwriting files on a remote location
rsyc performs incremental transfer of files – only those files not already present will be copied – this drastically reduces the time taken to perform backups.
For my purposes, I wanted files to be backed up off site. I decided to sign up for a Strongspace account. Strongspace provide external, secure storage – you can access your files either via the web interface, SFTP, or (handy for our purposes) via
rsync. While the rest of the article (and following parts) assume you’ll also be backing up to a Strongpsace account, it is a small matter to instead copy your files to an external disk drive or even another computer on your network. Note that Strongpsace supports
rsync by running an
rsync server – so these instructions should work equally well for backing up to any other
Assuming you have your Strongspace account setup already, lets get started. To start with, I simply want to backup the contents of my
rsync -azv /Users/johnsmith/Documents firstname.lastname@example.org:/home/johnsmith/backups/mac
When run, this will copy the contents of
Documents to the remote directory
/home/johnsmith/backups/mac. Unfortunately, since the release of Tiger my
Documents folder has become stuffed with lots of Dashboard widgets I never use. To ignore these, I specify the
rsync <del>azv </del>-exclude "Widgets" /Users/johnsmith/Documents email@example.com:/home/johnsmith/backups/mac
exclude option can take a regular expression, so you can specify multiple directories if you want to. If you want to backup files from multiple locations, then consider having a single
backup directory, then create symlinks to the directories you want backed up. You’ll need to add the
L option so that
rsync copies the referenced directory rather than simply copying the symlink itself:
rsync -azvL /Users/johnsmith/backup firstname.lastname@example.org:/home/johnsmith/backups/mac
Notice that when you run the command, you get prompted every time for your strongspace password. In part two we’ll start using an SSH key to avoid this, and we’ll be well on the way to providing an automatic backup solution.