Skip to main content
All CollectionsUniFiUniFi - Advanced Guides
How to use rclone for copying UniFi backups to your Dropbox
How to use rclone for copying UniFi backups to your Dropbox
Reilly Chase avatar
Written by Reilly Chase
Updated over a year ago

In this article, we will show you how to use "rclone", a command line program that syncs files and directories to cloud storage providers.

At HostiFi, we configure your UniFi settings to perform automatic nightly backups by default.

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.

Contents

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

Configure rclone Dropbox authorization

rclone config

Enter "n" to create a New remote cloud storage provider

n

Next, enter a descriptive name for the storage provider

rchase_dropbox

Enter "9" to choose Dropbox as the storage type

9

Press ENTER to leave Dropbox App Client Id blank

ENTER

Press ENTER to leave Dropbox App Client Secret blank

ENTER

Enter "n" to skip the Edit advanced config prompt

n

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

n

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.

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

Sync your backups on a schedule

First, create a service that will run your backup command. To do that, run the following command:

systemctl edit --user --force --full unifi-sync-backups.service

This will open an editor. Insert the following contents into the file:

[Service]
Type=oneshot
ExecStart=/usr/bin/rclone copy /var/lib/unifi/backup rchase_dropbox:unifi

Edit arguments to the ExecStart command to match your rclone configuration. Note that you must use the full path (/usr/bin/rclone) to the rclone binary.

You can test your backup service by running systemctl start --user unifi-sync-backup.service.

Next, create a timer to run the service on a schedule. Run the following command:

systemctl edit --user --force --full unifi-sync-backups.timer

Insert the following contents into the editor:

[Timer]
OnCalendar=02:00 America/New_York

[Install]
WantedBy=timers.target

The OnCalendar specification above will take a backup daily at 2AM in the “America/New York” timezone. You can change this to match your desired backup time and frequency; see systemd.time(5) for details about the calendar event syntax.

Finally, enable your timer by running the following command:

systemctl enable --user --now unifi-sync-backups.timer

You can see details about your backup timer by running systemctl list-timers --user or systemctl status --user unifi-sync-backups.timer.

HostiFi

HostiFi provides hosting for both Ubiquiti and TP-Link software-defined-networking (SDN) applications, with servers for UniFi, UISP and Omada. We also offer professional networking consulting, with HostiFi Pro.

If you run into any issues, send an email to support@hostifi.com or contact us via live chat.

Did this answer your question?