Backing up your information is very important to you, or at least it should be. One of my college professors once told me, “It is not a question of if your hard drive will crash; it is when your hard drive will crash.”
Rsync is a tool that allows you to keep two distinct directories in sync, either locally (two locations on the same machine, including attached devices) or remotely (local computer to server or even server to backup server). It is free and open source software and runs on Linux and most other Unix-like operating systems, including FreeBSD and Mac OS X.
Furthermore, those who prefer not to get their fingers dirty on the command line can use Grsync, a graphical frontend for rsync, available in most Linux distribution repositories.
Whether you are using the command line or a graphical program, location is key. You need to know the absolute paths to both locations you will be syncing. For example, if you are backing up a photo directory in your home folder, located in Pictures/2010/StateFair, you need to have the whole path, /home/username/Pictures/2010/StateFair.
For remote locations, the format is email@example.com:/path/to/directory
Rsync relies on SSH for remote backups, so the username you specify will need to be your SSH login identity for the remote computer or server. If you are syncing two local computers on your network, you may need to install OpenSSH server.
To perform a local backup to an attached drive or alternate location, specify the default location first, followed by the backup location.
rsync -avz /home/username/Pictures/2010/StateFair /media/disk/backup
The “-a” flag will tell rsync to archive the backup. The “-z” flag will tell rsync to compress the archive. The “-v” flag is “verbose” and will give you information about the backup.
To backup a website to a backup server or local machine, login to the server via SSH. Then, from the command line, run rsync:
rsync -avz /home/username/www/public_html username@backup-server:/home/user/backup
It will prompt you for a password, which will be the one you use for SSH.
Rsync will perform incremental backups by default. This means that it will not recopy all of the files every single time a backup is performed. Instead, only the files that have been newly created or modified since the last backup will be copied. This will save time and network bandwidth, something which is very important if you are running a website or dedicated server.
If you want your backups to be automated and periodic, you can setup a cron job to run rsync at the times you specify. On a server, you might just create a basic shell script that runs rsync and drop the script into /etc/cron.daily or /etc/cron.weekly, depending on how often you want to perform backups.
For a desktop or mobile computer, Grsync is a great tool you can use to simplify the rsync process and also save your sessions for future periodic use. Setup the source and destination exactly as you would with rsync.
Ubuntu user can install it via the Ubuntu Software Center, or simply click here to install.
The first box will be the source, and the second will be the destination. There are also numerous options, but unless you have something specific you need to configure, you can leave the default options and just press “Execute”.
Grsync will allow you to create multiple sessions so that you can backup a number of locations and keep the sessions on hand for future use. To add a new session, just click the “Add” button and give it a name. Grsync is free software and is available for Linux, Unix, Windows, and Mac OS X.
Finally, it should be noted that rsync is a great tool for backing up data, but nothing is perfect all the time. You should regularly check your backups to make sure they are successful and accurate. If all goes well, you will be able to backup your files quickly and easily.