[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Cron archive deletion / mass archive deletion
On Wednesday, July 9, 2014 8:30:33 PM CEST, Bob wrote:
I am using freeBSD and just started tarsnap backups. I would
like to understand a reasonable way to do periodic deletes via
cron. I have named my backups "lilybackup-yyyy-mm-dd-hh:mm:ss".
My hope is to be able to delete backups older than 30 days.
Here's what I use. This keeps ~10 backups around and culls so I have all of
the most recent ones and a few older backups:
backups=$(/usr/local/bin/tarsnap \
--keyfile /root/tarsnap.key \
--cachedir /var/lib/tarsnap/cache \
--list-archives)
[ 10 -lt $(echo $backups | wc -w) ] && exit 0
for a in $( echo $backups | fmt -1 | sort -r | sed -n '5~3p' ); do
/usr/local/bin/tarsnap \
-d \
--keyfile /root/tarsnap.key \
--cachedir /var/lib/tarsnap/cache \
-f $a
done
Arnt