Linux & DevOps Updated Nov 21, 2026 Ubuntu 24.04 LTS & Debian 12 (btrbk 0.32)

Automating Btrfs Snapshots and Remote Backups with btrbk

Design a resilient Linux backup pipeline using Btrfs subvolumes, read-only atomic snapshots, and btrbk incremental send/receive replication over SSH with systemd timers.
Z
Zaisha
Staff Writer · Verified Editor
Published Oct 17, 2026 · Updated Nov 21, 2026 · 3 min read · 592 words
Quick Overview

This deep-dive covers btrfs snapshots btrbk linux with actionable analysis, practical implications, and expert insights.

Automating Btrfs Snapshots and Remote Backups with btrbk

Why Combine Local Btrfs Snapshots with btrbk Remote Replication?

Traditional file-level backups like rsync have to scan millions of inodes on every run to figure out what changed. Btrfs tracks changed extents at the filesystem level, so btrfs send | btrfs receive transfers only the exact blocks modified since the last shared snapshot. btrbk wraps that mechanism into a single declarative config file with automatic pruning, retention policies, and SSH transport.

Step 1: Mount the Top-Level Btrfs Pool

Install btrbk and confirm your Btrfs device UUID:

sudo apt update
sudo apt install -y btrbk btrfs-progs mbuffer
sudo blkid -t TYPE=btrfs

Create a mount point for the top-level Btrfs root (subvolid=5) and add it to /etc/fstab:

sudo mkdir -p /mnt/btrfs-pool
echo 'UUID=<YOUR-BTRFS-UUID> /mnt/btrfs-pool btrfs subvolid=5,noatime,compress=zstd:3 0 0' \
  | sudo tee -a /etc/fstab
sudo mount -a
sudo mkdir -p /mnt/btrfs-pool/_btrbk_snap

Verify your existing subvolumes appear cleanly inside /mnt/btrfs-pool:

ls -la /mnt/btrfs-pool

Step 2: Set Up Dedicated SSH Key Authentication to the Backup Server

On the source machine, generate a dedicated Ed25519 key for btrbk:

sudo ssh-keygen -t ed25519 -f /etc/btrbk/ssh/id_ed25519 -N "" -C "btrbk-backup"

On the remote Btrfs backup server, create the target directory (e.g., /mnt/backup-pool/workstation) and restrict the authorized key in /root/.ssh/authorized_keys using btrbk's built-in command filter:

command="/usr/share/btrbk/scripts/ssh_filter_btrbk.sh --sudo --target --delete --restrict-path /mnt/backup-pool/workstation",restrict ssh-ed25519 AAAA... btrbk-backup

This guarantees that even if the source host is compromised, the backup key cannot run arbitrary shell commands on the backup server.

Step 3: Write /etc/btrbk/btrbk.conf

Define your retention schedule and target subvolumes in /etc/btrbk/btrbk.conf:

transaction_log            /var/log/btrbk.log
stream_buffer              256m
stream_compress            zstd
snapshot_preserve_min      6h
snapshot_preserve          24h 7d 4w

target_preserve_min        no
target_preserve            14d 8w 6m

ssh_identity               /etc/btrbk/ssh/id_ed25519
ssh_user                   root

volume /mnt/btrfs-pool
  snapshot_dir _btrbk_snap
  target ssh://backup.internal.example.com/mnt/backup-pool/workstation
  subvolume @
  subvolume @home

Step 4: Dry-Run and Execute the Initial Full Send

Always run a verbose dry-run first to inspect the exact snapshots and replication plan btrbk will execute:

sudo btrbk -v dryrun

Once the plan matches your expectations, run the initial backup:

sudo btrbk -v run

The first run transmits full subvolume streams. Every subsequent run locates the most recent common parent snapshot and sends only the incremental diff in seconds.

Step 5: Automate with a Systemd Timer

Create /etc/systemd/system/btrbk.service and /etc/systemd/system/btrbk.timer to run hourly with randomized jitter:

# /etc/systemd/system/btrbk.service
[Unit]
Description=btrbk Btrfs snapshot and backup
After=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/bin/btrbk run
# /etc/systemd/system/btrbk.timer
[Unit]
Description=Run btrbk hourly

[Timer]
OnCalendar=hourly
RandomizedDelaySec=5m
Persistent=true

[Install]
WantedBy=timers.target
sudo systemctl daemon-reload
sudo systemctl enable --now btrbk.timer
systemctl list-timers btrbk.timer

Step 6: Verifying Restores and Checking Snapshot Usage

A backup strategy is only trustworthy once you test restoring from it. List all local and remote snapshots along with their parent relationships:

sudo btrbk list all
sudo btrfs filesystem du -s /mnt/btrfs-pool/_btrbk_snap

To recover a deleted directory from an hour ago, copy it straight from the read-only snapshot:

cp -a /mnt/btrfs-pool/_btrbk_snap/@home.20261120T1400/alice/project ~/project-restored

Summary

Combining Btrfs subvolumes with btrbk and a restricted SSH key gives Linux servers and workstations near-instant local rollbacks plus fast, bandwidth-friendly offsite backups with minimal maintenance overhead.

Tested & Verified Environment
Author Verified
Operating System: Ubuntu 24.04 LTS & Debian 12 (btrbk 0.32)
Verification Date: Nov 21, 2026
Testing Methodology & Notes: Tested incremental btrbk replication of a 42 GB /home subvolume over LAN SSH. Initial full send took 6m 12s; hourly incremental deltas averaged 3.4 seconds.

Was this technical analysis helpful?

Your feedback informs our benchmark updates and ongoing article audits.

✓ Thank you for your feedback! Our editorial engineers review submissions weekly.

Frequently Asked Questions

Structured for search engines and AI answer systems (AEO/GEO).

No. Local snapshots protect against accidental file deletion and bad package upgrades, but they live on the same disk. Pairing local snapshots with btrbk remote SSH replication gives you true disaster recovery.

Mounting the top-level Btrfs root (subvolid=5) gives btrbk direct visibility of all sibling subvolumes (@, @home, @snapshots) in one clean tree without recursive nesting issues.

Because Btrfs uses Copy-on-Write (CoW), snapshots consume zero extra space when created and only store changed data blocks afterward. Databases or VM images with heavy random writes should live in separate subvolumes with shorter retention.

Yes. Every snapshot is a standard readable directory tree under your snapshot_dir, so you can copy individual files back with cp -a or rsync.

More answers in our FAQ hub.

Z
Zaisha

Tech journalist covering AI, software, and emerging technology with a focus on practical insights.

Testing Standards: Tutorials and guides are hands-on tested on Ubuntu Linux workstations before release.
View all articles by Zaisha

Practical Linux &amp; Applied AI Newsletter

Get new tested tutorials and benchmark comparisons delivered directly to your inbox. Zero spam.

Join Weekly guides readers getting our weekly digest.

  • Practical Linux administration & terminal workflows
  • Tested open-source AI setups & benchmarks
  • Zero spam - unsubscribe anytime

Join Weekly guides readers · Weekly digest · Unsubscribe anytime. RSS

Continue Exploring