How to change permissions on a directory without meaning to... -
include/exclude semantics
Tim Small
tim at semantico.com
Tue Oct 7 02:41:45 EST 2003
Hi,
Think I've found either a documentation bug, in rsync (or possibly a
code bug), with the include/exclude feature. This occurs on (at least)
2.5.5 and 2.5.6
First I created a file list of files that I wanted backed up
[root at poppy root]# cat /tmp/sendmail-rpmverify-out
/etc/
/etc/aliases
/etc/mail/
/etc/mail/helpfile
/etc/mail/local-host-names
/etc/mail/sendmail.mc
/etc/mail/statistics
/etc/mail/trusted-users
/etc/mail/virtusertable
/etc/sendmail.cf
/etc/sysconfig/sendmail
2. Then I fed this file to rsync as the files that it should copy from
one path to another:
# rsync -av --include-from /tmp/sendmail-rpmverify-out --exclude '*' / /tmp/
3. Check file permissions on /tmp
[root at poppy root]# ls -ald /tmp/
drwxr-xr-x 36 root root 4096 Oct 3 05:44 /tmp/
So, the --exclude '*' doesn't actually exclude '/' from the list, so
the file permissions on / are copied over to /tmp
No files under /tmp, except those specified in the file touched tho'.
From the rsync manual page:
"rsync builds an ordered list of include/exclude options as specified on
the command line. When a filename is encountered, rsync checks the name
against each exclude/include pattern in turn. The first matching
pattern is acted on. If it is an exclude pattern, then that file
is skipped. If it is an include pattern then that filename is not
skipped. If no matching include/exclude pattern is found then the
filename is not skipped."
I thought maybe I wasn't telling it explicitly enough not to include '/'
in its list, so I tried this:
rsync -av --include-from /tmp/sendmail-rpmverify-out --exclude '**'
/ /tmp/
and this:
rsync -av --include-from /tmp/sendmail-rpmverify-out --exclude '/**'
/ /tmp/
and even this:
rsync -av --include-from /tmp/sendmail-rpmverify-out --exclude '/**'
--exclude / / /tmp/
but it still does the same thing, and updates the permissions on /tmp -
thus it seems that the source path specified to rsync (in this case '/')
is always implicitly included, even though this isn't documented in the
man page. If this is a feature, then I think it would be helpful to
state it in the "include/exclude" part of the manual page..
Unfortunately, before I worked out what had happened, the mod-perl web
server on this machine had got the load up to 40, and partially stopped
working, as it was unable to create a temporary socket in /tmp/ :o(
Comments/thoughts?
Cheers,
Tim.
More information about the rsync
mailing list