Syncthing deleted 67000 files, how do I restore?

Since you’re on Linux, you can do batch rename using linux tools, something like:

#!/bin/bash

for file in $(find /yourpath/ -type f -regextype posix-awk -regex  ".*~[0-9]{8}-[0-9]{6}.*")
do
  mv $file ${file::-16}
done

The script is based on the naming patterns used with staggered versioning, i don’t know if other versioning patterns create same filenames in .stversions. The script above recursively searches for files in a given path and its sub-directories for files named somename~12345678-123456 (numbers represent date-time), and cuts off 16 last characters from the name (all that comes after ~).

I’d suggest to copy everything to some temp directory, and run script on the copy, just to make sure it works properly, and not interfere with ST.


I had a similar issue of ST wiping out ~1TB of data some time ago. It was on windows machine, shared folder with 1TB of data resided on external HDD, and for some reason, the USB connection dropped, while OS still reported it is connected: Using the file browser you’d see the disk as connected, but only previously read files would be shown. All the rest of the files are not shown until the disk is reconnected.

So ST would see the .stfolder file, assume form that that everything is OK, and delete stuff from other nodes to match current visible state of this HDD. The when the HDD was reconnected, it wiped stuff from it to match the other nodes.

1 Like