Status, rollback and destroy

Once a machine exists, three verbs cover the rest of its life. Only one of them is read-only, so learn which.

Status: what's there, and what drifted

sg machine status --config node-a.yaml

status compares the ledger with the host and reports recorded state, drift and when each change was last applied. It never repairs anything, and a report that shows drift still exits 0. Use it in scripts without fear.

When it shows drift, run sg machine plan to see what create would do about it, then decide.

Rollback: undo the last run

sg machine rollback --config node-a.yaml

Rollback undoes the most recent run's changes in reverse order, using what the ledger captured before each change ran. It shows the plan and asks Roll back N changes on node-a? [y/N].

FlagDoes
--allSelect every currently applied change, not just the last run's
--forceSkip changes that are named as irreversible. It never skips a safety or ownership check
--yesApprove the shown plan without asking

Rollback never removes storage.zfs or install.lxd. They hold your instances' data. Only destroy takes those away.

Destroy: take it all back

sg machine destroy --config node-a.yaml

Destroy tears down every artifact the ledger says sg created, in reverse order. The plan spells out the damage before it asks:

Destroy plan for node-a — teardown in reverse order, sg-owned artifacts only:

  1  install.lxd        undo 3 recorded artifact(s)
       data loss: instance shop-web-0 and its snapshots will be deleted
  …
warning: destroy deletes sg-owned data, including recorded instances and the pool file.
FlagDoes
--with-packagesAlso remove packages sg installed. Kept by default, because other software may use them
--yesApprove the shown plan without asking

When it finishes:

run <run-id> finished: ok. 7 changes reverted.

verify.isolation holds no state, so destroy never selects it. Anything it can't prove it owns is listed as retained and left alone. If destroy fails partway, it stops and tells you to investigate before re-running. It never recreates deleted data to try again.

Cluster members can't be destroyed directly

If the machine is a recorded member of a cluster, destroy refuses:

the machine is a member of a registered cluster

Tear the cluster down with sg cluster destroy --with-machines instead. See Form a cluster.

What each one keeps

CommandRemovesKeeps
sg machine rollbackThe last run's reversible changesZFS pool, LXD, anything sg didn't create
sg machine destroyEvery recorded sg artifact, including instances and the pool filePackages (unless --with-packages), anything sg didn't create

Known gap

destroy skips a change whose verification failed. So if install.lxd failed its check, a later destroy won't tear down that half-installed LXD. Clean it up by hand, or run create again until it verifies and then destroy.