Swapping Drives Containing Shared Folders Between Machines


Firstly, Happy New Year - and continued thanks to you amazing people for this amazing project!

I have a setup where I have two machines each syncing an external drive together:

Machine A <-> Drive A
Machine B <-> Drive B

Drive A was having issues, so I had to move Drive B onto Machine A for a while:

Machine A <-> Drive B
Machine B <-> 

During this time, I made no changes to the Syncthing setup on either machine. There will have been changes made to the files on Drive B - but no changes on Drive A. Prior to moving the drives around, the shared folders would have been Up-To-Date - or nearly so (I can’t be 100% confident).

I have now repaired Drive A, and need to reinstate the original setup.

How do I ensure that the sync will be handled correctly? If needs be, I’m happy to delete the Syncthing config and set it up again from scratch - but as it’s ~20TB of data, I was wondering if there’s a faster way to get it back in sync without everything having to be re-hashed.

Many thanks!

In the Syncthing config directory there is an index database that describes the contents of the folders. Any difference between this index database and the actual contents will be interpreted as an intentional change by the user. I’m not sure what’s the precise state of your databases and drives, but that’s the guiding principle.

If your Machine B hasn’t been syncing for a while, because the drive has been missing, it’s a while out of date. If you give it back a drive that is precisely equally out of date it will just sync the changes and be happy. If the drive contents are older than the database then the difference will look like an intentional revert by you and that will get synced to Machine A. If the contents are newer you will have changes on both sides and probably sync conflicts.

However, there’s a safe way to do it.

Safe Way

Assuming Machine A is now fine, and will keep the drive it has currently…

  • Set Machine A, which is currently fine, to “send only”.
  • Add your old drive to Machine B and let it scan/sync. It may detect changes incorrectly as above – it won’t matter, because Machine A will not apply them due to being in “send only” mode.
  • Once everything is quiescent you will probably see Machine A being “out of sync” and displaying an “override” button.
  • Press that button – it will enforce its current state onto Machine B, which will sync the changes.
  • Machines A and B are now in sync. Change the mode back on Machine A.

In the future, don’t move the drives around. :slight_smile: Or, keep the config directory on the drive in question so that the drive is self contained and defines the Syncthing device identity.

Hi Jakob:

Thanks for the quick response.

I’m needing to set the machines and drives back to their original positions:

Machine A <-> Drive A
Machine B <-> Drive B

(‘A’ is my master setup, and is more performant than ‘B’ - hence the need to revert the allocation of drives.)

So if I made no changes to the Syncthing config before setting it up again, I would have a mismatch between the database and filesystems on both machines:

  • Machine A will have a filesystem older than its database thinks;
  • Machine B will have a filesystem newer than its database thinks.

I know! :slight_smile: But sometimes the real world intrudes, hence Feature Request: Include Unique Token in .stfolder Marker :laughing: (I hope to spend some time on this at some point soon, once I’ve got some other projects out of the way. I’m a very amateur developer, so it wouldn’t be a quick process for me!)

Unfortunately there are several different drives which host shared folders on each machine - and, to my knowledge, I can’t split the database so that each drive holds only its own data… :wink:

Even if you need to swap the drives in the long run I’d do it as above. Once they are in sync and identical it’s safe to swap. If that’s not possible I’d suggest using another tool like rsync to make the other drive identical when you do the swap.


Thanks Jakob - much appreciated!

1 Like

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