rsync 101 for Linux, Unix and BSD

rsync is a snap to use. It's easily the best backup utility out there. You can also use it in place of other copy tools like cp, rcp, and mv.

To get started with rsync:

  1. Create a directory for your keys and scripts.
  2. Create an SSH key pair with ssh-keygen.
  3. Identify the data you want to back up by configuring an rsync backup.
  4. Upload the initial backup data to your EVBackup account.

Step One: Create the Backup Directory

To begin, open a terminal (Gnome-Terminal, Xterm, Kterm, etc.) and create a directory for your backup files. We recommend /backup.

sudo mkdir /backup

Step Two: Generating an SSH Key Pair with ssh-keygen

  • Each of the following commands are entered as a single line.
  • You'll want to run all of the commands here as the 'super-user' (using sudo), so that you have full access to all the files on your machine.
1. Create an SSH key pair with ssh-keygen
sudo ssh-keygen -f /backup/ssh_key -t rsa -N ''
Note the command ends with two single quote characters.
  • Why do I need an SSH keypair? »
  • « OK. Hide this

An SSH key pair allows you to securely log in to your backup server without entering a password each time.

2. Upload and activate the public key to your EVBackup account
sudo rsync -e ssh /backup/
ssh addkeys
Show Me
Successful SSH key pair generation in Linux

Successful SSH key pair generation in Linux

  • Notes about uploading »
  • « OK. Hide this
  • Substitute user with your EVBackup account name.
  • When you enter this command, you might see a message indicating that your computer doesn't recognize the server. Just enter yes when prompted and you'll never be bothered again.
  • You'll be asked to enter the password for your EVBackup account. Once the key is uploaded and activated, this won't be necessary again.
  • If Terminal simply returns (looking as though nothing has happened), then you have successfully uploaded your key!
3. Test that you can log in without a password
sudo ssh -i /backup/ssh_key
  • How do I know if it worked? »
  • « OK. Hide this

If you were successful, then something very similar to the following will appear in Terminal:

Last login: Thu Jul 15 16:16:44 2010 from c-28-26-13-101.
Copyright (c) 1983, 1986, 1988, 1990, 1991, 1993, 1994
The Regents of the University of California. All rights reserved.

[your-account@quark ~]$

Step Three: Configuring a Backup Session

Once you have your SSH key pair generated, uploaded and tested, the next step is to run a simulation of the backup command. rsync provides a really neat argument to help you do this: --dry-run. The --dry-run argument will help you sort out the options you'll be using in the backup script that you'll be automating later.

A basic rsync command with --dry-run command looks like this (all on one line):

sudo rsync -avz --dry-run -e "ssh -i /backup/ssh_key" /local/folder

You might have noticed that you are running the command as the "super-user." While this is optional depending on your system, we suggest that you run the command with root privileges so that you can be sure everything is backed up.

Example rsync Command

User bobsmith wants to backup the local directory /home. He wants to put the backed up files in the home-data directory on the server. Here is what his rsync command would look like (again, all on one line):

sudo rsync -avz --dry-run -e "ssh -i /backup/ssh_key" /home

If you have any questions, concerns or problems, don't beat your head on the desk: .

Step Four: Running the Initial Backup

Once you've sorted out the the rsync command and its arguments, then it's time to run the initial backup. All that you'll need to do is remove the --dry-run argument from the command you ran previously.

Show Me
Logging into your EVBackup account with EVFTP: the ExaVault Secure FTP Java web client

Logging into your EVBackup account with EVFTP: the ExaVault Secure FTP Java web client

We recommend that you run your first full backup from the command line. That way, if something goes awry, you'll be able to catch it right away.

Once the command has completed, you'll want to double-check what was uploaded. To verify, you can use any desktop S/FTP client.

Next Steps

Congratulations! The few minutes you've just spent covers what you need to know to backup your data. Moving on from here: