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 the Recordings
  3. Windows
  4. Linux/Hardware NVR
  5. Leveraging rsync
  6. Related Articles


Back to Top

When planning on backing up recordings, there are a number of details that should be taken into account:

  • Videos are large files. Off-site backups will likely be too cumbersome without a sufficient upload speed and may be subject to bandwidth caps on both sides, meaning the upload bandwidth of the NVR site and the download bandwidth of the off-site storage. A single UVC-G3 camera will need at least 6 Mbps of upload if it's recording full-time at maximum bitrate, 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 the cameras are recording faster than a backup can move data. Consider network speeds and transfer protocols prior to implementing the backup.
  • A storage device can only read and write at a certain speed. Performing a backup will degrade the 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 the 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 the backup device.
  2. Use a backup utility to copy the recordings to the backup device.

 Method 2 (Alternate):

  1. Mount the 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 to get started:

NOTE:If using the airVision-C or UVC-NVR, following step #13 from the first article or step #12 from the second article will be necessary.

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 to run this command back-to-back until the transfer time is minimal. Then the sync to run on an interval can be scheduled. 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

The frequency in which the command runs can be tweaked 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 this results in the errorbash: rsync: command not found, please 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 Use an External Hard Drive with the NVR Appliance or a Linux Install

Was this article helpful?
8 out of 21 found this helpful