Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gtrabanco/5e7a9ac0a15e3b9bbe9ba6de20e9f347 to your computer and use it in GitHub Desktop.
Save gtrabanco/5e7a9ac0a15e3b9bbe9ba6de20e9f347 to your computer and use it in GitHub Desktop.
UDM PRO Backup to NFS Script
#!/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