update backup count and counting mechanism
This commit is contained in:
parent
9e0f49c1bf
commit
7293aff6a5
1 changed files with 3 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
# 2024-05-26
|
||||
# lastmod: 2024-09-08
|
||||
# lastmod: 2024-10-05
|
||||
# Dominic Reich
|
||||
|
||||
BFILE=/srv/http/blocked.txt
|
||||
|
@ -16,13 +16,13 @@ OLDNUM=$(sudo ipset --terse -L | grep "Number of entries:" | cut -d: -f2 | xargs
|
|||
|
||||
while read ip; do sudo ipset -exist -A badips "$ip"; done < $IPFILE
|
||||
|
||||
FILEBACKUP=14
|
||||
FILEBACKUP=3
|
||||
|
||||
if [ ${FILEBACKUP} -ne 0 ]; then
|
||||
sudo cp ${BFILE} ${BFILE}.$(date +%Y%m%d)
|
||||
fi
|
||||
|
||||
BACKUPCOUNT=$(ls ${BFILE}* | wc -l)
|
||||
BACKUPCOUNT=$(ls ${BFILE}.* | wc -l)
|
||||
BACKUPSTODELETE=$(expr ${BACKUPCOUNT} - ${FILEBACKUP})
|
||||
if [ ${BACKUPCOUNT} -gt ${FILEBACKUP} ]; then
|
||||
for f in $(ls -tr ${BFILE}.* | head -${BACKUPSTODELETE})
|
||||
|
|
Loading…
Reference in a new issue