delete files

Voelker, Bernhard bernhard.voelker at
Tue Nov 15 02:15:37 MST 2011

Brian K. White wrote:

> On 11/14/2011 2:29 AM, Voelker, Bernhard wrote:
> > rsync -avx --delete --include=/file --exclude='*' . host2:deltest/.
> This didn't work for me, although one difference is my script specifies 
> a path instead of "." Does this only work with literally "." in the 
> places above?

> ...

> For the new delete mode it detects if the supplied argument doesn't 
> exist locally and does this instead:
> P=/path/to/some
> F=thing
> h=target_host
> OPTS="-acv --delete"
> rsync $OPTS --include=/$F --exclude='*' $P ${h}::root$P
> Which to me looks the same as what you did except that I'm using an 
> explicit full path with leading "/" in $P instead of "."
> But when it runs the remote file is not deleted.
> After creating /tmp/floof/{1,2,3} locally and pushing that all out to a 
> remote box, then deleting /tmp/floof/2 locally, then trying to push out 
> the non-existing /tmp/floof/2 to the same remote host, I just get:
> ----------
> sending incremental file list
> rsync: link_stat "/tmp/floof/2" failed: No such file or directory (2)
> sent 12 bytes  received 12 bytes  48.00 bytes/sec
> total size is 0  speedup is 0.00
> rsync error: some files/attrs were not transferred (see previous errors) 
> (code 23) at main.c(1042) [sender=3.0.7]
> ----------

I've never seen this.

Personally spoken, I've ever been always confused about the use of $P
(a directory name) together with include or exclude rules, so I turned
to appending "/." to the source and the destination argument:
	rsync -avx [other options] somedir/.  user at server:[/]some/dir/.
in your case:
	rsync $OPTS --include=/$F --exclude='*' "$P/." "${h}::root$P/."

Do you have an older rsync on one of the peer sides?

Have a nice day,

More information about the rsync mailing list