Few things are more important to a dedicated server than incremental backups. When your server is your livelihood and your reputation depends on it being reliable, you need to be prepared for possible disasters. Backups ensure that you always have a plan B, should something go wrong with your server.

To perform backups, you could setup a script that copies all data, compresses it, and then saves it to a backup server. You could even automate this using a cron job. But that would require you to overwrite all of the files every time you perform a backup or make a pretty complicated script to only overwrite old files.

Rsync makes all of that easy with only one command. Rsync is a Linux and Unix tool that can sync local or remote directories and only recopy those files which have been modified. These incremental backups save bandwidth and time. Rather than having each backup take hours and use valuable CPU power, it may only take a few minutes after the initial backup.

For a simple sync of two directories, run rsync like this:

rsync -avz ~/public_html /serverfiles/backup

If you want to backup to a remote server, you can enter the hostname and server right in the rsync command string. Run the command like this:

rsync -avz ~/public_html[email protected]:/home/user/backupfiles/

The “-a” flag will create an archive, and the “-z” flag will compress the files. “-v” makes the process verbose, showing you the output. You can remove the “v” if your prefer not to see what it is doing. Rsync will use secure shell (SSH) to make the file transfers and will require a password. If you want it automated, without needing a password, create an SSH key and then place it in a cron job.