From 0ed399dd4b9b24331d0bbc8ec9755fd9e4728734 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Thu, 24 Aug 2023 21:27:28 -0500 Subject: [PATCH] update --- defaults.inc | 2 +- nodemgmt-scripts.sh | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/defaults.inc b/defaults.inc index cb65b526..e6d17f4b 100755 --- a/defaults.inc +++ b/defaults.inc @@ -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' diff --git a/nodemgmt-scripts.sh b/nodemgmt-scripts.sh index ea4054b7..30f33c2f 100755 --- a/nodemgmt-scripts.sh +++ b/nodemgmt-scripts.sh @@ -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 }