--- title: Snapshot, roll back and replicate data datasets with zfs; leave BEs to beadm area: zfs impact: HIGH tags: [zfs, snapshot, rollback, send, receive, holds, backup] verified: 2026-11-04 --- # Snapshot, roll back and replicate data datasets with zfs; leave BEs to beadm `zfs snapshot`, `zfs rollback` and `zfs send | zfs receive` work on Solnix exactly as on illumos. Two things to watch: `zfs rollback -r` destroys every newer snapshot, so confirm with the user first; and the snapshots under `/ROOT` belong to boot environments, so manage those with `beadm`, not `zfs`. **Antipattern** ```sh # do not run these; the first two discard data pfexec zfs rollback -r rpool/db@monday # silently destroys @tuesday and every later snapshot pfexec zfs rollback rpool/ROOT/solnix-3@x # a BE dataset by hand: use beadm or solnix-rebuild rollback pfexec zfs send rpool/db@b | ssh backup-host zfs receive tank/backup/db # full stream onto an existing target ``` **The Solnix way** ```sh pfexec zfs snapshot -r rpool/db@a # -r: every child too, all at one moment zfs list -t snapshot -o name,creation -r rpool/db ls "$(zfs get -H -o value mountpoint rpool/db)/.zfs/snapshot/a" # read old files without a rollback pfexec zfs hold keep rpool/db@a # zfs destroy of @a now fails with EBUSY zfs holds rpool/db@a; pfexec zfs release keep rpool/db@a # replicate: a full stream first (the target must not exist, its parent tank/backup must), then incrementals # (the target must exist) pfexec zfs send rpool/db@a | ssh backup-host pfexec zfs receive tank/backup/db pfexec zfs snapshot rpool/db@b pfexec zfs send -i @a rpool/db@b | ssh backup-host pfexec zfs receive tank/backup/db # -I @a: every snapshot between # ask the user before any of these: a rollback discards every change since the snapshot (the ZFS Administration # Guide says the dataset is unmounted and remounted: see Unverified); zfs receive -F rolls the target back, and an # incremental replication stream (send -R -i/-I) destroys the target's snapshots the sender no longer has # (zfs(8) receive; with -F also its file systems; the ZFS Administration Guide says destroys need -F: confirm either way) pfexec zfs rollback rpool/db@b # refused unless @b is the newest snapshot pfexec zfs rollback -r rpool/db@a # -r destroys @b and any newer snapshots and bookmarks; -R clones # a recursive snapshot (snapshot -r) is not rolled back recursively: roll back each child's snapshot on its own ``` Use this on `/home` and datasets you made; for `/var/` see Unverified. For a BE use beadm: `pfexec beadm create solnix-3@before-test` and `beadm list -s`. To boot such a snapshot, make a BE from it with a name outside `solnix-N` (`pfexec beadm create -e solnix-3@before-test before-test`, beadm(8) Example 4): a hand-made `solnix-N` is destroyed without a prompt when `boot` or `switch` creates generation N (default.nix `do_boot`). Any BE not marked R is also a candidate for `solnix-rebuild rollback` (be-generations-and-rollback.md), so delete such a BE when you are done with it (ask first). **The illumos way** (OpenIndiana, OmniOS, SmartOS) ```sh zfs snapshot pool/home/bob@yesterday zfs rollback -r pool/home/anne@yesterday # zfs(8) Example 8: deletes all intermediate snapshots (confirm first) zfs send pool/fs@a | ssh host zfs receive poolB/received/fs@a zfs send -i a pool/fs@b | ssh host zfs receive poolB/received/fs ``` Same commands. On illumos, BE snapshots are also created and rolled back with `beadm`, which acts on every dataset of a BE at once. **The difference.** Same as illumos for data datasets. On Solnix every generation is a BE, and `beadm create` makes each one by snapshotting the source root and cloning it; those snapshots sit under `/ROOT` and cannot be destroyed while the clone exists. To go back to an older system, activate an older BE (`solnix-rebuild rollback`), and do not `zfs rollback` a BE dataset. **Check.** On the receiving side, `zfs list -t snapshot -r tank/backup/db` lists `@a` and `@b`. **Unverified** - Whether a rollback of a `/var/` dataset works while services hold files open there: the ZFS Administration Guide says a rollback fails if the dataset cannot be unmounted; the current zfs(8) does not say rollback unmounts. Not measured on Solnix. **Sources** - [modules/system/activation/default.nix](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/modules/system/activation/default.nix) (solnix 5a8e5ce), `do_boot` (`beadm destroy -f -F` an existing `solnix-N`); `solnixRebuild` rollback - [zfs(8)](https://solnix.io/docs/man/zfs.8) (illumos, CDDL), Snapshots; Clones; zfs snapshot -r; zfs rollback -Rfr; zfs send -i, -I, -R; zfs receive -F, -n, -v; zfs hold, holds, release; Examples 2, 8, 12 - [ZFS Administration Guide: Working With ZFS Snapshots and Clones](https://illumos.org/books/zfs-admin/snapshots.html) (PDL), 6.1.3 Rolling Back to a ZFS Snapshot (unmount and remount); Saving and Restoring ZFS Data (full stream needs no target; incremental needs one) - [Handbook: ZFS storage](https://solnix.io/docs/handbook/zfs#snapshots) (site 307b67f), Snapshots; `send` / `receive` — replication and backup; How this ties to boot environments - [Handbook: ZFS boot environments](https://solnix.io/docs/handbook/boot-environments#snapshots-and-bes) (site 307b67f), Snapshots and BEs - [beadm(8)](https://solnix.io/docs/man/beadm.8) (illumos, CDDL), create beName@snapshot; create -e beName@snapshot; list -s; rollback; Examples 3, 4 - [docs/design-var-state.md](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/docs/design-var-state.md) (solnix 5a8e5ce), The layout (`/home`, `/var/` outside the BE) - [docs/design-generations.md](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/docs/design-generations.md) (solnix 5a8e5ce), §0 The model (rollback = `beadm activate`) - [OpenIndiana handbook: Managing Boot Environments](https://docs.openindiana.org/handbook/getting-started/#managing-boot-environments), Features of the beadm utility