Backing up snapshots with rsync
Backing up data is something that needs to be done regularly. In addition to local backups, we may need to back up data to or from remote locations. The rsync
command synchronizes files and directories from one location to another while minimizing transfer time. The advantages of rsync
over the cp
command are that rsync
compares modification dates and will only copy the files that are newer, rsync
supports data transfer across remote machines, and rsync
supports compression and encryption.
How to do it...
- To copy a source directory to a destination, use the following command:
$ rsync -av source_path destination_path
Consider this example:
$ rsync -av /home/slynux/data
[email protected]:/home/backups/data
In the preceding command:
-a
stands for archiving-v
(verbose) prints the details or progress on stdout
The preceding command will recursively copy all the files from the source path to the destination path. The source and destination paths can be either...