Albin Varghese
Back to Blog

How I Avoided NVR/DVR Setup Using My Pi5 and Backblaze B2

5 min read
Raspberry Pi
NVR
DVR
Backblaze B2
Cloud Storage
Frigate
Surveillance
IoT

How I Avoided NVR/DVR Setup Using My Pi5 and Backblaze B2

Traditional Network Video Recorder (NVR) systems can be expensive, bulky, and often limited in functionality. After researching various surveillance options, I created a streamlined and cost-effective alternative using a Raspberry Pi 5 and Backblaze B2 cloud storage. This solution not only saved me hundreds of dollars but also provided greater flexibility and scalability than commercial options. Here's how I built my cloud-powered surveillance system.

Why I Needed an Alternative to Traditional NVR Systems

Traditional surveillance setups typically require dedicated NVR hardware, which can be costly and inflexible. Many commercial systems also lock you into proprietary ecosystems, making future upgrades complicated and expensive. As someone who values both privacy and flexibility, I wanted a solution that would give me complete control while keeping costs reasonable.

After evaluating my options, I determined that my requirements included:

  • Support for multiple IP cameras
  • Reliable 24/7 recording
  • Motion detection and notifications
  • Secure offsite storage for footage
  • Cost-effectiveness over the long term
  • Ability to access recordings remotely

A Raspberry Pi 5 paired with cloud storage seemed like the perfect solution to meet these needs without breaking the bank.

Hardware Configuration

The Raspberry Pi 5 Setup

The Raspberry Pi 5 serves as the brain of the operation. Its improved processing power makes it significantly more capable than previous models for handling multiple camera streams. Here's what my hardware setup includes:

  • Raspberry Pi 5 (8GB RAM model)
  • NVMe SSD (1TB) for system and temporary storage
  • USB Coral TPU accelerator (for efficient object detection)
  • PoE HAT (optional, for powering the Pi directly from ethernet)

The Pi 5's robust CPU and increased RAM allow it to handle multiple camera streams while performing motion detection and other processing tasks. Using an NVMe drive rather than an SD card provides much better performance and reliability for continuous recording operations.

Cameras

I use a mix of PoE and Wi-Fi cameras, including:

  • 2x Hikvision DS-2CD2122FW-I (1080p PoE cameras)
  • 1x Reolink C800 (4K camera with H.265 support)

These cameras provide a good balance of quality, reliability, and cost. Each camera supports RTSP streams, which is essential for integration with our software stack.

Software Configuration

Operating System and Base Configuration

I started with a fresh install of Raspberry Pi OS and configured it for headless operation. For this project, I utilized Jeff Geerling's open-source pi-nvr project, which provides Ansible automation for NVR software installation.


### Frigate NVR Software

Frigate is an excellent open-source NVR solution that works well on the Raspberry Pi. It provides robust motion detection, object recognition (especially when paired with a Coral TPU), and flexible storage options.

My `config.yml` file for Frigate looks something like this:

Cloud Storage Integration with Backblaze B2

This is where the real innovation in my setup comes in. Instead of storing all footage locally (which would require significant storage space and doesn't protect against theft or damage), I integrated Backblaze B2 cloud storage.

Why Backblaze B2?

Backblaze B2 offers several advantages for this use case:

  1. Extremely cost-effective at just $5 per TB per month for storage
  2. S3-compatible API for easy integration
  3. Free egress up to 3x your average monthly storage amount
  4. No complex pricing tiers or hidden fees

Compared to AWS S3 or other providers, Backblaze B2 offers significant cost savings. For example, storing 250TB of data for a year would cost around $19,500 with Backblaze, versus $75,600 with AWS S3.

Setting Up Backblaze B2

First, I created a Backblaze B2 account and a dedicated bucket for my surveillance footage:

  1. Sign up at backblaze.com
  2. Create a new bucket (I named mine "surveillance-footage")
  3. Create an application key with access to just this bucket

Next, I needed a way to upload footage from my Raspberry Pi to B2. For this, I chose rclone, a powerful command-line tool for managing cloud storage.


With rclone configured, I created a script to upload footage to B2:

I scheduled this script to run daily using cron:


### Optimizing Storage and Bandwidth

To manage costs and bandwidth, I implemented several optimizations:

1. Only upload recordings with detected motion events
2. Keep footage locally for 24-48 hours before uploading to cloud
3. Use H.265 compression where supported by cameras
4. Configure lifecycle policies in B2 to automatically delete footage after a specified retention period

## Accessing Footage Remotely

For remote access to live streams and recordings, I set up a secure method using Wireguard VPN. This provides:

1. Encrypted access to my home network
2. No need to expose my cameras or Raspberry Pi directly to the internet
3. Ability to view live feeds and recordings from anywhere

For reviewing cloud-stored footage, I created a simple web interface that generates presigned URLs from Backblaze B2. This allows secure, temporary access to specific recordings:

Cost Analysis

One of the major benefits of this setup is the cost savings. Here's a breakdown:

Traditional NVR System

  • Dedicated 4-channel NVR: $300-500
  • Hard drives (8TB): $200
  • Maintenance/replacement: ~$100/year
  • Total first year: $600-800

My Raspberry Pi + Backblaze B2 Solution

  • Raspberry Pi 5 (8GB): $80
  • NVMe SSD (1TB): $100
  • Coral TPU: $60
  • Backblaze B2 storage (assuming 500GB/month): $30/year
  • Total first year: ~$270

The savings become even more significant over time, especially considering that commercial NVR systems often need to be replaced every few years, while the Raspberry Pi setup can be upgraded incrementally.

Challenges and Solutions

Challenge 1: Bandwidth Limitations

Streaming multiple camera feeds continuously requires significant bandwidth.

Solution: I configured cameras to use lower resolution for continuous recording (1080p) while capturing higher resolution (4K) only during motion events. Additionally, I implemented a staggered upload schedule to B2 to avoid network congestion.

Challenge 2: Power Reliability

A surveillance system needs to be reliable even during power outages.

Solution: I added a small UPS (Uninterruptible Power Supply) to keep the Pi and network equipment running during brief power outages.

Challenge 3: Managing Data Retention

Determining how long to keep footage involves balancing storage costs with potential needs.

Solution: I implemented a tiered retention policy:

  • All footage with detected objects (people, vehicles): retained for 30 days
  • Motion events without recognized objects: retained for 14 days
  • Continuous recording: retained for 7 days

Conclusion

Building a cloud-powered NVR system with a Raspberry Pi 5 and Backblaze B2 has been a rewarding project that's saved me money while providing greater flexibility than commercial alternatives. The system has been running reliably for several months now, and the ability to access historical footage from anywhere has proven invaluable on multiple occasions.

The open-source nature of this solution means I can continuously improve it as my needs change or as new technologies become available. For anyone comfortable with basic Linux administration, this approach offers an excellent alternative to traditional surveillance systems.

In the future, I plan to enhance the system with:

  • Advanced AI-based object detection using TensorFlow
  • Integration with home automation systems
  • Email/SMS alerts for specific events
  • Improved web interface for managing and reviewing footage

If you're considering building your own surveillance system, I highly recommend exploring this Raspberry Pi + cloud storage approach for its cost-effectiveness, flexibility, and scalability.

Resources

  • Pi-NVR GitHub repository
  • Frigate NVR documentation
  • Backblaze B2 documentation
  • Rclone B2 configuration guide