Hello, I used the command "/usr/bin/rsync -avx --delete --numeric-ids /www/ /backup/daily.0/www/" and got the following output: building file list ... done ./ bla/ bla/lib/ bla/lib/cpp bla/lib/ld-2.3.2.so bla/lib/ld-linux.so.2 . . . Due to the -x option, rsync shouldn't touch my lib subdirectory. Here is the output of "mount": /dev/hda3 on / type reiserfs (rw,noatime) none on /dev type devfs (rw) none on /proc type proc (rw) none on /sys type sysfs (rw) none on /dev/pts type devpts (rw,gid=5,mode=620) none on /dev/shm type tmpfs (rw) /bin on /www/bla/bin type none (ro,bind) /etc on /www/bla/etc type none (ro,bind) /dev on /www/bla/dev type none (ro,bind) /lib on /www/bla/lib type none (ro,bind) /usr on /www/bla/usr type none (ro,bind) I use Gentoo Linux with rsync-2.6.2-r3 .
Since the bla/lib dir is on the same partition as bla, there is no way for the current rsync algorithm to notice any difference (the stat() call shows no change because the files dirs are actually on the same filesystem). It might be possible to do something like transform a mount list into an exclude list, but only if it could be done portably (e.g. by using getfsent(), getmntent(), or whatever is available). In the meantime I've changed this bug to an enhancement request. Your best bet for a quick fix is to use some explicit excludes. One way is to use a perl script to automatically create an exclude list from the /proc/mounts file, like this one (name this "mntexcl"): #!/usr/bin/perl -w use strict; my $start_dir = shift; $start_dir =~ s#^([^/])#$ENV{'PWD'}/$1#; my($prefix, $suffix) = $start_dir =~ m#^(.*/)([^/]*)$#; open(IN, '/proc/mounts') or die $!; while (<IN>) { $_ = (split)[1]; next unless s#^\Q$prefix\E##o && $_ ne ''; next if $suffix ne '' && !m#^\Q$suffix\E/#o; print "/$_\n"; } close IN; You could feed this into rsync like this (specifying the starting directory to mntexcl so that it can properly trim the excludes): mntexcl /www/ | rsync --exclude-from=- ... /www/ /backup/daily.0/www/
Created attachment 542 [details] Improved mntexcl perl script A few minor improvements to the in-line script mentioned in comment #1. This script expects /proc/mounts to exist, but could be easily adapted to read /etc/mtab or similar.
I don't see this being done automatically in rsync. There is now a script named mnt-excl in the support dir that is an updated version of the script that is attached to this bug report.