Rsync new and changed files
To just sync two directories:
$ rsync /source/path/* /dest/path/
Or if you want to do a whole tree:
$ rsync -a /source/path/ /dest/path/
"-a" specifies "archive" mode, where it duplicates the tree as closely as possible.
I like to add the flags v
and P
in there so I can watch it work:
$rsync -avP /source/path/ /dest/path/
"-v" turns on verbose mode, so you can see what it's doing (it lists the files as they copy), and "-P" enables progress, so you can see how long it's taking to copy each file (percentage copied, time remaining, etc), and allows you to see how far through the copy you are.
This is how rsync
works by default (at least on Linux). From the man page:
Rsync finds files that need to be transferred using a "quick check" algorithm (by default) that looks for files that have changed in size or in last-modified time. Any changes in the other preserved attributes (as requested by options) are made on the destination file directly when the quick check indicates that the file's data does not need to be updated.