Merge pull request #2985 from Security-Onion-Solutions/issue/2915

remove old backup files
This commit is contained in:
Josh Patterson
2021-02-17 09:43:58 -05:00
committed by GitHub

View File

@@ -38,9 +38,10 @@ if [ ! -f $BACKUPFILE ]; then
fi fi
# Find oldest backup file and remove it # Find oldest backup files and remove them
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) while [ "$NUMBACKUPS" -gt "$MAXBACKUPS" ]; do
if [ "$NUMBACKUPS" -gt "$MAXBACKUPS" ]; then OLDESTBACKUP=$(find /nsm/backup/ -type f -name "so-config-backup*" -type f -printf '%T+ %p\n' | sort | head -n 1 | awk -F" " '{print $2}')
rm -f /nsm/backup/$OLDESTBACKUP rm -f $OLDESTBACKUP
fi NUMBACKUPS=$(find /nsm/backup/ -type f -name "so-config-backup*" | wc -l)
done