Skip to content

Lesson 8 of 9 · 25m

Boot Environments, Backups, and Recovery Reality

Use ZFS boot environments and snapshots to survive upgrades while understanding what still requires real backups, rehearsal, and console access.

Recovery is where architecture stops being theoretical. FreeBSD with ZFS gives you boot environments, cheap snapshots, replication, and clear system boundaries. None of those excuse a missing restore test. The correct question is not 'do we have backups?' It is 'which failure do we survive, at what recovery point, with which manual steps?'

Boot environments are rollback for the operating system

A boot environment is a bootable ZFS dataset snapshot/clones arrangement for the OS itself. Tools such as bectl or bectl-compatible workflows manage them:

bectl list
bectl create before-upgrade
bectl activate before-upgrade

The operational pattern is simple: create a boot environment before major system mutation, upgrade, validate, and roll back if the boot or base userland is broken. It does not roll back your database state unless that state lives in the affected datasets and your design says so. Know exactly what is inside the rollback boundary.

Snapshots answer logical mistakes

Deleting the wrong application directory, corrupting local configuration, or applying a bad upgrade often maps well to snapshot rollback. But rollback is destructive in the other direction: changes after the snapshot are discarded. For live data, exporting or copying the needed files from a snapshot may be safer than rolling back an entire dataset.

zfs snapshot tank/app@pre-deploy
ls /tank/app/.zfs/snapshot/pre-deploy/

The .zfs snapshot directory can be a surgical recovery tool when visible. It is also a data exposure path if permissions and snapshots are designed carelessly.

Replication answers loss, not corruption alone

zfs send replication to another pool or host protects against device and host loss. But if corruption is logical — deletion, bad deployment, ransomware-like overwrite — replication faithfully copies the mistake unless snapshots and retention are preserved on the receive side. Backup design is therefore about independent snapshot histories, immutable windows, and restore isolation.

Recovery requires names, order, and credentials

Write the restore runbook as if the primary operator is unavailable:

1. Identify target host, pool, dataset, and desired snapshot.
2. Verify receive-side capacity and encryption keys.
3. Restore into a scratch dataset first.
4. Validate application configuration paths and ownership.
5. Promote or mount only after checksums and application checks pass.

Credentials matter. Encryption keys, SSH access to backup hosts, cloud console credentials, and bootstrap secrets cannot live only inside the system they are supposed to restore.

Console access is part of backup strategy

A perfect snapshot does not help if a bad PF rule, SSH configuration, or network change means nobody can reach the machine. Before risky upgrades, verify provider console access, serial console behavior, or out-of-band management. Test it before the outage. The middle of an incident is a terrible time to discover that the console user is deprecated.

Rehearsal is the control

Restoration should be rehearsed on non-production hosts or isolated jails. Measure how long it takes, which steps are manual, and where documentation diverges from reality. A backup system that restores once a quarter is technology; a backup system that only worked in a design document is folklore.

Field notes

  • Boot environments protect the OS boundary; do not silently assume they include application data.
  • Keep backup encryption keys outside the blast radius of the primary host.
  • zfs rollback can discard valid work; prefer surgical copies when uncertain.
  • Alert on failed replication jobs, not merely on missing backup files.

Was this lesson helpful?

Sign in to rate