Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restoring Backups in k8s #644

Open
kubelize opened this issue Sep 23, 2023 · 1 comment
Open

Restoring Backups in k8s #644

kubelize opened this issue Sep 23, 2023 · 1 comment

Comments

@kubelize
Copy link

kubelize commented Sep 23, 2023

Using microk8s on Ubuntu 22.04.03 LTS
Dockerimage version: latest / Digest:sha256:4e89eba8d2135ab5924ea65f551a06966a7cf34ea90e2e7434ecad6c0a21e2c0

I struggled for the last couple hours to restore a backup of a world save, These are the steps I took to restore:
Using hostpath-storage navigate to the directory where the backups are stored.

cd /path/to/hostpath-storage/valheim-valheim-server-world-data-pvc-42f60004-5d4b-491c-a805-e53f53feeb54/backup
# delete worlds_local
sudo rm -r worlds_local

# copy the zip to world_local
sudo cp worlds-20230923-140004.zip ../

# unzip
sudo unzip worlds-20230923-140004.zip

# move the contents to the correct location
cd config
sudo mv * ../

# remove directory config 
sudo rm -r config

this results in following files:

ls -lah
-rw-r--r-- 1 root root 4.9M Sep 23 16:44 ThePromisedLand.db
-rw-r--r-- 1 root root 4.9M Sep 23 16:14 ThePromisedLand.db.old
-rw-r--r-- 1 root root   56 Sep 23 16:44 ThePromisedLand.fwl
-rw-r--r-- 1 root root   56 Sep 23 16:14 ThePromisedLand.fwl.old
-rw-r--r-- 1 root root 4.9M Sep 23 15:44 ThePromisedLand_backup_auto-20230923134438.db
-rw-r--r-- 1 root root   56 Sep 23 15:44 ThePromisedLand_backup_auto-20230923134438.fwl

The expected behavior now would be that when i restart the container, that the current .db and .fwl files will be used, instead on running k delete pod valheim-server-747d78876f-xrjlb the current .db and .fwl files are overwritten and turned into .db.old and .fwl.old and new save files are generated

I assume this is a result of the server creating backups every time it is shutdown. Deleting the pod/container with k delete causes the restored backups to be overwritten, thus we need to restart the server within the container without shutting it down.

This is how i solved the problem:

  1. Delete worlds_local
  2. Delete the Container k delete pod valheim-server-747d78876f-xrjlb
  3. Execute into the new container k exec -it valheim-server-633d78834f-cjjda -- bash
  4. There should be no worlds_local directory under /config
  5. Using supervisor stop the service "valeim-server": supervisorctl stop valheim-server
  6. From your backup.zip move the directory worlds_local to the hostpath-storage directory
  7. Start the service "valheim-server": supervisorctl start valheim-server

And that's it the server will correctly start using the restored backup

I turned off the backup functionality while troubleshooting so it wouldn't continuously create new backups of the new saves on every restart, this shouldnt be necessary by following the steps described above. But if you run into difficulties you might want to try it.

@kubelize
Copy link
Author

Perhaps we could expand the Documentation to include how to restore a backup with the steps I described above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants