Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING BASH

Bash rsync - A fast, versatile, remote (and local) file-copying tool

Using the rsync Command

The rsync command is used to efficiently transfer and synchronize files across computer systems, by checking the timestamp and size of files.


Basic Usage

To synchronize a directory to a remote host, use rsync -avz source user@hostname:/path:

Example

rsync -avz /local/dir/ [email protected]:/remote/dir/

Understanding Rsync Output

The output of the rsync command can vary depending on the options used. Here are some common elements:

  • File List: Lists the files being transferred.
  • Transfer Progress: Shows the progress of each file transfer.
  • Compression Ratio: Indicates the effectiveness of compression if used.
  • Speed: The speed at which files are being transferred.

Rsync Options Overview

Here are some common options you can use with the rsync command:

  • -a - Archive mode
  • -v - Increase verbosity
  • -z - Compress file data
  • --delete - Delete extraneous files
  • -r - Recurse into directories
  • -u - Skip files that are newer on the receiver
  • --progress - Show progress during transfer

Option: -a (Archive Mode)

The -a option enables archive mode, which preserves permissions, times, symbolic links, and more. It's like a combination of several options.

Example: Archive Mode

rsync -a /local/dir/ [email protected]:/remote/dir/

Option: -v (Verbose)

The -v option increases verbosity, providing detailed output of the rsync process.

Example: Verbose Output

rsync -av /local/dir/ [email protected]:/remote/dir/

Option: -z (Compression)

The -z option compresses file data during transfer, which can speed up the transfer process.

Example: Enable Compression

rsync -az /local/dir/ [email protected]:/remote/dir/

Option: --delete

The --delete option deletes files from the destination that are not present in the source.

Example: Delete Extraneous Files

rsync -avz --delete /local/dir/ [email protected]:/remote/dir/

Option: -r (Recursive)

The -r option allows rsync to recurse into directories, copying all files and subdirectories.

Example: Recursive Copy

rsync -ar /local/dir/ [email protected]:/remote/dir/

Option: -u (Update)

The -u option skips files that are newer on the receiver, avoiding overwriting newer files.

Example: Skip Newer Files

rsync -avu /local/dir/ [email protected]:/remote/dir/

Option: --progress

The --progress option shows progress during transfer, providing detailed information about the transfer status.

Example: Show Progress

rsync --progress /local/dir/ [email protected]:/remote/dir/

Troubleshooting Common Issues

Common issues with rsync include "Permission Denied" or "Connection Timeout". Here are some troubleshooting tips:

  • Permission Denied: Ensure you have the correct permissions on both the source and destination directories. Check user permissions and SSH key access.
  • Connection Timeout: Verify network connectivity and ensure the remote server is reachable. Check firewall settings and SSH configurations.



×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.