1

My program copies/synchronizes several directories from source to target, each using rsync. For each directory, if the version in target is not identical to source, and thus rsync modifies the target, I would like to notify the user with a message like "directory X has been synchronized to target". On the other hand, if target version is already identical to target, I can skip showing this message since there is no change in target.

Exit status and -n option do not differentiate between the two condition. Aside from parsing the output of -v, is there any other way for me to get rsync to provide this information?

1 Answer 1

3

This may do the job:

rsync --log-format=%f ...

Note that rsync outputs files anytime any attribute changes, not only if the content of the file is updated.

There is also a -i option (or --log-format=%i) that itemizes all of the changes. See the rsync man page for details of the output format.

1
  • Thanks. I'll try --log-format=SomeUniqueString which makes the rsync output easily grep-able to detect modified/added files. For files deleted in target, I'll still have to parse /^deleting /m pattern. Aug 31, 2013 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.