rsync, The Synchronization Buddy

by | Jun 7, 2024

A very useful Linux terminal command is ‘rsync’. rsync is a powerful and versatile utility for synchronizing files and directories between two locations, either locally or over a network. It’s commonly used for backups, mirroring, and copying files efficiently.

Local File Synchronization: (This command synchronizes the contents of the
/source/path/ directory to the /destination/path/ directory.)
rsync -av /source/path/ /destination/path/

Remote File Synchronization: (This command synchronizes files from a remote host to a local directory using SSH for secure transmission.)

rsync -avz -e ssh user@remote_host:/remote/source/path/ /local/destination/path/

…and vice versa:

rsync -avz -e ssh /local/source/path/ user@remote_host:/remote/destination/path/

Advanced Usage:

Delete Extraneous Files: (This deletes any files in the destination directory that are not present in the source directory.)

rsync -av –delete /source/path/ /destination/path/

Bandwidth Limitation: (Limits the bandwidth used by rsync to 1000 KB/s.)

rsync -avz –bwlimit=1000 /source/path/ /destination/path/

Dry Run: (Simulates the synchronization process without making any changes. Useful for testing.)

rsync -av –dry-run /source/path/ /destination/path/

Show Progress: (Displays a progress bar indicating the status of the synchronization.)

rsync -av –progress /source/path/ /destination/path/

Uses for rsync:

  • Backup: Create incremental backups of files and directories.
  • File Mirroring: Keep two directories identical, ensuring data consistency.
  • Data Migration: Transfer files and directories between servers or storage devices.
  • Remote Sync: Synchronize files between local and remote systems securely.

rsync is an incredibly versatile and efficient tool for managing file synchronization tasks, making it an essential command-line utility for Linux users.