rsync(1)
rsync is a fast, versatile file synchronization tool that efficiently transfers and synchronizes files between local and remote systems.
Synopsis
rsync [OPTION]... SRC [SRC]... DESTDescription
rsync is a utility for efficiently transferring and synchronizing files across computer networks. It uses a delta-transfer algorithm that only sends differences between source and destination, making it much faster than simple copy commands for large files or many changes. rsync works over SSH for security and can mirror entire directory trees while preserving permissions, ownership, and timestamps.
Common use cases include backups, mirroring, incremental transfers, and maintaining synchronized copies across multiple machines. rsync can operate in local mode (file-to-file on the same system) or remote mode (using SSH or rsync protocol) to transfer data to or from another host.
Common options
| Flag | What it does |
|---|---|
-a, --archive | Archive mode; same as -rlptgoD, preserves permissions, ownership, times, and recursion |
-v, --verbose | Increase verbosity; show files being transferred and summary statistics |
-r, --recursive | Recurse into directories; necessary to sync directory trees |
-e, --rsh=COMMAND | Specify remote shell to use, typically 'ssh' or 'ssh -p 2222' for custom ports |
--delete | Delete files on destination that don't exist on source (dangerous; use with care) |
-z, --compress | Compress file data during transfer; saves bandwidth over slow links |
--progress | Show progress for each file and a summary total progress bar |
-P | Same as --partial --progress; keeps partial files and shows progress |
--exclude=PATTERN | Exclude files matching PATTERN; can be used multiple times |
-u, --update | Skip files on destination that are newer than source files |
--bwlimit=KBPS | Limit bandwidth used in kilobytes per second |
-n, --dry-run | Show what would be transferred without actually doing it |
Examples
Archive and verbosely sync a local directory tree, preserving all attributes
rsync -av /local/path/ /backup/path/Sync local directory to remote host over SSH with compression
rsync -avz -e ssh /local/path/ [email protected]:/remote/path/Sync remote directory to local system over SSH (pull operation)
rsync -avz -e ssh [email protected]:/remote/path/ /local/path/Mirror source to destination, removing files in destination that no longer exist in source
rsync -av --delete /source/ /destination/Sync directory excluding log files and .git directories to remote host
rsync -avz --exclude='*.log' --exclude='.git' /source/ user@host:/backup/Transfer large files with progress display, limiting bandwidth to 1 MB/s
rsync -avP --bwlimit=1000 /large/dataset/ user@remote:/storage/Perform a dry-run to preview what would be synced without making changes
rsync -avn /source/ /destination/Sync and delete extraneous files on destination after transfer completes
rsync -ave ssh --delete-after /source/ user@host:/dest/