update backup count and counting mechanism

main
Dominic Reich 2 months ago
parent 9e0f49c1bf
commit 7293aff6a5
Signed by: dominic
GPG Key ID: BC9D6AE1A3BE169A

@ -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…
Cancel
Save