GNU Rsync Cheatsheet #
GNU rsync is a utility for efficiently transferring and synchronizing files between a computer and a remote server or between two computers.
Basic Commands #
Command/Option | Example | Description |
---|---|---|
rsync -av | rsync -av source/ destination/ | Archive mode with verbose output (-a for archive, -v for verbose) |
rsync -z | rsync -z source/ destination/ | Compress file data during the transfer (-z for compression) |
rsync -r | rsync -r source/ destination/ | Recursively transfer directories (-r for recursive) |
rsync -e | rsync -e ssh source/ user@remote:/path/ | Specify the remote shell to use (-e for remote shell) |
rsync -u | rsync -u source/ destination/ | Skip files that are newer on the destination (-u for update) |
rsync -n | rsync -n source/ destination/ | Perform a dry run (no changes are made) (-n for dry run) |
rsync --delete | rsync --delete source/ destination/ | Delete extraneous files from the destination (--delete option) |
rsync -P | rsync -P source/ destination/ | Show progress during transfer and handle partial transfers (-P for progress and partial) |
Advanced Options #
Command/Option | Example | Description |
---|---|---|
rsync --exclude | rsync --exclude='*.tmp' -av source/ destination/ | Exclude files matching a pattern from being transferred (--exclude option) |
rsync --include | rsync --include='*.jpg' --exclude='*' -av source/ destination/ | Include only files matching a pattern (--include option) |
rsync --partial | rsync --partial source/ destination/ | Keep partially transferred files (--partial option) |
rsync --bwlimit | rsync --bwlimit=1000 -av source/ destination/ | Limit bandwidth used during the transfer (--bwlimit option) |
rsync --chown | rsync --chown=user:group source/ destination/ | Change ownership of transferred files (--chown option) |
rsync --checksum | rsync --checksum -av source/ destination/ | Use file checksums to determine changes (--checksum option) |
rsync --log-file | rsync --log-file=rsync.log -av source/ destination/ | Log transfer details to a file (--log-file option) |
This cheatsheet covers the essential GNU rsync commands and options for file synchronization and transfer.