Rsync Command to transfer file Syncing in Linux

rsync (Remote Sync): rsync is a powerful tool for copying and syncing files. It efficiently transfers only the modified parts of files, supports incremental updates, and can resume interrupted transfers, making it ideal for backups and keeping files up to date.

rsync Command Syntax
The basic syntax of the rsync command is:

rsync [options] source destination

source: The path to the files or directories you want to copy.
destination: The path where you want the files or directories to be copied to.

Common rsync Options
1. -a (Archive Mode), Preserves the file permissions, timestamps, symbolic links, and other attributes while copying.
Rsync command example:

rsync -a source/ destination/

2. -v (Verbose), Provides detailed output about the transfer process.

rsync -av source/ destination/

3. -z (Compress), Compresses file data during the transfer to reduce bandwidth usage.

rsync -az source/ destination/
or,
rsync -az source/ user@remote:/destination/

4. -r (Recursive), Recursively copies directories and their contents.

rsync -r source/ destination/

5. -u (Update), Only copies files that are newer in the source than in the destination.
rsync -au source/ destination/

6. –delete : Deletes files in the destination directory that are no longer present in the source directory.

rsync -a --delete source/ destination/

7. -e (Remote Shell): Specifies the remote shell program to use (e.g., SSH).
rsync -av -e ssh source/ user@remote:/destination/

8. --progress: Shows progress during the transfer.
rsync -av --progress source/ destination/

9. --exclude : Excludes specified files or directories from being copied.

10. –include : used to specify files or directories that you want to include in the sync operation, even if you are using the --exclude option to ignore other files.

rsync -av --include='.txt' --exclude='' source/ destination/

Thank you for reading through this guide on rsync commands. I hope this detailed explanation helps you understand how to use rsync effectively for your file syncing needs. If you have any questions or need further clarification, feel free to comment. We are here to help!

Leave a Reply

Your email address will not be published. Required fields are marked *