UniFi Video - Recording Backup Options


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

Table of Contents

  1. Things to consider before you begin
  2. Find your recording storage location
  3. For Windows
  4. For Linux/Hardware NVR
  5. Leveraging rsync
  6. Related Articles

Things to consider before you begin

Back to Top

Before reading further, we must forewarn you about the following caveats:

  • 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 (i.e. upload where your NVR is and download where your off-site storage is). To put this into perspective, a single UVC-G3 camera at maximum bitrate is 6mbps. If you're recording full-time at maximum bitrate for a single camera, you’d need at least 6mbps of upload to do a constant backup.
  • You will need a 1:1 ratio of storage for backups. If you max out at 1TB of recordings at the NVR device, you’ll need 1TB of storage at the backup location 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. Again, referencing point #1, with ten UVC-G3 all recording full-time at maximum bitrate, you’re going to need at least 60mbps of throughput available to the backup location.
  • IOPS. IOPS. IOPS. A storage device can only read and write at a certain speed. Performing a backup will degrade your read speed substantially. It is recommended to make use of bandwidth limiting utilities, but keep in mind point #3; it will be a delicate balance.

Find your recording storage location

Back to Top

Regardless of what operating system you’re running, you can quickly find your storage location by first logging in to UniFi Video:

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

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

For Windows

Back to Top

Unless you’re lucky enough to have a version of Windows that has the ability to install a native NFS client, you should consider a USB 3.0 drive (assuming, of course, your server has at least 1 USB 3.0 port). The NFS client is significantly faster when compared to Samba (a.k.a. Windows file sharing), but Microsoft has not adopted this protocol in less versions. For example, Windows 7, 8.1, and 10 would require you to have Enterprise level licensing (Enterprise/Pro for Windows 10) to enable NFS. Samba is the most user-friendly and, arguably, the easiest to setup, but is somewhat limited on transfer speeds.

 Windows Easy Method:

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

 Windows Alternate (Not-So-Easy) Method:

  1. Mount your backup device
  2. Create a batch script that will copy (cp) 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\”

For Linux/Hardware NVR

Back to Top

Luckily, Linux offers NFS and iSCSI out of the box (they may need to be installed). Here are a couple guides that will help get you started:

Adding iSCSI: UniFi Video - How to add a network volume to the NVR appliance? (Steps 1-12)

Adding USB: UniFi Video - How to add an External Hard Drive to the NVR Appliance (Steps 1-11)

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.

If you’re doing this on a Linux machine that is not the airVision-C or UVC-NVR, then you should 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. Think of it as a "copy" on steroids.

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’re wanting 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, simply execute:

crontab -e

And 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, of course, tweak the frequency in which the command runs. The first designator 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 may be and should be used in most cases.  In the second example, we’re saying minute = 0, hour = 2, 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 * * *” (a.k.a. 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 

Related Articles

Back to Top