[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using wildcards to remove archives



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?

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).

I'm deleting any archive names that match "zeros-100*" because
they're left-over from some debugging I was doing.


$ tarsnap --list-archives > archivelist.txt
$ grep "zeros-100*" archivelist.txt > todelete.txt
$ more todelete.txt 
zeros-1001
zeros-1000
$ tarsnap -d --archive-names todelete.txt 
                                       Total size  Compressed size
All archives                                12399             7607
  (unique data)                             12399             7607
zeros-1001                                   3039             1750
Deleted data                                 3039             1750
                                       Total size  Compressed size
All archives                                 9360             5854
  (unique data)                              9360             5854
zeros-1000                                   3039             1753
Deleted data                                 3039             1753
$ 


Adding the --keep-going option may be useful, and certainly won't hurt.

Cheers,
- Graham