diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2008-06-15 09:19:07 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2008-06-15 09:19:07 +0000 |
commit | 187bf571695147cf4c3bc40d9879797a2a69e6a8 (patch) | |
tree | 16ff751e0f402f49ea6bde1d02a297fb8955607b | |
parent | 0e96ae680ea409f90a5baf4a5d52aba485d1440e (diff) | |
download | alpine-conf-187bf571695147cf4c3bc40d9879797a2a69e6a8.zip |
keep maximum of $BACKUP_LIMIT backups
-rw-r--r-- | lbu | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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 |