Automatically backup your Linux server's Valheim world to the cloud


Valheim's Early Access release on Steam has taken the gaming world by storm. But as with any early access game, Valheim is no stranger to bugs, and it's important to frequently back up your worlds in case you ever need to restore them.

In my case, I'm hosting a dedicated server on Ubuntu. I installed and manage Valheim through LinuxGSM, which is a great command line tool for managing dedicated servers for over 100 games. I wanted to automate world backups every thirty minutes to my personal Google Drive, and here's how I did it.

Step 1: Set up Rclone

We'll be using Rclone to easily integrate with the cloud service of your choice. This is a great, free, open-source command line program that lets you manage files on over 40 different cloud storage providers.

Follow the instructions to download and install using your favorite method, and then follow the documentation to configure with your cloud provider of choice by running rclone config. I used Google Drive, which took just a couple minutes to set up. Keep whatever name you assign to your configuration handy.

Step 2: Find your Valheim worlds

Locate your Valheim worlds folder, which may vary depending on your installation. In my case through LinuxGSM, this was in /home/vhserver/.config/unity3d/IronGate/Valheim/worlds/. A world is made up of two files, a .db and .fwl( being whatever you named your world at creation). These are the files we'll want to back up.

Step 3: Schedule backup via crontab

To schedule the backup, we'll edit our crontab through crontab -e.

At the end of the file, switch cron's default shell from sh to bash by adding:


This is needed to support the curly-brace syntax I use to select multiple files at once.

The next step is adding the commands to zip the world files and upload to the cloud. Here is mine (note that the name of my world is Serendipity and the name of my Rclone config is gdrive; change yours respectively).

0,30 * * * * /usr/bin/zip -j /home/vhserver/.config/unity3d/IronGate/Valheim/worlds/ /home/vhserver/.config/unity3d/IronGate/Valheim/worlds/Serendipity.{db,fwl} && rclone copyto /home/vhserver/.config/unity3d/IronGate/Valheim/worlds/ gdrive:Serendipity-$(date +\%Y-\%m-\%d-\%H:\%M).zip

Here's an explanation for each part:

0,30 * * * *
This is standard crontab syntax for scheduling. It can be read as "minute - hour - day (of the month) - month - day (of the week)". In my case, I scheduled my backup to occur every half-hour at :00 and :30. You can adjust yours accordingly. If you wanted to do once a day at 3 AM, you would use 0 3 * * *.

/usr/bin/zip -j /home/vhserver/.config/unity3d/IronGate/Valheim/worlds/ /home/vhserver/.config/unity3d/IronGate/Valheim/worlds/Serendipity.{db,fwl}
Here I'm zipping up my world files (Serendipity.db and Serendipity.fwl). You'll want to compress these files as they are otherwise quite large. Uncompressed, my world files are 30 MB and growing, while compressing them brings them down to 10 MB. The -j flag disregards the directory names, so that your zip file will have the world files at the root level, instead of nested within /home/vhserver/....

rclone copyto /home/vhserver/.config/unity3d/IronGate/Valheim/worlds/ gdrive:Serendipity-$(date +\%Y-\%m-\%d-\%H:\%M).zip
Here I'm performing the actual clone through copyto. I'm taking our new zip file and uploading it to our previously-configured remote (mine is called gdrive). I set the name of each file to the name of my world followed by a timestamp; you can change this however you wish.

And that's about it! Once you've got the backup working, do a practice run of restoring your world from the backup to ensure it actually works (and manually save your existing world files on the server in case the backup doesn't actually work!). If you run into any questions or have any issues, feel free to comment below.