Backing up with rsync

In previous installments, we covered backing up your MySQL and SQL Server databases. This is a great first step toward a full backup solution. As a result, if the application corrupts the database, there is a local backup available to restore to get work going again.

To further ensure the safety of the backups taken, it is always good practice to keep a separate copy on another computer so that if the database server becomes unrecoverable, a separate copy of the data is kept to ensure a new server can be brought up in replacement.

A tremendous free tool to perform these copies is rsync. It is typically pre-installed on any Linux environment; if not, it is a quick package to install. On Windows, it can be installed via Cygwin and behaves the same as its Linux counterpart.

At the very basic level, rsync can be used to copy a set of files and folders with the same user and group IDs as the source system. This can be used for more than database backups; for example, it can be used to copy web site files in addition to database backup files.

The most common use of the rsync copy is as follows:

rsync -av --delete /path/to/folder user@remotehost:/path/to/storage

This will copy everything recursively under /path/to/folder to the remote system remotehost (authenticating with the user user) at path /path/to/storage. The files will be in the exact same structure under /path/to/storage.

If the command is run periodically, any files removed on the local system since the command was last run will be removed on the remote server by use of the --delete flag. Changed files are copied as differentials, which can greatly reduce the amount of data transferred and the overall copy time. This can be greatly beneficial for offsite backups.

There are many backup options available for servers, but some of the simplest are the best and cheapest. Remember when selecting a backup configuration to always ensure that the configuration meets the business requirements and to periodically check the configuration once running to ensure the backups are still valid.

Want to Learn More?

This is just a sample of what we can do. We have 15 years of experience working in nearly every technology and industry. Whatever you are doing, we've done it and are prepared to tackle your project. Reach out and we will discuss it with you.