Skip to content

Tutorial

Disaster recovery in the lab

In this tutorial, the lab loses all etcd data of a cluster and gets it back from a snapshot. The task mise run lab:backup-restore does the steps. You watch them and examine the result.

Lose etcd and restore it

1 / 6

A snapshot goes from etcd to the backup volume. After the data loss, an approved operation uploads the snapshot back to etcd.Youetcdcontrol plane node-1HostOperationetcdRecoverSnapshotencrypted with agedr-beforedr-aftersnapshotapprovesuploadrecover

Back up

The operator takes an etcd snapshot, encrypts it for your age key and stores it on its backup volume.

pk-metal backup now lab-dr
  1. Back up. The operator takes an etcd snapshot, encrypts it for your age key and stores it on its backup volume.

    pk-metal backup now lab-dr
  2. Write after the snapshot. The task writes a second ConfigMap. The snapshot does not contain it.

    kubectl create configmap dr-after
  3. Lose etcd. The task wipes the partition EPHEMERAL on each control plane. The cluster reports EtcdDataLost. The operator does not bootstrap it again.

    talosctl reset --system-labels-to-wipe EPHEMERAL
  4. Propose and approve. One person proposes the restore. A person approves it.

    pk-metal restore plan --snapshot <name> --propose lab
  5. Upload. You decrypt the snapshot on the workstation and send it to the node.

    pk-metal restore upload <operation> --identity identity.txt
  6. Recovered. etcd starts from the snapshot. The first ConfigMap is back. The second ConfigMap is not.

    kubectl -n default get configmaps
  • An EtcdBackupPolicy and one verified EtcdSnapshot.
  • A cluster that lost its etcd data and came back from the snapshot.
  • Proof of the result: an object from before the snapshot is back, and an object from after it is not.
Time
About 30 minutes.
Before
Your first cluster in the lab
Lab
Down. Step 1 starts a lab with one control plane, which is the quickest.
  1. If a lab runs, stop it and delete the disks.

    Terminal window
    mise run lab:down && mise run lab:reset
  2. Start the lab and install the cluster.

    Terminal window
    PK_LAB_NODES=1cp+0w mise run lab:up
    mise run lab:wait
  1. Open the live view in a second terminal.

    Terminal window
    mise run lab:top
  2. Start the round in the first terminal.

    Terminal window
    mise run lab:backup-restore
  3. Follow the parts in the output.

mise run lab:backup-restoreexample
$ mise run lab:backup-restore
== etcd backup volume
== EtcdBackupPolicy lab-dr, a snapshot, and markers around it
configmap/dr-before created
configmap/dr-after created
== losing etcd: wiping EPHEMERAL on every control plane of lab
  the operator sees the loss and does not bootstrap: ...
== restoring lab-dr-manual-20260115-101502
== waiting for lab-etcd-recover-node-1 and for etcd
  [2026-01-15 10:19:04 UTC] lab-etcd-recover-node-1 Running: ...
restored after 412s: lab is Bootstrapped from lab-dr-manual-20260115-101502; dr-before is back, dr-after is not
A replay with example data. The names of the snapshot and the operation are different in your lab.
Part in the output What happens Reference
etcd backup volume The manager gets a volume for snapshots. Manager
EtcdBackupPolicy lab-dr, a snapshot, and markers around it The task makes an age key and a policy. It writes dr-before, takes a snapshot, and writes dr-after. pk-metal backup
losing etcd talosctl reset wipes EPHEMERAL on the control plane. The TalosCluster reports EtcdDataLost. TalosCluster
restoring <snapshot> The user lab-restorer proposes the restore. The admin approves it. The task uploads the snapshot. pk-metal restore
waiting for <operation> and for etcd The operation with EtcdRecover runs. etcd starts from the snapshot. HostOperation
  1. Show the ConfigMaps in the restored cluster.

    Terminal window
    kubectl --kubeconfig .lab/workload.kubeconfig -n default get configmaps

    dr-before is in the list. dr-after is not.

  2. Show the snapshots.

    Terminal window
    metal/bin/pk-metal --kubeconfig .lab/kubeconfig backup list lab
  3. Show the restore operation. Its phase is Succeeded.

    Terminal window
    kubectl --kubeconfig .lab/kubeconfig -n pk-metal get hostoperations
  4. Examine the files that the task kept.

    Terminal window
    ls .lab/backup-restore/
    File Contents
    identity.txt The age identity. Only this key can decrypt the snapshot.
    snapshot.db.age The encrypted snapshot
    restorer.kubeconfig The kubeconfig of the user lab-restorer

If a step does not give its checkpoint, see Lab troubleshooting.

  • The operator sees the loss of etcd data, and it does not bootstrap the cluster again without a person.
  • A restore needs two persons and an approval, as each other change does: Approval.
  • The operator stores only encrypted snapshots. You keep the key.
  • A restore brings back the state of the snapshot. You lose later changes.