--delete and explicitly listed files

Wayne Davison wayned at samba.org
Thu Sep 30 09:18:20 GMT 2004


On Wed, Sep 29, 2004 at 08:07:28PM -0400, Igor A. Nesterov wrote:
> building file list ... link_stat /tmp/dira/file1 : No such file or directory

This is because rsync is a copy command, and you told it to copy a file
that doesn't exist.  Rsync does not currently have a way to specify
individual files to delete, but you can easily do a remote delete using
ssh and normal shell commands:

    ssh remote 'cd /dest; xargs rm' <list-of-deletions

So, you're best off if you keep two lists of files -- a list of
changed/added files, and a list of deleted files -- but it's easy
to filter a single list, like this example perl script does:

#!/usr/bin/perl
$HOST = 'remote';
open(SEND, "| rsync -a --files-from=- / $HOST:/");
open(DEL, "| ssh $HOST xargs rm");
while (<>) {
    chomp;
    if (-e $_) {
	print SEND $_, "\n";
    } else {
	print DEL $_, "\n";
    }
}
close DEL;
close SEND;

..wayne..


More information about the rsync mailing list