Syncing game saves with almost any cloud service

Posted on 2023/04/07 in Linux

Edit: New version of the script

Check the repository on https://gitlab.com/Nerdeiro/game-cloud-sync and follow the README.md there.

Sync your games to (almost) any cloud service

This is a simple Bash script to sync your game-saves with pretty much any cloud storage service out there. It uses Rclone, which supports dozens (not hyperbole) of providers.

The motivation to create this script was to sync my copy of Stardew Valley between my desktop and my Steam Deck. But wait, doesn't Steam do this ? Yes, it does, for copies bought on Steam. But my copy is from GOG... It runs just fine on the Deck, regardless if it was installed from a manual download, with Lutris or Heroic, it only lacks cloud saves.

This is where this script and Lutris come in. The role Lutris will play here, is to allow us to run a script both before and after running the game, all without having to change the default start.sh lancher script that the GOG installer creates.

What you need to use this script

In no particular order:

  • Lutris (optional but recommended)
  • Rclone
  • A cloud service supported by Rclone
  • A working remote configuration in Rclone

If you're syncing between two computers, getting Lutris and Rcloneis as easy as installing them using your distro's package manager. On the Steam Deck, Lutris have to be installed using Flatpack, after changing to Desktop mode. Rclone is a little bit more challenging, since it's not on Flathub and the Deck ships with a read-only Root (/) file-system, so using Pacman to get it is not an option.

Thankfully, the creators of Rclone have a statically compiled binary on the official website, which means you can run it on the Deck without any issues, only you'll have to put it somewhere on the $HOME directory. To avoid having to fiddle with the $PATH, I recommend that after unziping the downloaded file, you move the rclone executable to a convenient place, then edit the script to point the variable RC to the full, absolute path of the binary.

After installing Rclone, follow the official documentation to create a configuration for your remote cloud service. It's important that you can successfuly run a copy or sync between the two sides. Lets say that you run rclone copy mycloud:somedir/ ~/tmp/someotherdir, if the command finishes and the files show up in ~/tmp/someotherdir, then you're good to go.

Getting the script

Just clone it from my Gitlab Repo at https://gitlab.com/Nerdeiro/game-cloud-sync. You can do it with the command

git clone https://gitlab.com/Nerdeiro/game-cloud-sync.git

Once it's cloned, you can use it right away, on a normal Linux distro. To put use it on a Steam Deck, before transfering a copy to the console, open it in your favorite flavor of Vim and find the line:

RC=$(which rclone)

and change everything after the equals sign for the full path to the Rclone binary that you downloaded before. It should look like:

RC=/home/deck/bin/rclone

or something like that.

Using the script on the command line

Just run it with the following options:

  • -s : Source. It can be a local directory or an Rclone remote
  • -d : Destination. It can be a local directory or an Rclone remote
  • -v : Verbose. Shows the copy progress on the terminal

One of the parameters should be the local directory where your save games are, eg. $HOME/.config/StardewValley, the other should be a remote configuration and path, like mycloud:/StardewValley. Which one you'll use with -s or -d will depend on which direction you want to sync, to or from the cloud.

Using the script with Lutris

Open Lutris and click with the right mouse button on your game, selecting "Configure" to show the screen bellow:

screenshot of Lutris game settings

If your screen is not like that, tick the option "Advanced" on the top of the dialog, then scroll all the way to the botton of the "System Options" tab. There you'll the boxes to configure a Pre-launch and a Post-exit scripts.

To download the save files from the cloud to your computer (or Deck) fill the "Pre-launch" line with:

sync-game.sh -s my_cloud:saved_games/ -d $HOME/game_dir/

To upload the save files from the computer to the cloud, fill the "Post-exit" line with:

sync-game.sh -s $HOME/game_dir/ -d my_cloud:saved_games/

If everything works as they should, your game should be saved on your cloud storage, ready to sync to other devices. Do the same on the Steam Deck if necessary.

And happy gaming.