Replies: 20 comments 3 replies
-
It sounds like the ultimate goal is for the backup/restore process to be dead simple. At this point, is all state that can't be regenerated automatically stored in SQLite or is there important state elsewhere? |
Beta Was this translation helpful? Give feedback.
-
The video from the meetup yesterday answers my question, and it sounds like all important state is indeed stored in SQLite:
If that's the case, a cron job regularly running |
Beta Was this translation helpful? Give feedback.
-
That's great. But the slqlite should switch to etcd in HA mode, and can use etcd snapshot to do this. |
Beta Was this translation helpful? Give feedback.
-
Since we use sqlite and maybe etcd in the future it might be nice to have a solution which doesn't depend on implementation. I was trying to find a backup solution that might just use shell scripts and kubectl, not sure of the feasibility of something like that tho. |
Beta Was this translation helpful? Give feedback.
-
So to confirm, cluster state backups are essentially just backing up /var/lib/rancher/k3s/server/db/state.db? I have file/database backups, but my database backup solution (KubeDB) requires that the database superuser credentials are identical for WAL restores, and those are autogenerated and stored in secrets. So I need some way of keeping those secrets around if I have to restore backups, and I'd rather just let them be autogenerated and leave them in-cluster than manage them myself. Thanks. |
Beta Was this translation helpful? Give feedback.
-
This issue is a bit old now, I'm wondering if things changed. Can we get some pointers about the current recommended method of backing up/restoring a k3s environment? Thanks! |
Beta Was this translation helpful? Give feedback.
-
I’d like to reset k3s without having to download the container images again. So beyond the database, I'm not sure which directories should also be restored after a reinstall. I have a single master+agent server. |
Beta Was this translation helpful? Give feedback.
-
With some investigation, it appears restoring the I looked through containerd folders and note that the image blobs are here: /var/lib/rancher/k3s/agent/containerd/io.containerd.content.v1.content However, deleting the other folders inside /var/lib/rancher/k3s/agent/containerd MountVolume.SetUp failed for volume "cert-manager-cainjector-token-92bgb" : failed to sync secret cache: timed out waiting for the condition followed by a Pulling image event. This is unfortunate as I'd like to use k3s in a low-bandwidth location and pulling images constantly is painful. @ibuildthecloud do you have any recommendations or should I just be snapshotting the entire "/var/lib/rancher/k3s" folder? In my mind I should only need to backup the blobs and the database in order to revert back to a working state with minimal downloads but doesn't appear that way. |
Beta Was this translation helpful? Give feedback.
-
@brandonkal this isn't really a backup/restore issue, but it sounds like you want the airgap install option with pre-downloaded images. |
Beta Was this translation helpful? Give feedback.
-
At least there needs to be documentation on how to backup k3s cluster state. It could be really simple, it just needs to be documented! |
Beta Was this translation helpful? Give feedback.
-
What other files should be backed up aside from the db?
Can anyone confirm? |
Beta Was this translation helpful? Give feedback.
-
As information/inspiration, k0s has such feature: https://docs.k0sproject.io/v1.21.2+k0s.0/backup/ |
Beta Was this translation helpful? Give feedback.
-
@eranyanay @VladimirAkopyan @brandond For information I have tested an approach to backup and restore the sqlite DB and documented it here. The naive approach saves most of the server directory. But it works even though I tested restoring to a x86 VM instead of the arm64 metal master that did the backup. |
Beta Was this translation helpful? Give feedback.
-
Generally, it is not recommended to backup files of a database as consistency is not guaranteed. A dump could be better. |
Beta Was this translation helpful? Give feedback.
-
Good point. I'll update the script to tar the files except the db and then dump the db. |
Beta Was this translation helpful? Give feedback.
-
Changing this over to a discussion as it's more of a question than an issue. |
Beta Was this translation helpful? Give feedback.
-
Maybe k3s team could consider building in native Litestream support (for both backup and restore)? Currently our approach is to back up static files In case of k3s node redeployment, oneshot script will restore static files with |
Beta Was this translation helpful? Give feedback.
-
Some clarity on this would be awesome in the docs. I'm trying to setup backup for my home server, for example, and it's not clear to me if I can safely exclude the containerd directories, which would be nice given the rather large size of the overlayfs directories. |
Beta Was this translation helpful? Give feedback.
-
That's it, that's all you should need. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi
I am looking for backup/restore procedure in the docs and cannot find one
any help here?
Beta Was this translation helpful? Give feedback.
All reactions