delete files
Brian K. White
brian at aljex.com
Mon Nov 14 21:15:20 MST 2011
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?
My script parses the given command line into a path/file
(dirname/basename) pair and drops the path part in the same places you
have "." above.
Basically, to push a file out to all hosts, the user says:
pushfile /path/to/some/thing [host(s)...]
(* optional target host(s), defaults to all hosts listed in a config
file if not specified)
That normally results in:
P=/path/to/some
F=thing
h=target_host
OPTS=-acv
rsync $OPTS ${P}/$F ${h}::root$P
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]
----------
--
bkw
More information about the rsync
mailing list