From 187bf571695147cf4c3bc40d9879797a2a69e6a8 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Sun, 15 Jun 2008 09:19:07 +0000 Subject: keep maximum of $BACKUP_LIMIT backups --- lbu | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lbu b/lbu index 4b672c5..0bd309d 100644 --- a/lbu +++ b/lbu @@ -360,6 +360,16 @@ cmd_commit() { die "Problems creating archive. aborting" fi + # delete old backups if needed + # poor mans 'head -n -N' done with awk. + ls "$mnt"/$(hostname).[0-9][0-9][0-9][0-9]*[0-9].tar.gz \ + | awk '{ a[++i] = $0; } END { + print a[0]; + while (i-- > '"${BACKUP_LIMIT:-0}"') { + print a[++j] + } + }' | xargs rm 2>/dev/null + # remove obsolete file. some older version of alpine needs this # to be ble to upgrade if [ -z "$DRYRUN" ] && [ -f $mnt/packages.list ]; then -- cgit v1.2.3