Rsync new and changed files
Is it possible to have rsync
transfer all files in a directory that have changed or have been created? I don't need something as sophisticated as a CRC diff check; files with different timestamps and/or file sizes count as changes.
I get the impression from the man page that it should be possible, but I need a little guidance on what set of parameters to pass rsync
.
Solution 1:
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.
Solution 2:
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.