Rsync Backup on Ubuntu Server

I work on some servers at my University. Recently our RAID server went out, which means that we could potentially lose all student and professor data across several of our servers. I was tasked with getting some sort of backup going from our main servers to a local backup server.

After thinking about how to approach the problem, Dr. Awesome (Terry Griffin) and I decided that Rsync would be a good way to go, at least until we could get another RAID server.

The Command

Here is the command that I used:

sudo rsync -arv -e "ssh" --rsync-path="sudo rsync" user@host:/home /backup

The Command Explained

Note that I am using sudo on both the local server and remote server. You will need to be in the sudoers file on both machines to use this command. Sudo let’s you run a command as the super user, which essentially means you are awesome and can do anything.

Next, we have rsync with some options. The rysync command is what is used when you want to do a remote sync. Then the options are explained as follows:

  • a = Archive – This creates a tar of the directory that you want to backup, which allows you to keep permissions, times, etc. in sync.
  • r = Recursive – This option will allow the rsync to copy throughout the target directory.
  • v = Verbose – This option will print give you updates on the screen as the rsync command runs.

Other Notes

You can be more specific about what is copied by deciding to put a “/” at the end of a directory or not.

For example, if you a “/” at the end of the source directory, then rsync will copy the content of that folder. If you don’t put a “/” at the end of the source directory, rsync will copy the source directory and its contents.

If you put a “/” at the end of the destination directory, rsync will paste the contents into that directory. When you don’t use “/”, rsync will create a directory and paste the contents within that directory.

Leave a Reply