Backups and Restores
Page not available in that version
The current page Backups and Restores doesn't exist in version 1.6.2 of the documentation for this product.
Overview
Every run takes a backup before it changes anything, and acd-deploy backup takes one without changing anything. Each backup is a folder under /var/lib/acd/backups on the first server: see the acd-deploy reference for its files. A run never deletes a backup: delete old ones from the Backup tab, or remove the folders yourself.
The Backup tab lists each backup with when it was taken, the release, the machines, the etcd snapshot, its size, what took it, and any PostgreSQL dumps it holds.
Important: Treat backups as secret material. A backup of a running cluster holds an etcd snapshot of the whole cluster, which contains every Kubernetes Secret: database passwords, the Zitadel master key and TLS keys among them. Every machine’s archive, servers’ and agents’, also holds the cluster token, and the servers’ hold the cluster-admin kubeconfig,
/etc/rancher/k3s/k3s.yaml. The PostgreSQL dumps are not encrypted and hold the databases’ contents. Keep backups, and any copies you make, readable only by root, and delete the ones you no longer need.
Keep a copy of the latest backup folder off the first server, so that losing it does not lose the configuration acd-deploy needs. Protect the copy as the warning above describes.
Before relying on a backup, check it:
cd /var/lib/acd/backups/<folder>
sha256sum -c SHA256SUMS
What a Backup Does Not Include
A backup holds each machine’s configuration and, on a running cluster, an etcd snapshot of the Kubernetes state. It does not include:
- PostgreSQL data, unless the backup was taken with the PostgreSQL dump: see PostgreSQL Dump.
- Longhorn volumes: the contents of the cluster’s persistent volumes, such as Kafka’s messages and the metrics. See Longhorn Volume Backups.
- An etcd cluster reset: the snapshot is archived, but restoring a machine does not roll the cluster back. That is the manual procedure in Rolling Back the Cluster.
- The TLS certificate and key, in
certs/, and the MaxMind databases, inmaxmind/. Keep your own copies. - The operating system, its packages and anything else on the machines.
Restoring a backup puts a machine’s configuration back; it cannot recover lost data.
PostgreSQL Dump
A plain run or backup does not dump the PostgreSQL databases, so that a large database does not slow every run. Take a backup with the dump by running acd-deploy backup --postgres, or press p on the Backup tab, which shows the same sizes and the command, then asks for confirmation. PostgreSQL Backup is the procedure, and PostgreSQL Restore puts a dump back.
Restoring a Machine
On the Backup tab, select a backup and press ⏎. Pick the machine with j and k. The confirmation shows every command it will run, in order, and what the backup does not include. On y, acd-deploy:
- checks the backup’s archives against
SHA256SUMS; - copies the machine’s archive and checksum file to
/var/tmpon the machine; - extracts the archive with SELinux labels, extended attributes and ACLs, and checks every file against its checksum;
- removes the copies from
/var/tmp, since the archive holds the cluster token; - restarts NetworkManager and k3s on the machine, as a service of its own so that a dropped SSH session does not stop it, and waits until the machine answers again.
It restores one machine at a time.
To restore a machine by hand, copy its archive and checksum file to it, then, as root:
tar --selinux --xattrs --acls -C / -xpzf <machine>.tar.gz
sha256sum -c <machine>.files.sha256
Keep the --selinux --xattrs --acls options: plain tar restores some k3s files with the wrong SELinux label. Then reboot the machine, or restart NetworkManager and k3s.
Rolling Back the Cluster
Rolling back the cluster itself also needs the etcd snapshot, restored on one server with the k3s cluster-reset procedure: stop k3s on every server, restore that server’s archive, run k3s server --cluster-reset --cluster-reset-restore-path=<snapshot path> on it, start k3s there, and rejoin the other servers. See the k3s etcd snapshot documentation for the full procedure.
Deleting Backups
On the Backup tab, select a backup and press d. The confirmation shows the folder it removes, for good, and warns when it is the newest backup or the only one. Or remove the folder yourself:
rm -r /var/lib/acd/backups/<folder>
The etcd snapshot is also kept in /var/lib/rancher/k3s/server/db/snapshots on the server that took it, named acd-backup-<UTC time>-<machine>-<number>, and deleting a backup folder does not remove it there. List and delete old ones on that server with:
k3s etcd-snapshot list
k3s etcd-snapshot delete <name>
k3s also takes its own etcd snapshots, in the same folder on every server, named etcd-snapshot-<machine>-<time>: one every 12 hours, keeping the latest five, which k3s prunes itself. They hold every Kubernetes Secret too, so treat them, and any copy of them, as secret material.