UniFi Video - Recording Backup Options


This article reviews the different options on how to backup the UniFi Video recordings, for both Windows and Linux (Hardware NVR).

Table of Contents

  1. Introduction
  2. Locating your Recordings
  3. Windows
  4. Linux/Hardware NVR
  5. Leveraging rsync
  6. Related Articles


Back to Top

When planning on backing up your recordings, there are a number of details you should take into account. Please consider these before following the steps below:

  • Videos are large files. Off-site backups will likely be too cumbersome without sufficient upload speed and may be subject to bandwidth caps on both sides, meaning bandwidth of upload where your NVR is and download where your off-site storage is. A single UVC-G3 camera at maximum bitrate is 6mbps. If it's recording full-time at maximum bitrate, at least 6mbps of upload would be necessary to perform a constant backup.
  • A 1:1 ratio of storage for backups is required. If expecting 1TB of recordings in the NVR device, 1TB of storage at the backup location will be needed as well.
  • There may be situations where you’re recording faster than a backup can move data. Consider network speeds and transfer protocols prior to implementing your backup.
  • A storage device can only read and write at a certain speed. Performing a backup will degrade your reading speed substantially. It is recommended to make use of bandwidth limiting utilities, keeping in mind the previous point: it will be a delicate balance.

Locating your Recordings

Back to Top

On any operating system, the storage location will be found by logging into UniFi Video and following these steps:

  1. Click Settings in the lower left-hand corner
  2. Click NVR Settings in the upper left-hand corner
  3. Click the Configure tab (selected by default)
  4. The Recording Path is the value for UniFi Video Recording Backup Options “Recording Path” 

The Default location of recordings are:

  • Windows Default: C:\ProgramData\unifi-video\videos
  • Linux Default: /var/lib/unifi-video/videos
  • airVision-C/UVC-NVR Default: /srv/unifi-video/videos


Back to Top

Unless the Windows version used has the ability to install a native NFS client, a USB 3.0 drive is recommended. The NFS client is significantly faster when compared to Samba (Windows file sharing), but Microsoft has not adopted this protocol in recent Windows versions.

Method 1 (Recommended):

  1. Mount your backup device.
  2. Use a backup utility to copy the recordings to the backup device.

 Windows 2 (Alternate):

  1. Mount your backup device.
  2. Create a batch script that will copy the recording directory to the backup storage.
  3. Use Task Scheduler to run the script at your desired intervals .

A batch script would resemble something like:

xcopy /E C:\ProgramData\unifi-video\videos\* “D:\UFV Backup\”

Linux/Hardware NVR

Back to Top

Linux offers NFS and iSCSI out of the box. Here are a couple guides that will help get you started:

NOTE: If you're doing this on the airVision-C or UVC-NVR, then you’ll need to follow step #13 from the first article or step #12 from the second article.

For any other Linux machines, make use of /etc/fstab. A typical fstab mount would look like this:

 /path/to/your/partition /backup/mount/path auto defaults,nodiratime,noatime,errors=continue 0 2

Leveraging rsync

Back to Top

Linux has a utility for copying files called rsync. This is what that would look like:

rsync -rltzhu --progress --delete /source/recording/path /destination/backup/path

For a reference of what these flags do, please see the rsync manual page. The keys here are the -r and --delete.  Command -r tells rsync to copy recursively (sub directories) and --delete tells rsync to delete files on the destination that do not exist on the source. Command --delete is particularly important if you need to clear old data. Failing to use --delete will inevitably fill up your backup location causing future syncs to fail.

It is recommended that you run this command back-to-back until the transfer time is minimal. Then you can schedule the sync to run on an interval. This is done via crontab in Linux. To edit the crontab, follow these steps:

1. Execute:

crontab -e

2. Enter a line at the bottom of the crontab.

The following example will sync files every 5 minutes:

*\5  *  *  *  *               rsync -rltzhu --delete /source/recording/path /destination/backup/path

The following example will sync every night at 2AM:

0  2  *  *  *               rsync -rltzhu --delete /source/recording/path /destination/backup/path

You can tweak the frequency in which the command runs by editing the first 5 characters. The first character is minute, the second is hour, the third is day of month (i.e. the 15 would be the 15th day of the month), fourth is month (i.e. June is 6), and fifth is the day of the week (i.e. 0 is Sunday, 6 is Saturday). Wildcards (asterisks, *) should be used in most cases. In the second example, it says minute = 0, hour = 2 (or 2:00 am, to be specific), every day of the month, every month, and every day of the week.

Another example for wildcards is running intervals within those constraints. The first example has “*\5” for minutes, this means run every 5 minutes.  A similar setup for hours would be “*” in the hour place to run every hour or “*\2” to run every two hours. There are also shortcuts such as “@daily” which is really an alias for “0 0 * * *” (this is Midnight every day). For a more thorough explanation of cron for your customization purposes, please see this guide.

 Alternatives to rsync in Linux:

  • DRBD (provides an exact replica of the entire partition as a live sync)
  • lsync
NOTE: If you receive the error bash: rsync: command not found you will need to install rsync first using the following command:
sudo apt-get update && sudo apt-get install rsync

Related Articles

Back to Top

UniFi Video - How to Add a Network Volume to the NVR Appliance

UniFi Video - How to Add an External Hard Drive to the NVR Appliance

We're sorry to hear that!