Update nodemgmt-scripts.sh

This commit is contained in:
2025-05-10 15:38:31 -05:00
parent 2ca05f92fa
commit a9f0e75888

View File

@@ -727,47 +727,51 @@ BACKUP_UNIFINVR(){
if [ $(scp root@${UNIFINVR_IP}:/volume1/*_backup.tar.gz ${BAKFOLDER}/${newBAKFOLDER}/) ]; then if [ $(scp root@${UNIFINVR_IP}:/volume1/*_backup.tar.gz ${BAKFOLDER}/${newBAKFOLDER}/) ]; then
ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${UNIFINVR_IP} rm -f /volume1/*_backup.tar.gz ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${UNIFINVR_IP} rm -f /volume1/*_backup.tar.gz
cd ${BAKFOLDER} cd ${BAKFOLDER}
if [ "$(date +%d)" == "${DOM}" ] && [ "$(date +%u)" == "${DOW}" ]; then if [ "$(date +%d)" == "${DOM}" ] && [ "$(date +%u)" == "${DOW}" ]; then
echo "HERE 1";
mv ${newBAKFOLDER} "${newBAKFOLDER}-M" mv ${newBAKFOLDER} "${newBAKFOLDER}-M"
ln -s "${newBAKFOLDER}-M" "${newBAKFOLDER}-W" ln -s "${newBAKFOLDER}-M" "${newBAKFOLDER}-W"
ln -s "${newBAKFOLDER}-M" "${newBAKFOLDER}-D" ln -s "${newBAKFOLDER}-M" "${newBAKFOLDER}-D"
elif [ "$(date +%d)" == "${DOM}" ]; then elif [ "$(date +%d)" == "${DOM}" ]; then
echo "HERE 2";
mv ${newBAKFOLDER} "${newBAKFOLDER}-M" mv ${newBAKFOLDER} "${newBAKFOLDER}-M"
ln -s "${newBAKFOLDER}-M" "${newBAKFOLDER}-D" ln -s "${newBAKFOLDER}-M" "${newBAKFOLDER}-D"
elif [ "$(date +%u)" == "${DOW}" ]; then elif [ "$(date +%u)" == "${DOW}" ]; then
echo "HERE 3";
mv ${newBAKFOLDER} "${newBAKFOLDER}-W" mv ${newBAKFOLDER} "${newBAKFOLDER}-W"
ln -s "${newBAKFOLDER}-W" "${newBAKFOLDER}-D" ln -s "${newBAKFOLDER}-W" "${newBAKFOLDER}-D"
else else
echo "HERE 4";
mv ${newBAKFOLDER} "${newBAKFOLDER}-D" mv ${newBAKFOLDER} "${newBAKFOLDER}-D"
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