On Mon, Jan 30, 2006 at 07:42:20PM +0100, Kilian Krause
wrote:> To be more clearly, I want the rsync --files-from option to behave like
> "take these files out of $TARGET and *ONLY* these files", i.e.
deleting
> *EVERYTHING* there is except the files given in the index file added to
> --files-from.
That's not how deletions or --files-from works. The --delete option
only affects dirs that it has sent by rsync in whole. The --files-from
option allows for the copying of scattered files without affecting the
destination files outside of those listed.
What you want to do instead is to use an include/exclude file so that
rsync can send an entire hierarchy of directories, not individual files.
For instance, instead of this files-from file:
foo/bar/baz
foo/extra
bar/another
You could write something like this:
+ /foo/
+ /foo/bar/
+ /foo/bar/baz
+ /foo/extra
+ /bar/
+ /bar/another
- /foo/*
- /foo/bar/*
- /bar/*
- /*
And use that as an --exclude-from file while copying a single starting
dir. It's a more involved syntax, but it wouldn't be hard to write a
perl script that could take a list of files and turn it into a set of
include/exclude directives. In fact, I've attached one to this email.
..wayne..
-------------- next part --------------
#!/usr/bin/perl
use strict;
my %hash;
while (<>) {
chomp;
s#^/+##;
my $path = '/';
while (m#([^/]+/)/*#g) {
$path .= $1;
print "+ $path\n" unless $hash{$path}++;
}
if (m#([^/]+)$#) {
print "+ $path$1\n";
} else {
delete $hash{$path};
}
}
foreach (sort keys %hash) {
print "- $_*\n";
}
print "- /*\n";