Rsync
What is rsync?
- Incremental transfers: Only transfers the differences between source and destination files, saving time and bandwidth.
- Supports local and remote synchronization: Can copy files within the same system or over SSH/remote connections.
- Preserves file attributes: Can keep permissions, timestamps, symbolic links, and ownership intact.
- Efficient: Uses compression (
-z) and delta-transfer algorithm to reduce data sent over the network. - Versatile: Can be used for backups, migrations, or mirroring websites and directories.
How to Use rsync
1. Basic Local Copy
-a= archive mode (preserves permissions, timestamps, symbolic links, etc.)-v= verbose (shows what’s being transferred)- Trailing slashes matter:
/source/means “contents of the source directory.”
2. Remote Copy (via SSH)
- Copies local directory to a remote server via SSH.
3. Remote Copy from Server to Local
4. Compress Data During Transfer
-zenables compression for faster network transfers.
5. Show Progress
- Displays transfer progress and speed.
6. Delete Extra Files in Destination
- Deletes files in the destination that no longer exist in the source.
7. Exclude Certain Files
- Skips all
.tmpfiles during transfer.
Installation (Linux Examples)
```