1

I am using rsync to take a backup. This is my command line:

sudo rsync -avuh --delete --stats --log-file=$LOGFILE --exclude-from $EXCLUDE $SOURCE $DEST

This works for the most part. However, today, I came across a scenario where I just changed the attributes of a file to make it executable. Out of curiosity I ran rsync but it didn't show that file as being copied over to the destination.

The file contents are exactly the same and this is the stat output:

  File: `Projects/simpleFlash.py'
  Size: 706             Blocks: 8          IO Block: 4096   regular file
Device: 802h/2050d      Inode: 56961       Links: 1
Access: (0755/-rwxr-xr-x)  Uid: ( 1000/      pi)   Gid: ( 1000/      pi)
Access: 2015-03-26 17:13:29.970428613 -0400
Modify: 2015-02-17 00:16:44.558033934 -0500
Change: 2015-05-19 13:53:28.401164123 -0400
 Birth: -

The mtimes are the same but ctime is different. How do I make rsync look at the file attribute changes, for files with the same mtime?

specs:
rsync 3.0.9
FS: ext4
linux kernel: 3.18.11+
0

As stated in the rsync(1) 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.

This means as long as you tell rsync to transfer the attributes, they'll be updated. You said the missing attribute was permissions, so add -p or --perms to the command line and you're good to go.

  • Thank you. This does indeed work. I was using archive mode above ('a' option) which does this by default. The reason I was confused was that a file which only changes permission doesn't appear in the output of rsync as transferred/modified. Hence I was thinking that its not changing the permissions, but indeed it is. – Sujay Phadke May 23 '15 at 5:10

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.