Re-establish syncing with new syncthing, but old synced directory

My question is related to changing OS: If I change OS on a computer but keep the directory for syncing with syncthing on the computer, can I get the newly installed syncthing on the new OS to resume the syncing? If so, what do I need to do?

Here is the setup: I have a desktop and 2 laptops, all 3 with syncthing installed and with the two laptops syncing to the desktop. On all three computers, the OS (all 3 are Linux distros) is installed on a partition separate from the partition on which I store files. Each of the computers has a folder called syncthing on the storage partition and they are all synced together. That is, any changes to Laptop 1 are synced to the Desktop which then syncs to Laptop 2. This works quite well.

I am going to change the OS on the Desktop to a different Linux distro, which obviously will destroy the Syncthing setup on the Desktop, but the syncthing directory on the separate partition will remain unchanged. What is the most efficient way to re-establish the syncing of these 3 computers?

When reinstalling Syncthing, I would just add the existing folder as Receive Only first, let everything sync, override possible local additions, and then change it to Send and Receive for future synchronisation.

2 Likes

Thanks, tomasz86, that seems logical. It will probably be next weekend before I have a chance to install the new OS, so don’t expect a report on how it went or any followup questions before then.

Does /home/ count as “the OS” or is that the distinct partition? The Syncthing configuration should be sitting there, and replacing the distro shouldn’t need to wipe it. (That is why user home directories are kept in their own tree, after all.)

I’m not sure I understans what you’re saying. /home is on the same partition as the OS.

Here’s how I set up the partitions. I made 4 partitions: sda1 is the boot partition (I’m using EFI), sda2 is swap, sda3 is mounted as / and that’s where the OS is installed and sda4 is mounted as storage and that’s where I store most of my files.

It is common on Linux to mount the data partition to /home so all users data is seperated from the OS.

If you didn’t mount the data directory to /home then you probably lost the config and database when you re-installed.

Odin, I’ve thought more about what you said. I think the reason I started making a separate storage partition but leaving /home with the OS goes back many years to a time I decided to keep storage separate from the OS. I had everything on one partition, so I shrank that partition, and used the empty space to make the storage partition. As a noob (I’m only a little more advanced now), moving /home to that new partition seemed too complicated, so I didn’t. And I’ve used that system ever since.

But after reading your reply, I think when I do the new installation, I’ll put /home on it’s own partition and include storage on that partition. Then I shouldn’t have this problem in the future (except when I replace my two laptops, which are using my old system).

Thanks for the reply.

Thanks for the reply. kluppy.

Regarding your first sentence, please refer to my 2nd reply to Odin. In that, I mentioned that in the future I’ll put /home on a different partition.

Regarding your second sentence, I haven’t done anything YET. Do you have any suggestion on how to do this migration? Is there some way to export and then import the config and database you mentioned?

The default location for the database, certificates and configuration on Linux is ~/.config/syncthing.

You can copy these to the new system if the paths to the shares stay exactly the same.

If they do not match you could in theory loose data but the folder markers should prevent that.

Edit: If the location of the shares change you can update the config.xml but again be careful not to mess it up.

Thanks again. Since I’m going to start using home as my partition separate from the OS instead of /storage, the path to the WILL change. The path I’m currently using is /storage/syncthing/. When I do the new install, I’ll probably just use the default directory /home/randall/Sync/.

Personally, I have /home/ on its own partition, and have a separate data storage on a larger HD. It all depends on how you want to set things up.

There are ways to fix that - either by changing the syncthing config file before starting it on the new setup, or by being creative with the filesystem mounts. I’d probably go with the former.

Personally I would copy the data and modify the config file. If you are sure you haven’t changed any of the local files tomasz86 suggestion is a safer option.

FYI:

Also within that thread,

After looking at the two links you mentioned, I think the best option for me is essentially a variation of Mark McBride’s option 1-Install syncthing fresh and re-sync folders one by one.

Reading the other link it looks like there’s a lot to do and that makes it prone to the possibility of errors on my part that might break stuff.

I don’t know if you read my second reply to Odin, but the more I think about it, that may not be quite right either. I think the reason I put the storage separate from the OS AND the /home directory is that I was dual booting (actually triple booting) my computer with Windows and two Linux installations and I wanted to be able to mount the storage partition from either Linux installation.

Rather than run the risk of breaking something, I’ll probably do the following. I’m doing this on my desktop which will be single boot only. I’ll just completely wipe it and on separate partitions I’ll have swap, the OS and /home. Then I’ll sync /home/randall/Sync/ on this computer to /storage/syncthing/ on one of the laptops. Once this is done, I’ll restore the sync of the other laptop’s /storage/syncthing/ to the Desktop’s /home/randall/Sync.

I have 2 questions about this.

  1. Will this work without the syncing deleting files from the laptops because there are no files in the desktop /home/randall/Sync/ directory they’re syncing to. My guess is that won’t happen, but I want to make sure before I start.
  2. I’m not the only user on the desktop. I want other users on the computer to have access to the files that are going to be synced. Should I put the directory for syncing somewhere else, not MY home directory, maybe /home/syncthing/ or maybe just /syncthing/?

Let me ask this hypothetical question. Say I have two computers and on each I have a directory /sync_with_rsync, which are identical because I’ve kept them synced with rsync. Let’s say there is a total of 500 files in a variety of directories and sub-directories in this directory. I then do a fresh install of syncthing and set syncthing up to sync these two directories (and everything in them). What does syncthing do in that situation? My guess, after reading about conflict handling at (Understanding Synchronization — Syncthing v1 documentation), is that syncthing will go through the regular conflict handling procedure for each file but I really don’t know what that means.

The referenced document says syncthing recognizes conflicts, but I don’t know what it analyzes to see if two documents conflict or not. If syncthing looks at two documents on different computers, one of which is a document produced by rsync, will syncthing see them as different or will it see them as the same (and therefore non-conflicting)?

And would that apply to syncthing as well? That is, if two different machines were kept in sync by syncthing, instead of rsync, and then the syncthing was removed (including $HOME/.config/syncthing) and reinstalled on both computers, would syncthing see these as different, conflicting files or not? I realize there might be a few anomolies because of versioning.

You can probably see where I’m going with this.Will the procedure described in the paragraph work in my situation of using syncthing to keep my two laptops synced to my desktop? And is that essentially what tomasz86 is suggesting (along with “add the existing folder as Receive Only first”), except it isn’t necessary to remove syncthing from the laptop since I’m not changing anything on it?

BTW-Sorry for the long winded posts.

ST will compare the files and if they match will consider them in sync.

This includes content permissions etc.

If anything is different in one of the files they will be considered to conflict because there is no history for either.

What tomasz86 is suggesting essentially forces the receiving device to change it’s local additions to match the global state without generating conflicts that are synced to the global state.

Kluppy, thanks for the explanations.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.