27

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.

1
  • This question does not match the title, can anyone re-title it? Dec 28, 2020 at 22:01

2 Answers 2

29

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.

5
  • 4
    ...and perhaps add the z flag to use compression for the transfer
    – Linker3000
    Mar 7, 2011 at 21:47
  • 4
    ...if you're transferring to a remote location
    – Majenko
    Mar 7, 2011 at 21:50
  • I guess we should use -u or --update option to sync the changed files. Dec 4, 2020 at 2:03
  • What does 'duplicates the tree' mean?
    – Scorb
    Mar 30, 2021 at 2:11
  • --delete to make the destination match the source.
    – majorgear
    Oct 9, 2023 at 3:41
17

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.

1
  • Ah, I had confused myself by misreading the documentation. Thanks :) Mar 7, 2011 at 21:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .