We also have a script which logs in via SSH each night and copies the backup from the previous night over to DigitalOcean Spaces. In case there is a hardware failure on the server, this is our offsite backup to restore from.
As a third copy, we recommend that you take an occasional manual backup and save to your PC, or use this guide to keep updated UniFi backups on Dropbox.
1. Get SSH access to your HostiFi server
The first step is to get SSH access as the unifi user to your HostiFi server by following this guide: https://support.hostifi.net/en/articles/3437198-how-to-ssh-or-sftp-into-your-unifi-server
2. Configure rclone Dropbox authorization
Enter “n” to create a New remote cloud storage provider
Next, enter a descriptive name for the storage provider
Enter “9” to choose Dropbox as the storage type
Press ENTER to leave Dropbox App Client Id blank
Press ENTER to leave Dropbox App Client Secret blank
Enter “n” to skip the Edit advanced config prompt
Enter “n” to skip auto config – because we are connected to a command prompt instead of a PC, we won’t be able to automatically open a web browser on the HostiFi server to complete the Dropbox authorization process, we’ll have to do it on our PC locally in the next steps
To complete the Dropbox authorization, we have to download rclone to our PC and run “rclone authorize dropbox”
You can download rclone here: https://rclone.org/downloads/
If you are on Windows, you’ll download and then unzip the folder
Then open CMD and use the “cd” command change directories into the rclone unzipped folder
From there you should get the help response from running “rclone.exe”
Next, we need to run “rclone.exe authorize dropbox” to trigger the Dropbox app authorization wizard.
rclone.exe authorize dropbox
This will open a web browser with the Dropbox app authorization request
Click the Allow button
Now you will see a success web page. You can close the web browser and go back to your rclone CMD window. You should see a response there with instructions to paste the snippet of code into your remote machine.
Copy the snippet (right click, select Mark, highlight text with left cursor, right click to copy) then head back to your PuTTY terminal with SSH access to your HostiFi server.
Paste in the snippet (right click to paste in PuTTY) and then hit ENTER, it should look like this
Enter “y” to save
Dropbox configuration is now complete! Enter “q” to quit config.
3. Sync the UniFi backup directory at HostiFi to your Dropbox
First, you may want to create a folder in your Dropbox account to sync to:
Next, run this command to do your first sync. Replace “rchase_dropbox” with the description for your cloud storage that you created during setup.
rclone copy /var/lib/unifi/backup rchase_dropbox:unifi
4. Create a cronjob to run the rclone once per day
0 2 * * * rclone copy /var/lib/unifi/backup rchase_dropbox:unifi