OS X Online Backup (Connection & Test)
March 19, 2007
I’m assuming that you’ve gathered the materials indicated in Part 1 — specifically, that you’ve got an account set up with Talanov or a similar service, and have an FTP program that supports Secure FTP (SFTP) handy.
Our rsync transfers will be made over the Secure Shell protocol known as SSH. This insures that all of your data is transmitted in an encrypted fashion.
We could log into SSH with the username and password provided by our backup vendor (and we will while setting this up), but this would be a little annoying if we had to do it every time we backed up, so instead, we’re going to exchange encryption keys that will allow our Mac to automatically identify itself to the backup server (and vice versa) when our script is run.
We’re also going to want our scripts to run with administrator privileges on our end, so that they have sufficient permissions to access all of our files.
Go to System Preferences, Accounts, and make sure that “Allow user to administer this computer” is checked.
Next, You’ll need to open your terminal application (usually located in Applications/Utilities), and enter the following commands.
Type the following:
sudo mkdir /backup
(Sudo temporarily gives us “root” privileges. When you preface a command with sudo, the system will prompt you for your administrator password before performing the command. If you perform other sudo commands within the next few minutes, it will remember your password, but if more than a couple of minutes pass, you’ll need to type it again. Just enter your password whenever you’re prompted to do so.)
Now type the following (all on one line, and those are two single quotes at the end):
sudo ssh-keygen -f /backup/ssh_key -t rsa -N ”
This generates our key. Next, we’ll transfer our key to the server. Replace “username” in the following command with the username you’ve been given. If you’re not using Talanov, you’ll also want to substitute the name of the server with the one you’ve been instructed to use. Again, this is all on one line:
sudo rsync -e ssh /backup/ssh_key.pub email@example.com:keys/server1
You’ll be promoted for the user ID and password for your backup account. If this doesn’t return an error, then it worked properly. Now we have to merge our keys on the server:
sudo ssh firstname.lastname@example.org mergekeys
Again, you’ll be prompted for your user ID and password. Assuming that executed without errors, you’ve now got your keys set up, and are ready to try sending some data.
Pick something small, since you don’t want to wait forever. In my case, I just transfered a small folder called “test” from my desktop, and I placed it in a folder on the server called “backup-test”:
sudo rsync -avz -e “ssh -i /backup/ssh_key” “/users/username/Desktop/test” email@example.com:backup-test
Again, that’s all on one line. Substitute “/users/username/Desktop” with whatever your Mac username is, and put in your username for the backup service in place of the other one. You should see your files being transmitted.
Once this is done, go to your FTP program, and open a SFTP connection to your backup server (use the same server name, user ID and password you’ve been using).
You should see your backup folder (“backup-test” in the example above), and the files from your test folder should be in it. Once you’ve verified that everything looks right, you’ll probably want to delete your test folder from the server to conserve space.
Congatulations! You’re now rsyncing to your remote backup server!
In the next part of this series, we’ll look at how to do some serious backing up, and begin automating this process.