Repository navigation
Restoring from a sqlite backup on a new host #14969
|
I'm using the simplest-possible k3s install to run a cluster-api controller. My cluster is running on a single VM with sqlite, installed with get_k3s.sh. I'd like to back up the state of k3s (and cluster-api along with it) so that if necessary I can rebuild a new cluster with the recovered state. The backup/restore docs seem pretty trivial but I can't make it work at all. I have a small issue and a big one. Small issue: 'systemctl stop k3s' (one of the steps in several other guides I've found) leaves a ton of things around. No big thing, I can clean it all up with k3s-killall.sh, but I'm surprised that others are using a simple 'stop.' If I have a bunch of worker processes left after that, am I already in a bad state? Big issue: I can't actually restart the cluster after copying over the database backup and the token. I've tried various combinations (including starting with k3s --token instead of systemctl) but it never ends well. Here's how that looks: And the k3s logs end with: I've tried quite a few other things (starting with permissions and file mod times) but I suspect I'm missing something major. Does the recommended restore process only work for rollback on the same host? If so, what do I need to backup and restore to actually get going from nothing? |
Replies: 3 comments 5 replies
|
Oh, also, here's the script that produced those backup files in the first place: |
That is what I think I am doing. Am I not?
How can that precede copying the db dir over? That rm -rf will remove the parent dir which I am about to copy the db dir into.
That's fair, makes sense. |
Just copy the db dir over, and specify the token in the config on the new node. That's it. Do NOT copy anything else, or if you must, use a tool like rsync that can retain file modification times.
If you had previously started K3s on the node you are restoring to, you should clean that up first (just
rm -rf /var/lib/rancher/k3sif you didn't have anything in there you care about) - or it will complain that you have other, newer files present from the new cluster you created when you started it.With regards to stopping all the pods - the pods are not the cluster. If you want to cleanly stop your workloads, you should drain the node first, then run the killall script to terminate any strag…