Vahsen Beheer
2010-Oct-31 02:15 UTC
How to delete a whole destination tree (inclusive the destination its-self) with rsync (daemon)?
An HTML attachment was scrubbed... URL: <http://lists.samba.org/pipermail/rsync/attachments/20101031/bb482d8d/attachment.html>
Edvinas Valatka
2010-Oct-31 10:25 UTC
How to delete a whole destination tree (inclusive the destination its-self) with rsync (daemon)?
On Sun, 31 Oct 2010 03:15:37 +0100 Vahsen Beheer <beheer at vahsen.nl> wrote:> Hi! > > 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 > > > Any tips? Did anyone ever tried this? :) > Thanks a lot in advance! > Robert > > > PS: I also looked into the --prune-empty-dirs option, without success > though. > >rsync -naivv -f '-!pr daily.20101030-0155' --del /tmp/empty_dir/ remote-host::Backups/
Edvinas Valatka
2010-Oct-31 10:45 UTC
How to delete a whole destination tree (inclusive the destination its-self) with rsync (daemon)?
On Sun, 31 Oct 2010 03:15:37 +0100 Vahsen Beheer <beheer at vahsen.nl> wrote:> Hi! > > 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 > > > Any tips? Did anyone ever tried this? :) > Thanks a lot in advance! > Robert > > > PS: I also looked into the --prune-empty-dirs option, without success > though. > > > > > >Maybe better: rsync -ndivv -f '-!pr /daily.20101030-0155' --del /tmp/empty_dir/ remote-host::Backups/
Edvinas Valatka
2010-Oct-31 15:39 UTC
How to delete a whole destination tree (inclusive the destination its-self) with rsync (daemon)?
On Sun, 31 Oct 2010 03:15:37 +0100 Vahsen Beheer <beheer at vahsen.nl> wrote:> Hi! > > 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 > > > Any tips? Did anyone ever tried this? :) > Thanks a lot in advance! > Robert > > > PS: I also looked into the --prune-empty-dirs option, without success > though. > > > > > >Or: rsync -ndivv -f 'P!p /daily.20101030-0155' --del /tmp/empty_dir/ remote-host::Backups/
Vahsen Beheer
2010-Oct-31 15:52 UTC
How to delete a whole destination tree (inclusive the destination its-self) with rsync (daemon)?
An HTML attachment was scrubbed... URL: <http://lists.samba.org/pipermail/rsync/attachments/20101031/dfd9c291/attachment.html>
Vahsen Beheer
2010-Oct-31 18:16 UTC
How to delete a whole destination tree (inclusive the destination its-self) with rsync (daemon)?
On 31-10-2010 18:41, edacval at gmail.com wrote:> On 10/31/2010 07:26 PM, Vahsen Beheer wrote: >> On 31-10-2010 18:07, edacval at gmail.com wrote: >>> "-n" means "dry-run", no real action will be performed :). >>> >>> Hope found one-line solution: >>> rsync -ndivv -f 'R /daily.20101030-0155/**' -f '-!r >>> /daily.20101030-0155' --del /tmp/empty_dir/ remote-host::Backups/ >>> >> :-) I know that it is a dry run... The thing is however that all your latter >> solutions work perfectly on the root of the module. >> However i need to delete directories which are in subdirectories of this module... >> I guess the problem is the anchoring of the module in combination with the >> filter-rules. >> Reading the manual about 'anchoring include/exclude patterns' and checking out >> the filter-rules did not help me. >> >> Can you get your last example to work with a subdirectory of a directory in the >> module its-self ? >> >> The thing i tried below (with the added "SUBDIR/") does not work: >> ( i try to remove the tree: "remote-host::Backups/SUBDIR/daily.20101030-0155") >> >> rsync -divvv -f 'R /*SUBDIR/*daily.20101030-0155/**' -f '-!r >> /SUBDIR/daily.20101030-0155' --del /tmp/empty_dir/ remote-host::Backups/*SUBDIR/* >> >> A final hint? ;) >> > rsync -divvv -f 'R /daily.20101030-0155/**' -f '-!r > /daily.20101030-0155' --del /tmp/empty_dir/ remote-host::Backups/SUBDIR/The latter example of Edvinas works perfectly. It deletes the directory tree: "remote-host::Backups/SUBDIR/daily.20101030-0155" It seems that filters are relative to the whole destination path, and not only themodule (as for example '--link-dest' is). Thanks a lot for your help Edvinas (and also Matt), this seemed like a trivial thing to do, but certainly wasn't for a rsync-filter-newbie ;-) Cheers!