How to backup Syncthing configuration and database

I am running Syncthing on my Raspberry Pi2 which is running OSMC (based on debian upstream).

Now I want to do a clean install of my Raspberry Pi2, but I when I install Syncthing again, I want to make sure I don’t have to configure all sync folders again and also make sure Syncthing wont have to scan all directories again, generate keys etc etc.

How can I create a backup of Syncthing itself, its settings/configuration, cache etc?

3 Likes

The configuration and database are stored in ~/.config/syncthing/.

Be very careful if you restore the database but the files are missing synching will treat them as deleted and propagate the change globally.

There should be a margin of safety in that the .stfolder file will probably be missing but I would keep the configuration and blow away the database personally.

3 Likes

Wouldn’t SyncThing simply believe the drive is not available, if the folder containing sync folders is missing? Or if the drive containing the sync folders is simply not mounted?

Yes, that is what I meant by a margin of error. The .stfolder file came about so that Syncthing can recognise when a mount is missing etc.

There are still plenty of other things I would be careful of. For example, I have accidentally swapped mounts around when rebuilding a system before. It would not have been funny if I had Syncthing running before I noticed.

I am just setting up a new pc and copied the config.xml. Can I just overwrite the config.xml or will this delete the files on other devices?

The config.xml is fairly safe to copy (assuming you have folders in the same place as before), but to retain the device ID you also need to copy the key.pem and cert.pem files.

3 Likes

Hey, I’d like to do the same as the OP - i.e., replicate my current Syncthing configuration on a fresh install of Ubuntu…

I understand from reading this thread that if I replicate the folder structure on my fresh install of Ubuntu and keep all the Syncthing config files (listed in fig1 below), located inside ~/home/.config/syncthing/ and copy them into the same location on my fresh install of Ubuntu, then I will have transferred my Syncthing configuration over, and things should work as they have been doing on the old install?

Just to clarify, are the files within the folder name: ~/home/.config/syncthing/index-v0.14.0.db the database? And do I not need to bother copying and replacing this folder/files?

Thanks for your help

If you copy the database and then point the config at an empty directory, syncthing will assume you want it to delete all the files.

Are you moving syncthing or creating a new instance?

If moving, then you want to copy the pem files (as that is what decides the id), if new instance with the same configuration then copy just the configuration and you’ll get a new id on startup.

1 Like

Thanks for the helpful clarification @AudriusButkevicius.

I want to flatten my laptop that has Ubuntu 18.04 on it and do a fresh install of Ubuntu 20.04 and then reinstate my Syncthing configuration, so guess I’m creating a new instance?

Ideally, I’d like to keep the same Syncthing configuration and for Syncthing to reinstate all the folders/files from my network shares back on to the newly installed Ubuntu 20.20n machine.

But I could also manually copy all the folders/files across and then reinstate the configuration. Sounds like either could work?

Thanks again

1 Like

If it’s just a few folders and a few devices, it’s probably more fool proof to set it up from scratch by hand.