Troubleshooting Joplin's synchronization on Ubuntu

Hey,

I've been updating a note in Joplin when suddenly, upon the regular synchronization, Joplin just removed all notes, except the one I was working on, which it labeled as a 'conflict'.
I.e. I'm left with a single note instead of a couple hundreds.
What now? :wink:

Some specs:
OS: Ubuntu 16.04
Joplin: Joplin-1.0.70-x86_64
Synchro: to filesystem
(the synchro dir is actually encrypted with cryptomator and stored on my dropbox account, but Joplin is unaware of that).

I can see that the database in ~/.config/joplin-desktop is about the right size (2,4MB), pictures are still in ~/.config/joplin-desktop/resources but there's just no notes in Joplin.

App logs:

2018-04-26 18:22:10: "fetchingTotal: 1"
2018-04-26 18:22:10: "fetchingProcessed: 1"
2018-04-26 18:22:10: "Total folders: 15"
2018-04-26 18:22:10: "Total notes: 349"
2018-04-26 18:22:10: "Total resources: 77"
2018-04-26 21:25:12: "Garbage collecting alarms..."
2018-04-26 23:15:28: "Scheduling sync operation..."
2018-04-26 23:15:30: "Scheduling sync operation..."
2018-04-26 23:15:40: "Preparing scheduled sync"
2018-04-26 23:15:40: "Starting scheduled sync"
2018-04-26 23:15:41: "Operations completed: "
2018-04-26 23:15:41: "updateRemote: 1"
2018-04-26 23:15:41: "fetchingTotal: 1"
2018-04-26 23:15:41: "fetchingProcessed: 1"
2018-04-26 23:15:41: "Total folders: 15"
2018-04-26 23:15:41: "Total notes: 349"
2018-04-26 23:15:41: "Total resources: 77"
2018-04-27 10:38:24: "Scheduling sync operation..."
2018-04-27 10:38:25: "Scheduling sync operation..."
2018-04-27 10:38:35: "Preparing scheduled sync"
2018-04-27 10:38:35: "Starting scheduled sync"
2018-04-27 10:40:22: "Operations completed: "
2018-04-27 10:40:22: "noteConflict: 1"
2018-04-27 10:40:22: "deleteRemote: 1"
2018-04-27 10:40:22: "fetchingTotal: 590"
2018-04-27 10:40:22: "fetchingProcessed: 590"
2018-04-27 10:40:22: "deleteLocal: 589"
2018-04-27 10:40:22: "Total folders: 0"
2018-04-27 10:40:22: "Total notes: 1"
2018-04-27 10:40:22: "Total resources: 0"
2018-04-27 13:03:18: "Profile directory: /home/major/.config/joplin-desktop"
2018-04-27 13:03:18: "Trying to load 0 master keys..."
2018-04-27 13:03:18: "Loaded master keys: 0"
2018-04-27 13:03:18: "Trying to load 0 master keys..."
2018-04-27 13:03:18: "Loaded master keys: 0"
2018-04-27 13:03:18: "Scheduling sync operation..."
2018-04-27 13:03:18: "Scheduling sync operation..."
2018-04-27 13:03:19: "DecryptionWorker: starting decryption..."
2018-04-27 13:03:19: "DecryptionWorker: completed decryption."
2018-04-27 13:03:28: "Preparing scheduled sync"
2018-04-27 13:03:28: "Starting scheduled sync"
2018-04-27 13:03:28: "Operations completed: "
2018-04-27 13:03:28: "fetchingTotal: -"
2018-04-27 13:03:28: "Total folders: 0"
2018-04-27 13:03:28: "Total notes: 1"
2018-04-27 13:03:28: "Total resources: 0"
2018-04-27 13:03:28: "Updading all notifications..."
2018-04-27 13:03:28: "Garbage collecting alarms..."
2018-04-27 13:03:29: "DecryptionWorker: starting decryption..."
2018-04-27 13:03:29: "DecryptionWorker: completed decryption."

I'm not panicking as I have a copy of everything on my other machine, so I can probably open it up, disable synchro, export a package and import it in the affected PC... but what if I hadn't? Any trashcan somewhere, an option to undo last sync operation, get the notes from within the DB on the affected PC or I don't know?

I’ve managed to replicate the issue.
In my setup, I mount the directory decrypted by cryptomator in ~/tmp/journal. If during Joplin’s operation the share is unmounted or becomes empty, Joplin will sync itself with it, i.e. delete everything.
Recovery: quit Joplin, remount the share, delete (or rename) database.sqlite & resources dir, launch Joplin, reconfigure syncing with the dir & you’re done.

Still interested if anything can be recovered from database.sqlite in case it’s the actual cloud directory that gets corrupted/nuked and as a result wipes local copies on PCs.

Strictly speaking this behaviour is correct - if there’s nothing on the sync target, there should be nothing on the local copy, however it might indeed be surprising.

As a general rule, I think it’s better to do occasional backups of your Joplin data in case this kind of problem happens. The app lets you do your own setup (i.e. unlike Evernote you are not forced to use a specific infrastructure) but that also means you need your own failsafe.

Otherwise one thing I’ve been hinking of is displaying a warning if many changes are going to happen or many notes are going to be deleted. That way, the operation can be confirmed first, which would prevent this kind of unexpected behaviour.

Some kind of 'trash' folder from where one could restore the note to its original place would also be immensely helpful. (And not only in this one case. :slight_smile: )

Hi Laurent,

if there’s nothing on the sync target, there should be nothing on the local copy

I wonder if this is a correct logic in case when the user changes synchronization point.
I have just managed to erase everything by doing exactly that.

By the way when syncing between cloud and several devices how is the priority determined on who got the latest version?
My default assumption was that something like "git merge" should happen, but it doesn't seem to be the case.

Anyways, thanks a lot for the great app!

By the way when syncing between cloud and several devices how is the priority determined on who got the latest version?

The version on the sync target is considered the "right" version. If there are changes to the local copy and a conflict happens, the local note will be overwritten by the remote one, and the old version (that was overwritten) will be copied to the "Conflict" notebook. There's currently no "git merge" happening.