Running a FreeNAS‑style Backup Server with rsync and Snapshots on a Raspberry Pi 4
If you’ve ever wanted a tiny, energy‑efficient NAS that still gives you snapshots and incremental sync, the Pi 4 is a solid choice. I’ve set up a few of these in my own home lab, and they’re surprisingly robust. Below is the walk‑through I use, with a few practical tweaks that keep things running smoothly.
Why this stack?
- rsync is the workhorse for incremental copies; it’s built into almost every distro and keeps permissions, timestamps, and ownership intact.
- btrfs (or ZFS‑on‑Linux if you’re adventurous) gives you instant, copy‑on‑write snapshots that are cheap in space and fast to roll back.
- The Pi 4’s 4 GB RAM and single‑GbE port are plenty for a handful of clients and a few hundred gigabytes of data.
- All tools are free, and the Pi can run headless – SSH is all you need, but if you’re a GUI fan, Webmin or Cockpit is an option.
Hardware checklist
| Item | Minimum | Recommendation |
|---|---|---|
| Raspberry Pi | 4 B (any revision) | 4 B + USB‑3.0 HAT |
| Storage | 1 TB HDD/SSD (USB‑3.0) | 2 TB SSD for speed |
| Power | 5 V 3 A | 5 V 3 A USB‑C |
| Network | 1 GbE | 1 GbE or 2.5 GbE via USB‑3.0 HAT |
A USB‑3.0 HAT gives you a real 5 Gbps link to your drives, which keeps rsync throughput high. I’ve seen the Pi choke on 100 Mbps when you only use the on‑board Ethernet.
Install the OS
Grab the latest Raspberry Pi OS Lite (Debian 12). After boot, update and install the packages you’ll need:
sudo apt update && sudo apt upgrade -y
sudo apt install rsync btrfs-progs
If you want ZFS instead, install zfsutils-linux. Just remember that ZFS on ARM is still a bit experimental.
Create a btrfs pool
sudo mkfs.btrfs -f /dev/sda1
sudo mkdir /mnt/backup
sudo mount /dev/sda1 /mnt/backup
Persist it in /etc/fstab:
/dev/sda1 /mnt/backup btrfs defaults,autodefrag,compress=lzo 0 0
The autodefrag and compress=lzo options keep the filesystem healthy without a huge CPU hit.
Snapshot policy
I run a simple cron job that takes a daily read‑only snapshot and keeps the last seven:
sudo crontab -e
Add:
0 3 * * * /usr/bin/btrfs subvolume snapshot -r /mnt/backup /mnt/backup/backup-$(date +\%Y\%m\%d)
0 4 * * * /usr/bin/find /mnt/backup/backup-* -mtime +7 -exec rm -rf {} \;
The -r flag protects snapshots from accidental writes. I schedule the cleanup an hour later so the snapshot is fully created before I start deleting old ones.
rsync server setup
Create /etc/rsyncd.conf:
sudo nano /etc/rsyncd.conf
uid = nobody
gid = nogroup
use chroot = no
max connections = 5
timeout = 300
[backup]
path = /mnt/backup
comment = Pi Backup
read only = no
auth users = backupuser
secrets file = /etc/rsyncd.secrets
Add a password:
echo "backupuser:raspberry" | sudo tee /etc/rsyncd.secrets
sudo chmod 600 /etc/rsyncd.secrets
Enable and start the daemon:
sudo systemctl enable rsync
sudo systemctl start rsync
Clients can now sync with:
rsync -avz --delete [email protected]::backup /home/user/backup
The --delete flag keeps the destination a mirror of the source – handy for backups.
Security considerations
- Use a dedicated, strong‑password user (
backupuser). - Restrict the daemon to your local network: add
hosts allow = 192.168.1.0/24torsyncd.conf. - Prefer SSH key authentication for any remote clients that need to run rsync over SSH instead of the daemon.
Troubleshooting tips
| Symptom | Likely cause | Fix |
|---|---|---|
rsync: connection unexpectedly closed |
Firewall blocking port 873 | sudo ufw allow 873/tcp |
| Snapshots not appearing | btrfs not mounted read‑only | Verify mount options in /etc/fstab |
| Disk space runs out | Snapshots not pruned | Check cron log /var/log/cron |
Scaling up
If you need more storage, just plug in another USB drive and create a btrfs RAID‑1 or RAID‑10 pool:
sudo mkfs.btrfs -f /dev/sdb1 /dev/sdc1
sudo mount -o defaults,autodefrag,compress=lzo /dev/sdb1 /mnt/backup
The Pi will handle parity calculations; performance will dip compared to SSD, but it’s still fine for a home setup.
See also
- Rootless Podman: How I Got My Home Directory Synced to a Container Volume
- Setting up a Home NAS with Docker, NFS, and SMB – A Hands‑On Guide
- Running a Rootless Podman Web App with Persistent Volumes on Ubuntu
- Why My Home Assistant Timer Never Fires—and How to Fix It
- Fixing a Broken /etc/hosts When systemd‑resolved Hides It