Bashrsync Command - Remote (and local) File-copying
Using thersync Command
Thersync 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, usersync -avz source user@hostname:/path:
Example
rsync -avz /local/dir/ user@example.com:/remote/dir/Understanding Rsync Output
The output of thersync 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 thersync 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/ user@example.com:/remote/dir/Option: -v (Verbose)
The-v option increases verbosity, providing detailed output of the rsync process.
Example: Verbose Output
rsync -av /local/dir/ user@example.com:/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/ user@example.com:/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/ user@example.com:/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/ user@example.com:/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/ user@example.com:/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/ user@example.com:/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.

