I have a second laptop that I take travelling with me for work. It is a Linux laptop and has a direct copy from my main machine of /home/my_home and /opt. I install the same apps on it. The travel laptop has a different name to my main development machine, and they can both exist happily on the same network.
I wanted to copy the syncthing configuration from my main machine to the travel laptop and assumed that it would all work fine. All file paths and names are identical.
Following much of the advice on this forum, I took the following steps to get a working configuration for the travel laptop, when a simple copy did not work.
Created a working configuration for the travel laptop and ensured changes went in both directions to the other machines in the same syncthing mesh.
Backed-up this configuration (~/.local/state/syncthing directory) to a secure place on disk.
Run a start-up script, which checks the name of the machine.
If the name of the machine is my main development laptop, then start up syncthing as normal (/usr/bin/syncthing serve --no-browser --logfile=default).
If the name of the machine is that of the travel laptop, perform the following steps.
kill syncthing, if it is running.
forcibly remove ~/.local/state/syncthing .
make a new directory of the same name as in the step above (No. 2).
copy config.xml from the back-up travel configuration to this new directory
also copy cert.pem and key.pem into that new directory.
eventually also tried copying the https- versions of the latter two files.
restart syncthing.
Unfortunately, every time I restart syncthing on the travel laptop after following the aforementioned steps, it has a new ID and no memory of any configuration apart from having the correct machine name. I had hoped it would just start and run as it did when initially set up. (Every time a restore my home directory to the travel laptop, the travel configuration is overwritten, that is why I need to remove the syncthing configuration and copy over the old one.)
I am running the latest version of Linux Mint (22.2) and I believe the latest syncthing (2.0.10).
It seems like there is some other configuration information kept somewhere that I am missing.
What am I doing wrong? All the comments on similar posts in this forum just advise copying over those three files and everything will be fine.
Given that there are two branches, v1.x and v2.x, best to make sure because you could be running different versions between the two PCs. Look on Syncthing’s web UI, or with the following command:
syncthing --version
Based on the available info, it should’ve been fine just restoring config.xml, key.pem and cert.pem for your “work” laptop.
However, a more streamlined and simpler option is to simply exclude ~/.local from your mirror of /home/my_home. Edit the Syncthing folder, and under the “Ignore Patterns” tab, add the following pattern:
/.local
You didn’t mention if your sync is bi-directional, but regardless, it’s best to add the pattern to both PCs.
Alternatively, a more complicated (but still streamlined) option is to set up a systemd service override that tells Syncthing to use a custom home directory for Syncthing that’s unique to each PC. Done properly, you can freely mirror all of /home/my_home between the two PCs.
I also agree there are better ways to achieve what I think you’re trying to achieve without a startup script that has to modify/copy config files.
what is it about your situation that makes you think you need to do something “special” to get the behavior you want? I’m truly trying to understand.
I don’t believe I have to do something special. It’s just that following the instructions in other posts that specified copying over the config.xml, cert.pem, and key.pem would allow me to run syncthing as the travel laptop, not as the work laptop.
It didn’t work, and since I travel ad hoc often, I had been trying to work out how to solve the problem.
When I’m working in a different city, or example, I want the files on the server and my smart phone updated in the same way, in which they would be updated were I working on the main (i.e. work) laptop.
I’m not sure of the precise thing you’re referring to, but generally never copy the certificates (*.pem). Those make up the device identity and need to be unique for each machine or very, very strange things will happen.
(The only exception being when you’re migrating from one machine to another identical one with all data, and wiping or throwing the old one away.)
I ended up using –home=<dir> to point each machine to the location of the stored copy of the config directory. No more copying files. There must have been some issue when copying the files, in the previous clunky solution that I used.