Hi all, I'm trying to made a filtered backup of a windows PC. My target is to create a recursive backup of "only" files reported in the include/exclude files (i.e. only *.txt). the rules (reported below) work well, but also create an empty folders structure that I don'want. Rsync works fine for me (the rules are reported below) except a point, rsync create an empty folders structure that I don'want. I'm trying to explain better. Suppose that the source folder is: ./source/a.txt ./source/afolder ./source/afolder/b.txt ./source/afolder/c.doc ./source/bfolder/ ./source/bfolder/a.doc ./source/bfolder/ ./source/bfolder/cfolder/ ./source/bfolder/cfolder/e.doc . I used the following syntax: rsync -avz --delete-excluded ./source/ ./dest --exclude-from=exclude.txt where the rules in the exclude.txt are: + *.txt + */ - * rsync create in the dest folder: ./dest/a.txt ./dest/afolder ./dest/afolder/b.txt ./dest/bfolder/ ./dest/bfolder/cfolder/ Please note if I omit the rules "+ */", I cannot fetch recursively the folders and thus the ./source/afolder/b.txt file. I misleading anything? There is anyway to exclude the creation of the empty folders? My environment is: Win XP Pro SP2 rsync 2.6.4 (from cygwin) Thanks in advantage, Luca
On Tue, Jun 28, 2005 at 02:22:22PM +0200, l.corbo@pronetics.it wrote:> Rsync works fine for me (the rules are reported below) except a point, > rsync create an empty folders structure that I don'want.The only way to get rsync to not create directory hierarchies that don't contain *.txt files is to actually remove the directories from the transfer, either through more targeted directory includes, or by using --files-from (though the latter would not make it easy to delete missing files). So, instead of the "+ */" rule you would need to maintain some include rules, perhaps using something like this perl script: #!/usr/bin/perl use strict; my $dir = shift; chdir($dir) or die "Unable to chdir to $dir: $!\n"; print "+ *.txt\n"; my %hash; open(IN, 'find . -name "*.txt" |') or die "Failed to run find: $!\n"; while (<IN>) { chomp; s#^\./##; next unless s#/[^/]*\.txt$##; my $path = ''; foreach (split(/\//)) { $path .= $_ . '/'; next if $hash{$path}; $hash{$path} = 1; print "+ $path\n"; } } print "- *\n"; And use it like this: new-script ./source | rsync -avz --delete-excluded --exclude-from=- ./source/ ./dest ..wayne..