How to delete a whole destination tree (inclusive the destination its-self) with rsync (daemon)?
matt at mattmccutchen.net
Sun Oct 31 09:47:20 MDT 2010
On Sun, 2010-10-31 at 17:39 +0200, Edvinas Valatka wrote:
> On Sun, 31 Oct 2010 03:15:37 +0100
> Vahsen Beheer <beheer at vahsen.nl> wrote:
> > I am backing up (using --link-dest, hard links) to a NAS which has
> > an 'rsync' daemon running. I do not have ssh access to this
> > Storage-device. Part of my script needs to delete whole remote
> > directory trees. This seems difficult with rsync.
> > A nice trick is to make an empty source directory:
> > rsync -a --delete /tmp/empty-dir/
> > remote-host::Backups/daily.20101030-0155
> > This works perfect. It deletes the contents of destination. However,
> > need it to also delete the destination directory its-self.
> > This seems something very easy, but after searching for many hours in
> > the manual, FAQ, Web and forum did not reveal a solution.
> > Is it possible to have rsync also delete the 'destination-directory' ?
> > (Or do i need to work from its parent-directory of the destination -
> > here the module itsself ? Or do something with filters?)
> > The next also does not work (it deletes all! from the Backups module):
> > rsync -a --exclude='/***' --include='/daily.20101030-0155/'
> > --delete /tmp/empty-dir/ remote-host::Backups
> Or: rsync -ndivv -f 'P!p /daily.20101030-0155' --del /tmp/empty_dir/
Yes, there are a number of variations that work. I had another one
More information about the rsync