Checksum verification in RSYNC is used to ensure the integrity and consistency of data transferred between locations. Unlike simple copying methods, RSYNC facilitates checksum verification, allowing users to detect any data corruption during transmission and retransmit affected parts.
To perform checksum verification with RSYNC, you can use the “-c” or “—checksum” option in your RSYNC command. This option forces RSYNC to run a checksum-based algorithm while transferring files. Here is an example:
```
rsync -chavzP source_directory/ destination_directory/
```
Here, each parameter in the command carries a specific function:
- c: Runs the checksum-based algorithm
- h: Shows output in a human-readable format
- a: Applies archive mode, which preserves symbolic links, file permissions, user & group ownerships, and timestamps
- v: Enables verbose output, showing details of the ongoing operations
- z: Compresses the data during the process of transmission
- P: Combines ‘progress’ and ‘partial’, showing the progress during transfer and keeping partially transferred files
RSYNC uses the MD5 checksum algorithm for its data integrity verification. When the “-c” option is used, RSYNC calculates the checksum of the source and destination files. If the values match, it skips the file, otherwise, it transfers the data.
Even though using checksum provides a higher level of data integrity, it comes with a trade-off. The computation of checksums for large files or directories can be CPU-intensive and time-consuming, thus, slowing down the entire synchronization process.
To avoid this, be strategic with the “-c” option. It’s often wise to use it when you suspect that your files have been manipulated or corrupted but may not be necessary for each sync operation.
Here’s an example where checksum can be useful. Suppose you have a directory full of images, and you suspect that some images have been compressed or edited without modifying the timestamps or filenames. Using RSYNC with the checksum option will help you identify and re-sync these modified files.
```
rsync -chavzP /path/to/images/ /backup/location/
```
This method might be slower, but it will spot even minor alterations, unlike a simple timestamp comparison, ensuring that both source and destination locations match perfectly.
Sources used:
1. RSYNC man page: www.samba.org/ftp/rsync/rsync.html
2. Linux Academy: www.linuxacademy.com/blog/linux/rsync-and-why-its-awesome/
3. TecMint: www.tecmint.com/sync-files-using-rsync-with-non-standard-ssh-port/