mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
Merge pull request #2985 from Security-Onion-Solutions/issue/2915
remove old backup files
This commit is contained in:
@@ -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
|
||||||
Reference in New Issue
Block a user