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

Re: Using wildcards to remove archives




> On 14 Mar 2019, at 17:27 , Craig Hartnett <craig.lists@subs4.sitnominedigna.com> wrote:
> 
> Hi all,
> 
> 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. The
> following attempts (to delete all archives from November 2018 using the
> default naming convention used in the sample Tarsnap script) produces
> the shown errors:
> 
>        [00:30:32 USER@MACHINE ~]$ sudo tarsnap -d -f MACHINE-2018-11*
>        tarsnap: Archive does not exist: MACHINE-2018-11*
>        tarsnap: Error deleting archive
>        tarsnap: Error exit delayed from previous errors.
>        [00:31:14 USER@MACHINE ~]$ sudo tarsnap -d -f MACHINE-2018-11.*
>        tarsnap: Archive does not exist: MACHINE-2018-11.*
>        tarsnap: Error deleting archive
>        tarsnap: Error exit delayed from previous errors.
>        [00:32:05 USER@MACHINE ~]$
> 
> Can I accomplish this some other way?

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.

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{}

The important parts:
 -X and the {} for -f of tarsnap to fill the list of archives to delete
-j1 else you’ll have multiple tarsnaps competing and I recall the one working while the others exit with error

(I used the —keep-going for tarsnap, as I was using an “historical” list to prevent repeated requests, doing multiple delete runs over the list which then had already deleted archives and then tarsnap threw errors on those)

Attachment: signature.asc
Description: Message signed with OpenPGP