Update nodemgmt-scripts.sh

This commit is contained in:
2025-05-10 15:36:39 -05:00
parent 3e3b42ed25
commit 2ca05f92fa

View File

@@ -744,30 +744,30 @@ BACKUP_UNIFINVR(){
fi fi
fi fi
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 folder in $(ls -d ${BAKFOLDER}/*); do # for folder in $(ls -d ${BAKFOLDER}/*); do
if [ "${folder}" != "${BAKFOLDER}/mounted" ]; then # if [ "${folder}" != "${BAKFOLDER}/mounted" ]; then
if [[ "${folder}" == *"-D"* ]]; then # if [[ "${folder}" == *"-D"* ]]; then
filestokeep=${dailyfilestokeep[@]} # filestokeep=${dailyfilestokeep[@]}
elif [[ "${folder}" == *"-W"* ]]; then # elif [[ "${folder}" == *"-W"* ]]; then
filestokeep=${weeklyfilestokeep[@]} # filestokeep=${weeklyfilestokeep[@]}
elif [[ "${folder}" == *"-M"* ]]; then # elif [[ "${folder}" == *"-M"* ]]; then
filestokeep=${monthlyfilestokeep[@]} # filestokeep=${monthlyfilestokeep[@]}
fi # fi
keep=0 # keep=0
for file in ${filestokeep}; do # for file in ${filestokeep}; do
if [ "${folder}" == "${file}" ]; then # if [ "${folder}" == "${file}" ]; then
keep=1; break # keep=1; break
fi # fi
done; # done;
if [ $keep == 0 ]; then # if [ $keep == 0 ]; then
delFolder="D:\\BackupSync\\UniFi-Backups\\UniFi-NVR_Backups\\${folder##*/}" # delFolder="D:\\BackupSync\\UniFi-Backups\\UniFi-NVR_Backups\\${folder##*/}"
ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 backup@10.10.1.60 cmd /C rmdir /S /Q "${delFolder}" # ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 backup@10.10.1.60 cmd /C rmdir /S /Q "${delFolder}"
fi # fi
fi # fi
done # done
else else
SENDNOTICE "UniFi-NVR Backup Failed" "Could not contact 'NVR @ ${UNIFINVR_IP}' for backup" 1 SENDNOTICE "UniFi-NVR Backup Failed" "Could not contact 'NVR @ ${UNIFINVR_IP}' for backup" 1
fi fi