encryptic-team / encryptic

An encryption-focused open source note taking application
Mozilla Public License 2.0
348 stars 40 forks source link

Restore from Encryptic backup fail #90

Closed dayfuaim closed 5 years ago

dayfuaim commented 5 years ago

I use https://unstable.encryptic.org in many browsers (Brave, Chrome, Vivaldi, Opera), so I have made Brave the main one and did "Backup everything".

Then I've created the same identity (d3) in Vivaldi (same name and key). Then I tried to "Restore from backup" (Encryptic-backup-d3.zip). Nothing happens in interface. I got in console: Снимок экрана 2019-04-11 в 14 12 29 (many lines of such) I clicked "Close", but "All Notes" are empty. Even after refresh and closing the tab and enter the site again. Application DBs (in my case that's lav-d3, lav-default and notes-db) are empty.

This has place also at https://app.encryptic.org and in standalone app. I use Mac OSX 10.10.5, but I think that it's not about the OS.

fbicknel commented 5 years ago

Same here chrome+Ubuntu -> chrome+Mac OSx

Encryptic v0.0.4

daed commented 5 years ago

Can replicate. I'm looking at it.

daed commented 5 years ago

The most immediate issue is that the wrong part of the path is being used as the key to determine which files are which. I've found and fixed that issue. However, any notes I import are blank.

I think there's something else going on with the import. I wrote a command line decryption script to test exported notes and they're looking fine, but if I import the exported notes and then export them a second time, they come back looking like:

{"title":"","content":"","tags":[]}

Which is definitely wrong, and definitely would explain what I'm seeing.

johnblommers commented 5 years ago

Perhaps somebody can write a clear HOWTO that goes step by step over how a user with a working encrypted Dropbox-synced Encryptic installation can back up necessary information, move it to another computer, and configure Encryptic there with the same identity, key and access to Dropbox. Essentially you now have two computers in sync with encrypted dropbox data shared.

I cannot figure out how to do it. Nothing works. I'm using Macintosh computers. And I suspect this issue might be closed in part with the requested HOWTO.

daed commented 5 years ago

Okay, some significant progress. At modules/Module.js:305:

        await this.decryptModel(model);
        await this.saveModel({model, dontValidate: options.dontValidate});

We were decrypting the model and then not following that up with the decrypted model. After that I was able to see the imported backup mesages fine in the log. There's still something I'm missing here that is causing the model to not save properly, but at least it's progress. I hope to have more in a few days.

@johnblommers Once I get this sorted, I'll put together a HOWTO on the "correct" way to restore your backup. I think this will go a long way toward fixing the dropbox issues as well as they both use the saveModelObject() function.

dayfuaim commented 5 years ago

@daed I looked yesterday into the components/ImportExport/Import.js and found out that following makes tags and notebooks (at least) import correctly (Import.js:480):

            if (path.length === 4) {

(all paths in archive start with 'Encryptic-backups/').

Also Import.js:493:

                const _opt = {zip, profileId, data, name: file.name}
                this.importNote(_opt);

makes note have title during import (I think because of model is immutable object).

Hope this will help.

UPDATE (I think it's very important): Import.js:492:

            if (userDir === 'notes') {
                const _opt = {zip, profileId, data, name: file.name}
                this.importNote(_opt);
            }
            else if (userDir === 'files') {
                this.importFile({profileId, data});
            }

After these changes restore from Encryptic backup went well (as it should be). :) Verified in Brave (Chromium-based) & Firefox.

daed commented 5 years ago

I think that last bit was the one I was missing. It looks like it worked with my test backup.

daed commented 5 years ago

@dayfuaim are the notes you import persisting after you close/reopen the browser window? Mine went empty. It's like it's rendering them, but they're not properly being saved.

daed commented 5 years ago

I think I fixed that too. Should be in latest push (and also on unstable.encryptic.org). That was one of the major issues, so I'll put together a release soon.

I haven't tested if this fixes Dropbox yet. I'm expecting that to have a particular set of steps that have to be performed to work correctly. I'm going to test that and then put together a HOWTO.

dayfuaim commented 5 years ago

@dayfuaim are the notes you import persisting after you close/reopen the browser window?

Yes. I have verified it in several browsers (Brave, Firefox, Opera...).

The only thing is wrong (IMHO): after import I see notification "Import is successful... . Reloading the window." but no reloading happens.

The rest is very good. Dropbox, RemoteStorage, import – everything works (https://unstable.encryptic.org/ and locally built version). Thank you @daed 👍

I think I should close this now.