Restoring a deleted ConfigMap from a NAS backup of the K3s datastore
I deleted a test ConfigMap and recovered it from the Restic snapshot on the NAS.
I wanted proof that the K3s backup on my NAS could bring something back, before I trusted it with anything real.
Single-node K3s keeps its state in an SQLite database. So the drill went like this:
- Create a test ConfigMap called
backup-drill-20261017, with a value I could look for later. - Run the backup script. It takes an online SQLite
.backupofstate.db, checks it withPRAGMA integrity_check(it saidok), and copies the K3s config, server token, encryption config and TLS files. - Send all of that to the NAS as an encrypted Restic snapshot. It was 52 files, 12.9 MiB, and 2.6 MiB after compression.
- Delete the ConfigMap from the live cluster.
- Restore the snapshot from the NAS into a temp folder and query the
kinetable in the restoredstate.dbfor the ConfigMap’s key.
It was there:
RESTORE DRILL PASSED: recovered /registry/configmaps/default/backup-drill-20261017This proves the data comes back from the NAS. It doesn’t yet prove a full cluster rebuild from that file. That’s a bigger drill, and I want to do it before I depend on this.
How do you test K3s restores? Do you rebuild a whole node, or check the datastore like this?
Recipes written later from this work: