So, I have a seemingly simple issue, but so far I haven't found a solution: I want to exclude the topmost directory from an rsync, while still syncing all its children. The particular issue is that I don't have permission to modify the times of the topmost directory, but want all the children to have properly sync'd times.The rsync command I'm using is as follows:rsync --exclude ./ -rlptDu ./ server.example.com:/usr/local/directory/and server.example.com:/usr/local/directory/ looks like this:drwxrws---  5 root   staff 24576 Jul  9 15:00 .(my local user is a member of staff)When I run rsync, I get the following error:rsync: failed to set times on /usr/local/directory/.: Operation not permitted (1)rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1070) [sender=3.0.9]make: *** [pub_to_mel_internal] Error 23This is version 3.0.9 on the local machine and 3.0.7 on the remote, both machines running Debian.
rsync: how to exclude the topmost directory
rsync
I think rsync's filter rules can't match the toplevel directory, so it's always synchronized. A workaround is to synchronize all the files inside this directory instead of the directory itself.rsync -rlptDu -- * server.example.com:/usr/local/directory/Add .[!.]* after * if you have dot files in the topmost directory, and ..?* if you have file names beginning with two dots.