remove oldest backup

This commit is contained in:
m0duspwnens
2021-02-16 11:40:45 -05:00
parent d6fa54b606
commit 1ccc5480e1

View File

@@ -40,7 +40,7 @@ fi
# Find oldest backup file and remove it # Find oldest backup file and remove it
NUMBACKUPS=$(find /nsm/backup/ -type f -name "so-config-backup*" | wc -l) NUMBACKUPS=$(find /nsm/backup/ -type f -name "so-config-backup*" | wc -l)
OLDESTBACKUP=$(find /nsm/backup/ -type f -name "so-config-backup*" | ls -1t | tail -1) OLDESTBACKUP=$(find /nsm/backup/ -type f -name "so-config-backup*" -type f -printf '%T+ %p\n' | sort | head -n 1 | awk -F" " '{print $2}')
if [ "$NUMBACKUPS" -gt "$MAXBACKUPS" ]; then if [ "$NUMBACKUPS" -gt "$MAXBACKUPS" ]; then
rm -f /nsm/backup/$OLDESTBACKUP rm -f $OLDESTBACKUP
fi fi