Swapping Drives Containing Shared Folders Between Machines

Hello:

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.

2 Likes

Thanks Jakob - much appreciated!

1 Like

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