Syncthing

Starting with Batocera 33, you have the ability to synchronize files across multiple Batocera machines. We use Syncthing for this, and a good use case is to enable synchronization of your saved games, so that you can start a game in the morning on your Odroid Go Advance, resume your game on your PC in the afternoon, and finish up your game on your Raspberry Pi in the evening, all with the same saves.

The beauty of this solution is that you don't necessarily need a cloud storage account, nor a central NAS storage location, and it works not only over your local network, but also across the Internet. You can synchronize your saves from your home Raspberry Pi to your Odroid Go Advance while you play in the office (yeah, it's your lunch break, you're allowed to relax a bit at this office, we don't mind ;) ).

  • There is a risk that you lose the files that are getting synchronized, or an important save file might be overwritten by a Batocera node with an incompatible format. Batocera takes no responsibility for this, you're on your own and are fully responsible if you lose data with this process. Make backups for important files, always.
  • Not all saves are compatible across architectures. It depends on the emulators and architectures you are using. If you use Batocera on multiple PCs x86_64, or multiple Raspberry Pi 4s, and the same emulators, it will work fine, but you might hit issues when using PC ←→ RPi synchronizations (for endianness reasons) or if you use two different cores for the same system, with cores that use the same filenames for the save files, but with different formats. Be careful with that.
  • If you have a machine that is up 24×7, like a NAS or a personal server, you can install Syncthing on this machine, and put it in your syncthing cluster. As it is always up, your Batocera machines will synchronize with this central server. I personally use an OpenMediaVault NAS, with Syncthing running in a Docker container.
  • If you don't have a machine running 24×7, when you synchronize files across two Batocera nodes (or more), you need to make sure both of them are up and running during the saves/synchronization processes.
  • The process is the same if you have 2, 3 or more nodes. Each node will synchronize their local content with the other peers in the cluster, once you configured the node correctly to access it.

First, you need to enable syncthing on all the Batocera machines you want to use for saves synchronization. On each Batocera, edit the batocera.conf file and add:

 system.syncthing.enabled=1

Once this is done, reboot your Batocera. When your Batocera is back up, open a web browser to http://batocera:8384 (where batocera is the IP address of your machine, if the DNS is not up).

You will have a Synthing web UI where the configuration process start.

First, a few housekeeping items:

  • do you allow to share encrypted usage data with Syncthing (Yes/No). Fully optional, and this data won't ever be shared with Batocera in any way, shape or form.

  • A warning that the process should not run as a privileged user. At the moment, this is a limitation you need to accept to use Syncthing on Batocera.

Now let's move on to the configuration:

  • Settings: this is the main page where you can define a Syncthing name for your Batocera unit, and on the GUI tab you can put a login/password to protect access to this web configuration page on http://batocera:8384. I would strongly encourage you to put a login and password in there.

  • Once you have this basic setup done on at least two Syncthing nodes (i.e. two Batocera machines with Synchthing on, or a Batocera + your central server for saves), you can create a cluster of Syncthing nodes, by telling each node which are the other machines where you want to share your saved files. You can add a friendly name for each machine, internally Syncthing identifies them with a self-generated DeviceID.

  • Now that we have our cluster of Syncthing nodes, we can configure the folders that need to be synchronized across them. In our example here, we want to synchronize the games save files in /userdata/saves/. Be mindful of the folderID that is provided here. I kept the default one assigned by Synchthing, but you can put your own. What is important is that you keep the same folderID for all nodes in the cluster.

  • Then on the “sharing” tab of the same screen, you can select all the nodes you want to synchronize this Batocera saves folder with.

  • You need to repeat that on all nodes, but if your nodes are on the same network, they might be auto-discovered and announce their shared folders to the other nodes to provide a one-click easy addition.

  • Once the shares are configured, you should see on the UI a progress for the initial synchronization. Depending on the size of your shared files, it might take some time, but you can follow the process on this screen.

  • At any given time, you can check the status of the synchronization across the cluster of Syncthing nodes on any of them with this screen.

  • Right now, when a new save file is added, or when a save file is updated on a node, you need to “reload gamelists” from the main menu to see the new save files and save screenshots updated in EmulationStation.
  • syncthing.txt
  • Last modified: 3 days ago
  • by lbrpdx