rsync recursion question

Dave Dykstra dwd at
Thu Oct 25 02:50:49 EST 2001

On Tue, Oct 23, 2001 at 09:08:25PM -0500, Justin Banks wrote:
> >>>>> "Tim" == tim conway <tim.conway at> writes:
>   Tim> That's the way it is.  If it's really a one-off change, a huge change
>   Tim> in your structure, telnet ssh, rsh, and so forth, work really well for
>   Tim> dropping in and deleting stuff (unless you're supplying the master, and
>   Tim> other systems out of your control copy from you).  Rsync is opTimized
>   Tim> for taking a filesystem in an unknown state, and making it identical to
>   Tim> another filesystem in an unknown state, using network bandwidth as
>   Tim> efficiently as possible.
> Well, that doesn't cut it here. It seemed like all the guts were there - I
> mean, the functionality already exists on the receiving side, mostly, right?
> Anyway, I took a look, and I added an option (-d). This means that you can do
> rsync --delete -d /some/removed/directory foo at wherever::module:/some/removed
> and the remote side will remove /some/removed/directory. It will work whether
> it's a file or directory. Let me know if anyone wants a patch, if this is a
> feature that would help other folks. I can't imagine people are in my
> particular circumstances, where the source filesystem is on the order of a
> terabyte, but you never know ;)

This rang a bell.  Back in December 1998 while I was official maintainer
of rsync, Phil Dietz submitted a patch to remotely make directories on 
rsync --daemons and discussed one to remotely delete directories.  I was
opposed to the former, and came up with a way to do the latter without a
patch.  Unfortunately the messages were not on the mailing list so I can't
refer them to you.

The way to recursively delete a single directory while ignoring the rest is:

    mkdir /tmp/empty
    rsync -a --delete --include "/directorytodelete**" --exclude "*" \
	/tmp/empty/ foo at wherever::module

- Dave Dykstra

More information about the rsync mailing list