Tokimeki.Memorial

Note: This website contains almost no TokiMemo content.
In fact, this picture is the only reference at this point.

Syncthing on ArkOS

Post unlisted | August 12th 2024

This is a quick tutorial for setting up Syncthing on ArkOS. It will cover installation and configuration of Retroarch saves and states. I'm running ArkOS 2.0 which is the latest release on an Anbernic RG353V. I don't plan on keeping this guide updated, so if ArkOS or Syncthing make some dramatic changes in the future, it might not work. I mostly used this guide from lenordsNet for setup.

Step 0: Pre-setup

Before you start syncing your folders, you need to decide what kind of folder structure you want to use. In order for this to work properly, all your Retroarch devices has to use the same folder structure so they know where to look for your saves. In a recent video, Russ from Retro Game Corps has set up Retroarch to sort saves and states by core name. This means for instance that any savegame created by DuckStation will go in a duckstation subfolder. Personally, I would recommend sorting by content directories instead, meaning PlayStation games end up in a psx folder and so on. Here are the pros and cons of this setup:

Advantages:

  • Batocera compatibility. This is the main reason I recommend this setup as this is how Batocera (and Knulli) stores their saves. There currently is no easy way to change this in Batocera, so if you want this to work with Batocera, this is probably the easiest way of getting it to work.
  • Lets you use multiple emulator cores. If you set Retroarch to sort by emulator core, you won't be able to find your saved games if you one day decide to use Swanstation instead of Duckstation. However, If you sort by content directory instead, all your PlayStation saves will be in a shared psx folder instead. This doesn't necessarily mean Swanstation is able to read Duckstation save files (I don't know if it can or can't) so your milage way vary.
  • You only need to sync one folder. I don't know if it makes much of a difference, but it should save on resources and power consumption.

Disadvantages:

  • Potential hit-or-miss compatibility between emulators. I alluded to this in the advantages as well. While your emulator cores can find your save file from another core, it doesn't necessarily know to read it. Usually, save games work between cores but I wouldn't rely on save states doing so. In any case, there are no guarantees.
  • Locks you into storing your roms in Emulation Station structure: In order for this to work, you need to store PS1 games in a psx folder etc. I don't know if this could be an issue for your setup.
  • If you store multi-disc games in separate folders, this will not work. I was keeping my multid-disc games in subfolders that a .m3u file would refer to. I think this was the recommended way of doing it in Batocera, but in ArkOS it doesn't make much sense. Also, this will make Retroarch save your game in "Final Fantasy VII" (or whatever you called your subfolder) instead of psx. You can circumvent this with a series of symlinks or ideally not use subfolders on ArkOS.
  • Kind of messy. By default Retroarch likes to keep saved games and states separate. Instead we will not only mix them together, but also mix 32 and 64-bit versions. I haven't personally found any issues with this setup, but I haven't really done anything to stress-test it either.

In any case, once you've decided on a folder structure, you need to go into Retroarch settings and set Sort Saves into Folders by Content Directory and Sort Save States into Folders by Content Directory to On. Any other way to sort in this menu has to be turned off.

After this, you need to go into Settings > Directory and find Save Files and Save States. These need to refer to the same folder. Finally, under Main Menu, you want to Save Current Configuration to save your changes.

ArkOS ships with both the 32 and 64 bit versions of Retroarch. They have each their own config, meaning your have to do this setup in both versions. Make sure to pick the same save folder for 32 and 64 bit. You want everything to be stored in one folder so it isn't separated.

Step 1: Install Syncthing

ArkOS doesn't ship with Syncthing by default, so we need to install it ourselves. In ArkOS, go into the Options section and turn on "Enable Remote Services". This allows you you do access your device's shell, or command line, from another computer using ssh. On a computer that is on the same network as your ArkOS device, open a Terminal. Linux and Mac comes with a Terminal app included, while on Windows you can install one from the Windows Store or use Putty. Once you have your Terminal ready, type the following to get access to your device:

ssh ark@"ip address"

... with "ip address" being the IP of your ArkOS device. If you are unsure what your IP is, you can press start to open the main menu - Your IP is listed at the bottom. You will be prompted for a password. This is "ark" by default.

Press enter, and you're in! Now we can get on with installing Syncthing:

sudo apt update
sudo apt install syncthing

In some Terminals, you might need to press ctrl-shift-V to paste from your clipboard. Alternatively, right-clicking and selecting Paste is usually also an option. You'll be asked if you want to continue installing - Press y. Some text will flash by - This is a good sign. When it stops, Syncthing will be installed - Yay!

Step 2: Configure Syncthing

For whatever reason, by default Syncthing is set to only allow access to its GUI website from the device itself. That's no good, as ArkOS doesn't ship with a browser. Instead, let's make it accessible for your home network. In your ssh session, type:

nano ~/.config/syncthing/config.xml

This will open Syncthing's configuration file in the text editor Nano. Find the place where it says <address>127.0.0.1:8384</address> and replace 127.0.0.1 with the IP address you used to access your device in step 1. Keep the :8384 on the end though. Once you're changed it to the correct IP, press ctrl-s to save and ctrl-x to exit Nano. Back in the command prompt, you can now start syncthing by typing:

syncthing

You should now be able to access Syncthing from your computer's browser by going to IP address you entered in the config file, including the :8384 at the end.

You can now follow Russ' guide (or video) to set up your syncing. It's a great guide, and I wouldn't be able to do it better myself. If you followed my recommendation from step 0, there's only one folder you need to sync. However, I personally like to sync the screenshots folder as well. In the Advanced tab, you can set your ArkOS device to Send Only if you worry about fill your device with screenshots from other devices.

Also, if you plan on syncing saves with Batocera, I would recommend that you add a few lines to the ignore list. x64-based Batocera supports a lot more devices than ArkOS, and a lot of them uses a lot more storage space than retro consoles when saving games. I would add the following to the ignore list on your ArkOS device:

flatpak
gamecube
wii
ps2
ps3
xbox
xbox360

If there are any other "big" emulators, you're playing on Batocera, you might want to add their save folder to this list.

Step 3: Start Syncthing automatically

Finally, we need to set Syncthing to start automatically. This is done by adding at as a service. In your ssh shell, paste the following:

sudo nano /etc/systemd/system/syncthing.service

This opens a configuation file for a Syncthing service. It doesn't exist yet, so the file is empty. Paste this in:

[Unit]
Description=Syncthing - Open Source Continuous File Synchronization
Documentation=https://docs.syncthing.net/
After=network.target

[Service]
User=ark
ExecStart=/usr/bin/syncthing -no-browser -logfile=/var/log/syncthing.log
Restart=on-failure
SuccessExitStatus=3 4

[Install]
WantedBy=multi-user.target

Just like last time, ctrl-s to save, ctrl-x to exit. Now we need to enable the service so that it starts as intended:

sudo systemctl daemon-reload
sudo systemctl enable syncthing
sudo systemctl start syncthing

You can check that the Syncthing service is running by typing:

sudo systemctl status syncthing

If it says "Active: active (running)", then congratulations, you have fully configured Syncthing!

Maintenance:

Syncthing is pretty set-it-and-forget-it. It doesn't really draw much attention to itself. If you want to, you can update from the ssh shell using sudo apt update | sudo apt upgrade syncthing, but then again, why risk breaking it?

Other than that, you can check the GUI webpage once in a while to see if there are sync errors. Usually, when there is a conflict, it will store a copy of the conflicting file with "sync-conflict" added onto to the file name along with when and what device the conflicting file came from.