Webux Lab - Blog
Webux Lab Logo

Webux Lab

By Studio Webux

Search

By Tommy Gingras

Last update 2026-02-28

KubernetesLinuxDocker

Backing Up a k3s Single Node

The SQLite database is only one piece of the puzzle. A complete backup requires three things: the cluster state, the persistent volume data, and any other stateful data your workloads depend on.

Cluster State (SQLite)

k3s stores its state in a SQLite database at /var/lib/rancher/k3s/server/db/state.db.

sudo dnf install sqlite
sudo mkdir /backup/
sudo sqlite3 /var/lib/rancher/k3s/server/db/state.db ".backup '/backup/state-$(date +%F).db'"

The .backup command produces a consistent snapshot even while k3s is running — SQLite handles the locking internally.

Persistent Volumes

By default, k3s uses the local-path provisioner, which stores PVC data under /var/lib/rancher/k3s/storage/. Back it up with:

sudo tar -czf /backup/pvc-$(date +%F).tar.gz /var/lib/rancher/k3s/storage/

If your workloads use a different storage path or a custom StorageClass, adjust accordingly. Check where your PVCs are bound:

kubectl get pv -o wide

Other Persistent Data

Any data mounted from the host via hostPath volumes must be backed up separately — k3s has no knowledge of it. Identify those paths in your manifests and include them in your backup routine.

Copy to a Local Machine

scp one.webux.dev:/backup/state-2026-02-28.db ./
scp one.webux.dev:/backup/pvc-2026-02-28.tar.gz ./

Restore

sudo systemctl stop k3s
sudo cp state-2026-02-28.db /var/lib/rancher/k3s/server/db/state.db
sudo tar -xzf pvc-2026-02-28.tar.gz -C /
sudo systemctl start k3s