Backup snapshots with rsync
Backing up data is something that most sysadmins need to do regularly. In addition to backing up local files, we may need to backup data from a web server or from remote locations. rsync
is a command that can be used to synchronize files and directories from one location to another while minimizing data transfer using file difference calculations and compression. The advantage of rsync
over the cp
command is that rsync
uses strong difference algorithms. Additionally, it supports data transfer across remote machines. While making copies, it compares the files in the original and destination locations and will only copy the files that are newer. It also supports compression, encryption, and a lot more. Let us see how to work with rsync
.
How to do it...
Let's see how to copy files and create backups with rsync
:
To copy a source directory to a destination use:
$ rsync -av source_path destination_path For example, $ rsync -av /home/slynux/data [email protected]:/home...