rsync recursion question

Dave Dykstra dwd at bell-labs.com
Thu Oct 25 04:25:06 EST 2001


On Wed, Oct 24, 2001 at 12:42:29PM -0500, Justin Banks wrote:
> >>>>> "Dave" == Dave Dykstra <dwd at bell-labs.com> writes:
>   Dave> The way to recursively delete a single directory while ignoring the
>   Dave> rest is:
> 
>   Dave>     mkdir /tmp/empty rsync -a --delete --include "/directorytodelete**" 
>   Dave>      --exclude "*" \ /tmp/empty/  Dave> foo at wherever::module
> 
> This works, if there's nothing else on the receiving side that you want to
> keep (unless I'm doing it wrong). In other words, if the sending side looks
> like this :
> 
> [root at r1c3n104 foo]# ls -l /tmp/foo
> total 4
> drwxr-xr-x    2 root     root         4096 Oct 24 12:32 bleen
> -rw-r--r--    1 root     root            0 Oct 23 15:27 fred
> 
> and the remote side looks like this :
> 
> [root at r1c1n130 /tmp]# ls -l /tmp/foo
> total 8
> drwxr-xr-x    2 root     root         4096 Oct 24 12:34 bleen
> drwxr-xr-x    2 root     root         4096 Oct 24 11:52 bob
> -rw-r--r--    1 root     root            0 Oct 24 12:31 fred
> 
> 
> and I want to remove /tmp/foo/bob on the remote side without walking the
> entire /tmp/foo/bleen directory, which may contain several hundred gigabytes,
> I can follow your suggestion, as follows :
> 
> [root at r1c3n104 foo]# rsync -a --delete --include "/tmp/foo/bob**" -exclude "*"
> /tmp/empty/ user at 10.55.11.130::module/tmp/foo/
> 
> but then the remote side ends up like this :
> 
> [root at r1c1n130 /tmp]# ls -l /tmp/foo
> total 0
> 
> ;(


The filename paths that the exclude algorithm sees are relative to the
destination path, they do not include it.  It should work if you use
--include "/bob**".  The slash at the beginning does not indicate the
root of a filesystem, it indicates "match only the beginning of a path".






> What I want to be able to do is have the initial picture as above, and run
> something like this (/tmp/foo/bob doesn't exist on the sending side) :
> 
> [root at r1c3n104 foo]# /tmp/rsync -d --delete --force --delete-after /tmp/foo/bob
> user at 10.55.11.130::module/tmp/foo
> 
> and have the remote side end up like this :
> 
> [root at r1c1n130 /tmp]# ls -l /tmp/foo/
> total 4
> drwxr-xr-x    2 root     root         4096 Oct 24 12:36 bleen
> -rw-r--r--    1 root     root            0 Oct 24 12:36 fred
> 
> without walking the /tmp/foo/bleen tree at all. This seems to make lots of
> sense to me. It seems like the intuitive thing to do. You ought to be able to
> sync something that doesn't exist on the sending side, and have it go away on
> the remote side, without wierd extra voodoo.
> 
> Anyway, as I said, I have a patch to make this work, and I'd rather it went
> in, 'cause then I wouldn't be out of synch with the rest of the world ;)


I'm not the official maintainer anymore, but I think there's little chance
of your patch being accepted.

- Dave Dykstra




More information about the rsync mailing list