This commit is contained in:
2023-08-24 21:27:28 -05:00
parent 6444e6258f
commit 0ed399dd4b
2 changed files with 20 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env bash
VERS='4.10.68-08242023'
VERS='4.10.75-08242023'
noheader=' service status-check nightlyrephp7.3-fpm,new backup report check checkcerts gitea update-nodes copynpmcerts singleservercheck update-dyndns '
CERT_DAEMON='/snap/bin/certbot'

View File

@@ -580,16 +580,28 @@ BACKUP_OFFSITEPFSENSE(){
scp root@10.2.1.1:/cf/conf/conf* ${newBAKFOLDER}/
ssh root@10.2.1.1 rm -f /cf/conf/conf_backup.tar.gz
[ "${BackupsToKeep}" == "" ] && BackupsToKeep=2
filestokeep=(`ls -d ${BAKFOLDER}/*-D | tail -${BackupsToKeep}`)
for i in $(ls -d ${BAKFOLDER}/*-D); do
if [ "$(date +%u)" == "1" ]; then
cp ${newBAKFOLDER} ${newBAKFOLDER/-D/-W}
elif [ "$(date +%d)" == "1" ]; then
cp ${newBAKFOLDER} ${newBAKFOLDER/-D/-M}
fi
dailyfilestokeep=(`ls -d ${BAKFOLDER}/*-D | tail -2`)
weeklyfilestokeep=(`ls -d ${BAKFOLDER}/*-W | tail -2`)
monthlyfilestokeep=(`ls -d ${BAKFOLDER}/*-M | tail -2`)
for i in $(ls -d ${BAKFOLDER}/*); do
keep=0
for a in ${filestokeep[@]}; do
if [[ "${i}" == *"-D"* ]]; then
filestokeep=${dailyfilestokeep[@]}
elif [[ "${i}" == *"-W"* ]]; then
filestokeep=${weeklyfilestokeep[@]}
elif [[ "${i}" == *"-M"* ]]; then
filestokeep=${monthlyfilestokeep[@]}
fi
for a in ${!filestokeep}; do
[ "${i}" == "${a}" ] && keep=1
done;
if [ $keep == 0 ]; then
[ "$(date +%u)" == "4" ] && mv ${i} ${i/-D/-W} || rm -rf ${i}
fi
[ $keep == 0 ] && rm -rf ${i}
done
}