summaryrefslogtreecommitdiffstats
path: root/lbu
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2008-06-15 09:19:07 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2008-06-15 09:19:07 +0000
commit187bf571695147cf4c3bc40d9879797a2a69e6a8 (patch)
tree16ff751e0f402f49ea6bde1d02a297fb8955607b /lbu
parent0e96ae680ea409f90a5baf4a5d52aba485d1440e (diff)
downloadalpine-conf-187bf571695147cf4c3bc40d9879797a2a69e6a8.tar.bz2
alpine-conf-187bf571695147cf4c3bc40d9879797a2a69e6a8.tar.xz
keep maximum of $BACKUP_LIMIT backups
Diffstat (limited to 'lbu')
-rw-r--r--lbu10
1 files changed, 10 insertions, 0 deletions
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