On Thu, Mar 14, 2019 at 05:39:42PM +0200, hvjunk wrote: On 14 Mar 2019, at 17:27 , Craig Hartnett <craig.lists@subs4.sitnominedigna.com> wrote:
I've skimmed the sources of some of the "helper scripts" that offer archive rotation (and, of course, done a web search), but I can't seem to figure out how to use wildcards to delete Tarsnap archives.
See below. :) Pull the whole list of archives, then grep for those you want, and do a multiple delete action: Beware, it could take easily an hour for large number of archives (In my case dailies) where I delete and leave weeklies/monthlies every 3-6months.
Yes, although I'd use a different "multiple delete action". The “juice” part I use is GNU parallel which gets fed the list of archives (on the STDIN), one per line, ie:
cat LIST-TO-DELETE | parallel -j1 -X time tarsnap -v -v -v -d --keep-going -f{}
This is the first time I've looked into GNU parallel, but if you use it with -j1, surely it has no real effect?
The -j1 is like xargs’s “default”, ie. no parallel execution. The reason for parallel and not xargs, is/was the -f <archive_name> repetition, as I’ve stated at the bottom of that email "else you’ll have multiple tarsnaps competing and I recall the one working while the others exit with error”
Here's my solution, using the --archive-names option (new in 1.0.38, 2018-July-15, so longtime users might not know it exists).
Ah!, thanks for reminding my about that one!
|