problem with --delete if I sync part of a dir

Dave Dykstra dwd at
Wed Jan 16 02:35:48 EST 2002

On Tue, Jan 15, 2002 at 10:01:59AM +0100, Palmans Pepijn wrote:
> Hi,
> I'm using rsync for a couple of things but I am at a point where I could
> not find a solution for my problem.
> this is what I want to do:
> rsync only the files i_* from a directory from machine A to machine Bi
> and delete them from machine B if they on longer exist on machine A.
> so I use the command:
> rsync -azv --stats -e ssh --delete i_* user at host:/dir/
> When using this command the files starting with i_ will get placed on the
> remote server or even updated when I change them but if I delete a file on
> machine A it will not be deleted on machine B.
> This is only a problem if I use i_* as my source.  If i sync whole
> directories (recursive or not) it's no problem at all to get files deleted
> on the other end.

That is expected behavior.  Rsync would have no way of knowing that it
should delete just the missing i_* files or all files in the remote

> Is there anything to do about this ?

Not if you have any other files that don't start with i_* in the remote
directory that you want to keep.  If you don't you could use
    rsync -azv --stats -e ssh \
	--include 'i_*' --exclude '*' --delete-excluded . user at host:/dir/
but that will delete all files except the i_* files in host:/dir/.

- Dave Dykstra

More information about the rsync mailing list