How to check for sync completion with the api?

How to check for sync completion with the api? Basically to know that I’m not working with old files that haven’t been updated from a sync when system starts up and to know that I can shutdown the system because all files are synced to the server.

At first I tried polling for completion:

curl -sk -H "X-API-Key: $apikey" -X GET "$folder_id" | jq .completion

but even at .1 seconds, I tested by creating a 500M file on the remote machine and it never reported anything under 100%. On my local system (Linux), all I can see is no file, and then the 500M file in an instant. (Unrelated, but even with inotify, I noticed there’s a delay from when I created the file to when it starts syncing.)

Quick google search I see there’s also an event for completion but I’m not sure how this is useful for my purposes–it tracks syncs as they are happening but I guess not when “a successful sync was recently completed”. I.e. in the situation where my system boots up again, it was already fully synced on shutdown and there might not be any change in data, but it would still be important to know that a sync was completed on startup and that there are no errors for the sync directory.

At the moment, there is last scan which seems the most straightforward to understand, but time of scan that should have started does not necessarily indicate it was completed and without errors.

So you want to see when a locally created file has synced to a remote device? Then you need to watch the completion percentage of that device, not of the folder (which shows the local state, where a file is “there” immediately after Syncthing has scanned it).

1 Like