Update nodemgmt-scripts.sh

This commit is contained in:
2023-10-30 21:49:08 -05:00
parent 839e2a6abe
commit 2576734201

View File

@@ -578,7 +578,9 @@ UPDATE_DYNDNS(){
} }
BACKUP_OFFSITEPFSENSE(){ BACKUP_OFFSITEPFSENSE(){
BAKFOLDER=/opt/Offsite-pfSense_Backups OFFSITE_PFSENSE_IP='10.2.1.1'
if [ "$(CHECK_HOST ${OFFSITE_PFSENSE_IP})" != "false" ]; then
BAKFOLDER=/mnt/Veeam-pfSense-Backups
newBAKFOLDER=${BAKFOLDER}/`date +%Y%m%d-%H%M%S` newBAKFOLDER=${BAKFOLDER}/`date +%Y%m%d-%H%M%S`
mkdir ${newBAKFOLDER} mkdir ${newBAKFOLDER}
DOM='01' DOM='01'
@@ -587,9 +589,9 @@ BACKUP_OFFSITEPFSENSE(){
WeeklyBackupsToKeep=12 WeeklyBackupsToKeep=12
MonthlyBackupsToKeep=24 MonthlyBackupsToKeep=24
ssh root@10.2.1.1 tar -c -f /cf/conf/conf_backup.tar.gz /cf/conf ssh root@${OFFSITE_PFSENSE_IP} tar -c -f /cf/conf/conf_backup.tar.gz /cf/conf
scp root@10.2.1.1:/cf/conf/conf* ${newBAKFOLDER}/ scp root@${OFFSITE_PFSENSE_IP}:/cf/conf/conf* ${newBAKFOLDER}/
ssh root@10.2.1.1 rm -f /cf/conf/conf_backup.tar.gz ssh root@${OFFSITE_PFSENSE_IP} rm -f /cf/conf/conf_backup.tar.gz
if [ "$(date +%d)" == "${DOM}" ] && [ "$(date +%u)" == "${DOW}" ]; then if [ "$(date +%d)" == "${DOM}" ] && [ "$(date +%u)" == "${DOW}" ]; then
mv ${newBAKFOLDER} "${newBAKFOLDER}-M" mv ${newBAKFOLDER} "${newBAKFOLDER}-M"
@@ -608,22 +610,27 @@ BACKUP_OFFSITEPFSENSE(){
dailyfilestokeep=(`ls -d ${BAKFOLDER}/*-D 2> /dev/null | tail -${DailyBackupsToKeep}`) dailyfilestokeep=(`ls -d ${BAKFOLDER}/*-D 2> /dev/null | tail -${DailyBackupsToKeep}`)
weeklyfilestokeep=(`ls -d ${BAKFOLDER}/*-W 2> /dev/null | tail -${WeeklyBackupsToKeep}`) weeklyfilestokeep=(`ls -d ${BAKFOLDER}/*-W 2> /dev/null | tail -${WeeklyBackupsToKeep}`)
monthlyfilestokeep=(`ls -d ${BAKFOLDER}/*-M 2> /dev/null | tail -${MonthlyBackupsToKeep}`) monthlyfilestokeep=(`ls -d ${BAKFOLDER}/*-M 2> /dev/null | tail -${MonthlyBackupsToKeep}`)
for i in $(ls -d ${BAKFOLDER}/*); do keep=0 for folder in $(ls -d ${BAKFOLDER}/*); do
if [[ "${i}" == *"-D"* ]]; then if [[ "${folder}" == *"-D"* ]]; then
filestokeep=${dailyfilestokeep[@]} filestokeep=${dailyfilestokeep[@]}
elif [[ "${i}" == *"-W"* ]]; then elif [[ "${folder}" == *"-W"* ]]; then
filestokeep=${weeklyfilestokeep[@]} filestokeep=${weeklyfilestokeep[@]}
elif [[ "${i}" == *"-M"* ]]; then elif [[ "${folder}" == *"-M"* ]]; then
filestokeep=${monthlyfilestokeep[@]} filestokeep=${monthlyfilestokeep[@]}
fi fi
for a in ${filestokeep}; do keep=0
if [ "${i}" == "${a}" ]; then for file in ${filestokeep}; do
if [ "${folder}" == "${file}" ]; then
keep=1; break keep=1; break
fi fi
done; done;
[ $keep == 0 ] && rm -rf ${i} # [ $keep == 0 ] && rm -rf ${folder}
# [ $keep == 0 ] && ssh backup@10.10.1.60 rmdir "D:\Offsite-pfSense_Backups\${newBAKFOLDER}"
[ $keep == 0 ] && echo "DELETE FOLDER: ${folder}"
done done
else
SENDNOTICE "Offsite pfSense Backup Failed" "Could not contact 'pfSense @ ${OFFSITE_PFSENSE_IP}' for backup"
fi
} }
RUN_COMMAND(){ RUN_COMMAND(){