Last active
April 26, 2021 22:27
-
-
Save cdbailey/b796b6379f52b393c63a0d39bb13ab02 to your computer and use it in GitHub Desktop.
UDM PRO Backup to NFS Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# /volume1/UDMBackup is the path to the NFS share on the Synology | |
# /nfs/UDMBackup is the mount point on the local Linux server where the script runs | |
# /opt/scripts/UDM_pass is a text file containing the root account password on the UDM | |
# I run this script on an Ubuntu VM for ease of maintenance and save the backups on a Synology using NFS | |
LOGFILE="/opt/scripts/udmpro-backup.log" | |
BKUPSCRIPT="sshpass -f /opt/scripts/UDM_pass scp -o StrictHostKeyChecking=no -r root@<<UDM PRO IP ADDRESS>>:/mnt/data/unifi-os/unifi/data/backup/autobackup/* /nfs/UDMBackup" | |
mount <<SYNOLOGY IP ADDRESS>>:/volume1/UDMBackup /nfs/UDMBackup | |
if findmnt --raw --noheadings <<SYNOLOGY IP ADDRESS>>:/volume1/UDMBackup /nfs/UDMBackup ; then | |
echo -e "[`date '+%m/%d/%Y %H:%M:%S'`] NFS /nfs/UDMBackup mount SUCCESS" >> $LOGFILE | |
if $BKUPSCRIPT ; then | |
rm /nfs/UDMBackup/backup_time ; touch /nfs/UDMBackup/backup_time | |
echo -e "[`date '+%m/%d/%Y %H:%M:%S'`] UDMPRO backup SUCCESS" >> $LOGFILE | |
else | |
echo -e "[`date '+%m/%d/%Y %H:%M:%S'`] UDMPRO backup FAILED - SCP copy error" >> $LOGFILE | |
fi | |
else | |
echo -e "[`date '+%m/%d/%Y %H:%M:%S'`] UDMPRO backup FAILED - NFS /nfs/UDMBackup mount FAILED" >> $LOGFILE | |
fi | |
umount /nfs/UDMBackup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment