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

How to update your Valheim Server #22

Closed
apertureless opened this issue Feb 17, 2021 · 25 comments
Closed

How to update your Valheim Server #22

apertureless opened this issue Feb 17, 2021 · 25 comments

Comments

@apertureless
Copy link

@apertureless apertureless commented Feb 17, 2021

Maybe a silly question but, how can the server (valheim server) be updated? Currently there is a new clent + server version released

@Nimdy
Copy link
Owner

@Nimdy Nimdy commented Feb 17, 2021

ssh into your Ubuntu VM

1. Stop the Valheim Server Service (MUST DO FIRST)

sudo systemctl stop valheimserver.service

wait 1-2 mins

2. Make a copy of your Valheim World Data Files

*Example: WorldNameFile.db

cp /home/steam/.config/unity3d/IronGate/Valheim/worlds/WorldNameFile.db /home/steam/.config/unity3d/IronGate/Valheim/worlds/WorldNameFile.dbGood

*Example: WorldNameFile.fwl

cp /home/steam/.config/unity3d/IronGate/Valheim/worlds/WorldNameFile.fwl /home/steam/.config/unity3d/IronGate/Valheim/worlds/WorldNameFile.fwlGood

*This will now create a 1:1 copy of WorldNameFile.(db/fwl) into WorldNameFile.(db/fwl)Good

3. Start the Valheim Server Service

sudo systemctl start valheimserver.service

wait 1 -2 mins

4. Connect like normally

@Nimdy Nimdy changed the title How to update? How to update your Valheim Server Feb 17, 2021
@apertureless
Copy link
Author

@apertureless apertureless commented Feb 17, 2021

I'll leave the issue open, for others to find.

@siamgo
Copy link

@siamgo siamgo commented Feb 17, 2021

Thanks great help, i was just looking for this bacause of the new version :)

@aburakayaz
Copy link

@aburakayaz aburakayaz commented Feb 17, 2021

I'm thankful but I really don't understand, does it auto-update itself after I stop it? How exactly does it work?

@Nimdy
Copy link
Owner

@Nimdy Nimdy commented Feb 17, 2021

No it updates when you restart the valheimserver.service or the whole VM reboots

BUT PLEASE!!!

stop the valheimserver.service before rebooting or anything.

All I did for mine just 15 mins ago was. Stop the valheimserver.service -> waited 1-2 mins -> Started the valheimserver.service ->waited 2-3 mins -> connected with my Game Client. ZERO ISSUES....

@aburakayaz
Copy link

@aburakayaz aburakayaz commented Feb 17, 2021

Thanks @Nimdy your guide has been so helpful and it allowed me and my friends many hours of fun. I can't thank you enough. Kudos!

@SnakeOfMidgaard
Copy link

@SnakeOfMidgaard SnakeOfMidgaard commented Feb 17, 2021

Thanks for these instructions @Nimdy ! Was wondering about exactly this this morning.

@angryfoxnoises
Copy link

@angryfoxnoises angryfoxnoises commented Feb 17, 2021

Hey @Nimdy! Thanks a million for doing this. I encountered one small hiccup when trying to copy the files. When attempting to copy the world files, I got the following messages:

cannot stat '/home/steam/.config/unity3d/IronGate/Valheim/worlds/WorldNameFile.db': No such file or directory

And

cannot stat '/home/steam/.config/unity3d/IronGate/Valheim/worlds/WorldNameFile.fwl': No such file or directory

Is this supposed to happen? How do I proceed?

Thanks!

EDIT: Disregard this, I'm big dumb, I just realized I need to copy change WorldNameFile.db to the name of my actual world.

If you'd like to include your Paypal or Venmo please let me buy you a root beer for your work.

@FictionalCrow
Copy link

@FictionalCrow FictionalCrow commented Feb 17, 2021

Thanks for this! not a total noob, but I was unsure how to safely shutdown the game server without any confirmations that it did so, your advice 'wait 1-2 mins' was exactly what I needed to make me feel better. I couldn't find specifics in the server documentation or google that wasn't about shutting down windows server. Valheim doesn't have a screen or tmux session to save in the way I am used to on linux game servers.

Also I would recommend the scp command to download the world file copies to your local pc if using ssh from windows gaming machine like most would be. example I used in powershell.

scp sshuser@serverip:/home/steam/.config/unity3d/IronGate/Valheim/worlds/WorldFiles C:\VHbak\WorldFiles

you can also use reverse to upload world files to server

scp C:\WorldFiles sshuser@serverip:/home/steam/.config/unity3d/IronGate/Valheim/worlds/WorldFiles

@BigWincy
Copy link

@BigWincy BigWincy commented Feb 17, 2021

I bounced the service per your instructions. Server updated with no issues. AWS EC2 t2.medium running ubuntu 18. Thanks for the procedures.

@Pendora2017
Copy link

@Pendora2017 Pendora2017 commented Feb 17, 2021

I just restarted the service
sudo systemctl restart valheimserver.service

the service has a build in "feature" which starts an automatic update (within steamcd) for Valheim Server

I dont know if a backup before is neccessary

@RotaryTiger
Copy link

@RotaryTiger RotaryTiger commented Feb 17, 2021

Following the instructions above (sudo systemctl stop valheimserver.service --> wait 3 mins --> back up files --> sudo systemctl start valheimserver.service --> wait 3 mins --> connect) successfully updated my server, but also reset it to the state it was originally in when I initially spun it up yesterday.

A friend and I just tested it again, and every time I restart the server we lose anything new we've done.

Any idea why it wouldn't be saving?

@BigWincy
Copy link

@BigWincy BigWincy commented Feb 17, 2021

@Pendora2017

"I dont know if a backup before is neccessary"

I don't think they are necessary, but the statement scares the hell out of me. Backups should a part of every procedure. I backed up mine to the a different account, just in case. Honestly, I think a daily cronjob wouldn't hurt either. Can we backup the DB when the service is running?

@devdavi
Copy link
Collaborator

@devdavi devdavi commented Feb 17, 2021

I dont know if a backup before is neccessary

It's definitely not required, but is a good a precaution incase someone loses their save and time on the server.

@BigWincy
Copy link

@BigWincy BigWincy commented Feb 17, 2021

I added in a step...
sudo systemctl status valheimserver.service
... after the stop. That way I knew the service was down before saving and starting. I don't like to rely on guesstimating times (which can work). I didn't lose anything or progress. Not sure about RotaryTiger's data loss... permissions for db and fwl file? Pure speculation.
[Also, I usually have no idea what I'm doing]

@Pendora2017
Copy link

@Pendora2017 Pendora2017 commented Feb 17, 2021

@BigWincy Nimdy wrote something (here) about the disastrous use of that flat file DB system from valheim... wow... i mean... wow... i'm really shocked

If my understanding is correct you should not do a backup while the server is running. Maybe @Nimdy could give a better detailed answer ;)

@RotaryTiger
Copy link

@RotaryTiger RotaryTiger commented Feb 17, 2021

@BigWincy Yep, looks like a permissions error. I checked the logs after and every autosave there's an UnauthorizedAccessException. Any idea what I should be granting permissions to/on to fix this?

@devdavi
Copy link
Collaborator

@devdavi devdavi commented Feb 17, 2021

@BigWincy Yep, looks like a permissions error. I checked the logs after and every autosave there's an UnauthorizedAccessException. Any idea what I should be granting permissions to/on to fix this?

navigate to the main steam folder cd /home/steam/ and use ls -la

You'll get a list of the files/directories as well as the owner. You should see something similar to this:

drwxr-xr-x 5 steam steam 4096 Feb 17 20:11 .
drwxr-xr-x 3 root  root  4096 Feb 16 20:29 ..
-rw-r--r-- 1 steam steam  220 Feb 25  2020 .bash_logout
-rw-r--r-- 1 steam steam 3771 Feb 16 20:29 .bashrc
-rw-r--r-- 1 steam steam    0 Feb 16 20:25 .cloud-locale-test.skip
drwxr-xr-x 3 steam steam 4096 Feb 16 20:31 .config
-rw-r--r-- 1 steam steam  807 Feb 16 20:29 .profile
drwxr-xr-x 9 steam steam 4096 Feb 17 15:58 .steam
-rwxr-xr-x 1 steam steam   42 Feb 16 20:30 check_log.sh
lrwxrwxrwx 1 steam steam   19 Feb 16 20:29 steamcmd -> /usr/games/steamcmd
drwxr-xr-x 5 steam steam 4096 Feb 17 20:12 valheimserver

The user and group both should be steam for everything. If not check that the steam user/group was created:

less /etc/passwd

You should see steam at the bottom of that list. Use ctrl+z to exit that screen.

If you have the user, you can change ownership with the following command:

sudo chown steam:steam /home/steam

If all looks good there, you can check items within the valheimserver directory. Again, everything should be owned by steam, files should have -rwxr-xr-x for the permission settings and directories should have drwxr-xr-x for the permissions.

@RotaryTiger
Copy link

@RotaryTiger RotaryTiger commented Feb 17, 2021

@devdavi Yeah, everything in that folder is owned by steam with those permissions but I was still getting the unauthorized access exception. The default save directory was owned by root however and didn't have write permissions for other users/groups. I granted all on it that so hopefully that was the issue

@devdavi
Copy link
Collaborator

@devdavi devdavi commented Feb 17, 2021

@devdavi Yeah, everything in that folder is owned by steam with those permissions but I was still getting the unauthorized access exception. The default save directory was owned by root however and didn't have write permissions for other users/groups. I granted all on it that so hopefully that was the issue

Well that's progress! Build something in the game and then try restarting the service again. I would check the systemctl status valheimserver.service before shutting it down to see when the last save was though.

Let us know if that resolved it for ya!

@RotaryTiger
Copy link

@RotaryTiger RotaryTiger commented Feb 17, 2021

@devdavi tested and confirmed! autosave and manual save as admin are working now. Thanks for the help!

@karljakober
Copy link

@karljakober karljakober commented Feb 17, 2021

Thanks! update went smooth on my end.

@BlueIcicle
Copy link

@BlueIcicle BlueIcicle commented Feb 17, 2021

Hello,

I'm looking to write a shell script to launch on cron during the evenings to run the update automatically, but I'm not too familiar with shell scripting. I'm looking to stop the service, sleep until the service is stopped successfully, backup the world files to an existing archive location with overwrite (or append a date), then start the service. I was wondering if I could get assistance as this is what I have so far. Would this work or do you think I'm overlooking something?

#!/bin/sh

sudo systemctl stop valheimserver.service

sleep 60

sudo cp -p /home/steam/.config/unity3d/IronGate/Valheim/worlds/*.db /home/steam/.config/unity3d/IronGate/Valheim/worlds/archive

sleep 2

sudo cp -p /home/steam/.config/unity3d/IronGate/Valheim/worlds/*.fwl /home/steam/.config/unity3d/IronGate/Valheim/worlds/archive

sleep 2

sudo systemctl start valheimserver.service

Thank you!!

@Nimdy
Copy link
Owner

@Nimdy Nimdy commented Feb 18, 2021

Hello,

I'm looking to write a shell script to launch on cron during the evenings to run the update automatically, but I'm not too familiar with shell scripting. I'm looking to stop the service, sleep until the service is stopped successfully, backup the world files to an existing archive location with overwrite (or append a date), then start the service. I was wondering if I could get assistance as this is what I have so far. Would this work or do you think I'm overlooking something?

#!/bin/sh

sudo systemctl stop valheimserver.service

sleep 60

sudo cp -p /home/steam/.config/unity3d/IronGate/Valheim/worlds/*.db /home/steam/.config/unity3d/IronGate/Valheim/worlds/archive

sleep 2

sudo cp -p /home/steam/.config/unity3d/IronGate/Valheim/worlds/*.fwl /home/steam/.config/unity3d/IronGate/Valheim/worlds/archive

sleep 2

sudo systemctl start valheimserver.service

Thank you!!

You will need to build a crontab for this.

https://www.golinuxcloud.com/create-schedule-cron-job-shell-script-linux/

Just be careful... not sure how smooth that will workout.

@Nimdy Nimdy added documentation and removed help wanted labels Feb 18, 2021
@Nimdy
Copy link
Owner

@Nimdy Nimdy commented Feb 19, 2021

seem most are over this point now. Closing :)

@Nimdy Nimdy closed this Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet