...
rsync
is a powerful tool with many useful options. Here’s a quick list of examples:
-a
: Archive mode, preserving symbolic links, devices, attributes, permissions, and ownership.Code Block rsync -a /path/to/source/ /path/to/destination/
-v
: Verbose mode, providing detailed information during the transfer.Code Block rsync -v /path/to/source/ /path/to/destination/
-r
: Recursively syncs folders.Code Block rsync -r /path/to/source/ /path/to/destination/
-nv
: Performs a verbose dry run, showing what the command would do without actually making any changes.Code Block rsync -nv /path/to/source/ /path/to/destination/
-z
: Compresses the data during transfer to save bandwidth.Code Block rsync -az /path/to/source/ /path/to/destination/
-P
: Combines--partial
and--progress
, keeping partially transferred files and showing progress during transfer.Code Block rsync -P /path/to/source/ /path/to/destination/
--delete
: Deletes files in the destination that are not present in the source, ensuring the destination is an exact mirror of the source.Code Block rsync -av --delete /path/to/source/ /path/to/destination/
-t
: Preserves modification times of files.Code Block rsync -t /path/to/source/ /path/to/destination/
--exclude
: Excludes files matching specified patterns from the transfer.Code Block rsync -av --exclude='*.tmp' /path/to/source/ /path/to/destination/
--include
: Overrides exclusions for specific patterns.Code Block rsync -av --exclude='*.tmp' --include='important.tmp' /path/to/source/ /path/to/destination/