-v
verbose
-h
humanise the output by implementing binary multipliers instead of byte values etc.
-P
display progress and allow resumption of interrupted transfers
-n
do a dry run for testing
--stats
display statistics on the file transfer (useful to combine with -n
)
-r
recursive to include all sub-directories and their content
--remove-source-files
move files instead of copying
-a
archive mode which preserves permissions, symlinks, etc.
-z
compress the data over transfer, the following file types will not be compressed 7z ace avi bz2 deb gpg gz iso jpeg jpg lz lzma lzo mov mp3 mp4 ogg png rar rpm rzip tbz tgz tlz txz xz z zip
-skip-compress=gz/jpg/mp[34]/7z/bz2
will compress all data over transfer except those file that match these extensions, mp[34]
is short for mp3/mp4
--exclude='/directory' --exclude='file' --exclude='*pattern*'
exclude directory names, filenames or pattern matches
--include='/directory' --include='file' --include='*pattern*'
include directory names, filenames or pattern matches
--max-size='50M'
only copy files less than 50 MB
--bwlimit=50
cap bandwidth usage to 50 KiB
--timeout=60
permit a transfer timeout of 60 seconds before rsync will exit
-u
update mode which skips all files on the destination that are newer than the source
rsync -hvP archive.tar.gz /directory/to/store/copy
rsync -hvrP /directory/to/copy/* /directory/to/store/copy
-e ssh
use a secure shell (SSH) connection
rsync -ahvzPe ssh /directory/to/copy/* [email protected]:/directory/to/store/copy
Or switch to copy a remote directory locally.
rsync -ahvzPe ssh [email protected]:/directory/to/store/copy /directory/to/copy/*
The --includes
and --excludes
arguments must be in the correct order
--include="*/"
includes all subdirectories
--include="*.html" --include="*.css" --include="*.js" --include="*.php"
includes all files matching these file extensions
--exclude="*"
exclude all other files that don't match the previous includes
-m
prunes empty directories from the copy
rsync -avhPrm --include="*/" --include="*.html" --include="*.css" --include="*.js" --include="*.php" --exclude="*" /var/www/* /var/backups/www.src/
-R
use relative path names for --includes
and --excludes
rsync -avhPrR --exclude=".*" --exclude="/downloads" --exclude="/setup" /var/www/* /var/backups/www.src/
Learn more.