federicoiosue / Omni-Notes

Open source note-taking application for Android
https://omninotes.app
GNU General Public License v3.0
2.67k stars 1.11k forks source link

Cannot restore legacy backup #737

Closed bastianilso closed 1 year ago

bastianilso commented 4 years ago

Hi, I recently upgraded to a newer version of Lineage OS, and had to format my phone, so i made a backup of my Omni Notes data. Now, i have been trying to restore it in the Omni Notes 5.5.0 (from f-droid) and in the Omni Notes 6.x from here, but even if it says it succeeds, i still dont see any notes. What can i do to figure out what is going wrong?

federicoiosue commented 4 years ago

Hi there,

did you tried to enable the following options to check if more informations are reported?

Screenshot_20191226-102929__01

bastianilso commented 4 years ago

Ah, thanks didnt look in there. Here is the log:

12-26 22:43:08.964 24723-24723 D/Omni Notes: start file logger service thread
12-26 22:43:08.962 24723-24723 V/Omni Notes: Started navigation drawer initialization
12-26 22:43:08.968 24723-24723 V/Omni Notes: Finished navigation drawer initialization
12-26 22:43:08.970 24723-24723 D/Omni Notes: {navigation=1549290266696, settings_enable_file_logging=true, settings_language=en_US, acra.legacyAlreadyConvertedTo4.8.0=true, settings_password_access=false, acra.legacyAlreadyConvertedToJson=true, settings_send_analytics=true, pref_tour_complete=true, acra.enable=true, acra.lastVersionNr=280}
12-26 22:43:09.029 24723-24723 D/Omni Notes: initNotesList intent: android.intent.action.MAIN
12-26 22:43:09.034 24723-24775 V/Omni Notes: Query: SELECT creation,last_modification,title,content,archived,trashed,alarm,reminder_fired,recurrence_rule,latitude,longitude,address,locked,checklist,category_id,name,description,color FROM notes LEFT JOIN categories USING( category_id)  WHERE category_id = 1549290266696 AND trashed IS NOT 1 ORDER BY title||content COLLATE NOCASE  ASC 
12-26 22:43:09.245 24723-24775 V/Omni Notes: Query: Retrieval finished!
12-26 22:43:09.326 24723-24723 D/Omni Notes: it.feio.android.omninotes.async.bus.NotesLoadedEvent
12-26 22:43:09.345 24723-24723 V/Omni Notes: Started navigation drawer initialization
12-26 22:43:09.351 24723-24723 V/Omni Notes: Finished navigation drawer initialization
12-26 22:43:09.352 24723-24723 V/Omni Notes: Finished main menu initialization
12-26 22:43:09.353 24723-24785 V/Omni Notes: Query: SELECT creation,last_modification,title,content,archived,trashed,alarm,reminder_fired,recurrence_rule,latitude,longitude,address,locked,checklist,category_id,name,description,color FROM notes LEFT JOIN categories USING( category_id)  ORDER BY title||content COLLATE NOCASE  ASC 
12-26 22:43:09.355 24723-24723 V/Omni Notes: Finished categories menu initialization
12-26 22:43:09.973 24723-24785 V/Omni Notes: Query: Retrieval finished!
12-26 22:43:09.975 24723-24785 D/Omni Notes: Dynamic menu finished counting items
12-26 22:43:29.248 24723-25053 E/Error copying file: java.io.FileNotFoundException: /storage/emulated/0/Omni Notes/2019.12.22-11.33/it.feio.android.omninotes_preferences.xml (No such file or directory)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:231)
    at java.io.FileInputStream.<init>(FileInputStream.java:165)
    at it.feio.android.omninotes.utils.StorageHelper.copyFile(StorageHelper.java:158)
    at it.feio.android.omninotes.helpers.BackupHelper.importSettings(BackupHelper.java:275)
    at it.feio.android.omninotes.async.DataBackupIntentService.importData(DataBackupIntentService.java:134)
    at it.feio.android.omninotes.async.DataBackupIntentService.onHandleIntent(DataBackupIntentService.java:83)
    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:76)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.os.HandlerThread.run(HandlerThread.java:65)

12-26 22:43:47.862 24723-25053 D/Omni Notes: Resettings reminders
12-26 22:43:47.871 24723-25053 V/Omni Notes: Query: SELECT creation,last_modification,title,content,archived,trashed,alarm,reminder_fired,recurrence_rule,latitude,longitude,address,locked,checklist,category_id,name,description,color FROM notes LEFT JOIN categories USING( category_id)  WHERE alarm IS NOT NULL AND reminder_fired IS NOT 1 AND archived IS NOT 1 AND trashed IS NOT 1 ORDER BY title||content COLLATE NOCASE  ASC 
12-26 22:43:47.875 24723-25053 V/Omni Notes: Query: Retrieval finished!
12-26 22:43:54.221 25387-25387 D/Omni Notes: start file logger service thread
12-26 22:43:54.219 25387-25387 V/Omni Notes: Started navigation drawer initialization
12-26 22:43:54.227 25387-25387 V/Omni Notes: Finished navigation drawer initialization
12-26 22:43:54.300 25387-25387 D/Omni Notes: initNotesList intent: android.intent.action.MAIN
12-26 22:43:54.304 25387-25407 V/Omni Notes: Query: SELECT creation,last_modification,title,content,archived,trashed,alarm,reminder_fired,recurrence_rule,latitude,longitude,address,locked,checklist,category_id,name,description,color FROM notes LEFT JOIN categories USING( category_id)  WHERE category_id = 1549290266696 AND trashed IS NOT 1 ORDER BY title||content COLLATE NOCASE  ASC 
12-26 22:43:54.381 25387-25387 D/Omni Notes: {navigation=1549290266696, settings_enable_file_logging=true, settings_language=en_US, acra.legacyAlreadyConvertedTo4.8.0=true, settings_password_access=false, acra.legacyAlreadyConvertedToJson=true, settings_send_analytics=true, pref_tour_complete=true, acra.enable=true, acra.lastVersionNr=280}
12-26 22:43:54.511 25387-25407 V/Omni Notes: Query: Retrieval finished!
12-26 22:43:54.596 25387-25387 D/Omni Notes: it.feio.android.omninotes.async.bus.NotesLoadedEvent
12-26 22:43:54.614 25387-25387 V/Omni Notes: Started navigation drawer initialization
12-26 22:43:54.618 25387-25387 V/Omni Notes: Finished navigation drawer initialization
12-26 22:43:54.620 25387-25387 V/Omni Notes: Finished main menu initialization
12-26 22:43:54.623 25387-25417 V/Omni Notes: Query: SELECT creation,last_modification,title,content,archived,trashed,alarm,reminder_fired,recurrence_rule,latitude,longitude,address,locked,checklist,category_id,name,description,color FROM notes LEFT JOIN categories USING( category_id)  ORDER BY title||content COLLATE NOCASE  ASC 
12-26 22:43:54.624 25387-25387 V/Omni Notes: Finished categories menu initialization
12-26 22:43:55.071 25387-25417 V/Omni Notes: Query: Retrieval finished!
12-26 22:43:55.072 25387-25417 D/Omni Notes: Dynamic menu finished counting items
12-26 22:43:58.618 25387-25387 V/Omni Notes: Notes list: onViewTouchOccurred 0
12-26 22:43:58.656 25387-25387 V/Omni Notes: Notes list: onViewTouchOccurred 2
12-26 22:43:58.692 25387-25387 V/Omni Notes: Notes list: onViewTouchOccurred 2
12-26 22:43:58.708 25387-25387 V/Omni Notes: Notes list: onViewTouchOccurred 2
12-26 22:43:58.744 25387-25387 V/Omni Notes: Notes list: onViewTouchOccurred 2
12-26 22:43:58.757 25387-25387 V/Omni Notes: Notes list: onViewTouchOccurred 2
12-26 22:44:00.401 25387-25387 V/Omni Notes: Notes list: onViewTouchOccurred 0
12-26 22:44:00.454 25387-25387 V/Omni Notes: Notes list: onViewTouchOccurred 2
12-26 22:44:00.473 25387-25387 V/Omni Notes: Notes list: onViewTouchOccurred 2
12-26 22:44:01.314 25387-25387 V/Omni Notes: Notes list: onViewTouchOccurred 0
12-26 22:44:01.338 25387-25387 V/Omni Notes: Notes list: onViewTouchOccurred 2
12-26 22:44:02.141 25387-25387 V/Omni Notes: Notes list: onViewTouchOccurred 0
12-26 22:44:02.172 25387-25387 V/Omni Notes: Notes list: onViewTouchOccurred 2
12-26 22:44:02.189 25387-25387 V/Omni Notes: Notes list: onViewTouchOccurred 2
12-26 22:45:04.806 25387-25387 D/Omni Notes: {navigation=1549290266696, settings_enable_file_logging=true, settings_language=en_US, acra.legacyAlreadyConvertedTo4.8.0=true, settings_password_access=false, acra.legacyAlreadyConvertedToJson=true, settings_send_analytics=true, pref_tour_complete=true, acra.enable=true, acra.lastVersionNr=280}
12-26 22:45:28.421 25387-26528 E/Error copying file: java.io.FileNotFoundException: /storage/emulated/0/Omni Notes Foss/2019.12.22-11.33/it.feio.android.omninotes_preferences.xml (No such file or directory)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:231)
    at java.io.FileInputStream.<init>(FileInputStream.java:165)
    at it.feio.android.omninotes.utils.StorageHelper.copyFile(StorageHelper.java:158)
    at it.feio.android.omninotes.helpers.BackupHelper.importSettings(BackupHelper.java:275)
    at it.feio.android.omninotes.async.DataBackupIntentService.importData(DataBackupIntentService.java:134)
    at it.feio.android.omninotes.async.DataBackupIntentService.onHandleIntent(DataBackupIntentService.java:83)
    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:76)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.os.HandlerThread.run(HandlerThread.java:65)

12-26 22:45:46.137 25387-26528 D/Omni Notes: Resettings reminders
12-26 22:45:46.138 25387-26528 V/Omni Notes: Query: SELECT creation,last_modification,title,content,archived,trashed,alarm,reminder_fired,recurrence_rule,latitude,longitude,address,locked,checklist,category_id,name,description,color FROM notes LEFT JOIN categories USING( category_id)  WHERE alarm IS NOT NULL AND reminder_fired IS NOT 1 AND archived IS NOT 1 AND trashed IS NOT 1 ORDER BY title||content COLLATE NOCASE  ASC 
12-26 22:45:46.141 25387-26528 V/Omni Notes: Query: Retrieval finished!
federicoiosue commented 4 years ago

It seems that configurations are mixing during the translation between the two distribution channels of the app.

Thanks for reporting, I'll dig further asap

echeoquehaii commented 4 years ago

I just faced the same problem today, I was updating the app from F-Droid, which is still on 5.x version. With the apk from GitHub I cannot restore my backup. Here is the log:

01_05_19_00.txt

echeoquehaii commented 4 years ago

Update: I noticed one error in the log was the preferences xml file. My old Omni Notes version's backup was called it.feio.android.omninotes_preferences.foss.xml, while the new one doesn't have the ".foss" part. But even renaming it to match it didn't solve the issue.

EDIT: Sorry, it was my fault, I didn't notice the option to "Restore OLD backup". Using that it is indeed restoring the backup, BUT actually the backup is not complete. I had a fast look at the backup file and it seems like the 5.5.2 FOSS version is not backing up all the notes, that's strange. I will try to dig further. Also there is no option to save the log in that version, so I cannot help you with that.

federicoiosue commented 4 years ago

I've replicated and the workaround actually works: just rename the preferences file by removing the ".foss" postfix to the name and data restore will finish correctly Schermata 2020-01-08 alle 14 18 42

I'm keeping the issue opened to fix the notification (that reports data restore done even when error occurs)

echeoquehaii commented 4 years ago

Dear Federico, thanks for your help! Yes, the renaming seem to work, but in doing that I found a strange behaviour, it seems like my OmniNotes FOSS is backing up only notes older than 4 months. The ones saved in the last 4 months are, for some strange reason, not being included in the backup. Should I open another bug for that? The OmniNotes FOSS version didn't have the option to save logs so I don't know how to give you more info.

federicoiosue commented 4 years ago

@ghoppaccia very strange, actually the whole database is copied during backup process in older versions (FOSS included).

Could be a problem on the latest version instead. In the test I made I created from scratch 6-7 notes with different characteristics and performed a backup create-restore (5.5.4 FOSS -> 6.1.0 Beta) without noticing anything wrong except what stated before.

Wilker-uwu commented 4 years ago

for solving the read error, you can make it so it checks if it can read the file (and properly sanitize it when applicable) instead of judging by the name, no?

federicoiosue commented 4 years ago

Actually I kept the issue opened to work on error management: if that blocks the backup restoration the user must be informed and some action/workaround must be triggered.

For what concerns cross-flavor (flavor is the technical name used to distinguish different publishing branches of the app; ON currently has published APKs for: play(Store), Beta, Alpha, FOSS(F-Droid)) backups restore is a correct behavior to not allow it. Different flavors could differ quite a lot and so, while new versions must ensure retro-compatibility with previously created backups, the same thing doesn't applies to flavors.

echeoquehaii commented 4 years ago

@ghoppaccia very strange, actually the whole database is copied during backup process in older versions (FOSS included).

Could be a problem on the latest version instead. In the test I made I created from scratch 6-7 notes with different characteristics and performed a backup create-restore (5.5.4 FOSS -> 6.1.0 Beta) without noticing anything wrong except what stated before.

That's what I also thought at first, but then to do a double check I tried to import that backup to the same version of Omni Notes FOSS and the last 4 months notes were not showing up again, that's why I thought it's the backup's problem. I tried several times and the problem was always there. Anyway, it's not a issue for me, luckily I just had around 8-9 notes so I could just copy paste them, I just thought I had to mention it to you, hopefully it's not affecting other people.

rugk commented 4 years ago

The app's backup/sync system is totally broken. It seems to delete everything if you import an invalid backup. (It should at least show an error message and not make me loose all old data! I.e. check before importing whether it would work… and show me why it does not if it does not!!)

Also, I never managed to import a backup back. It just deletes the old data.

Also(!) I don't even know it deletes the data. I thought it maybe just adds it to the existing one. So please add a big warning: "This process deletes all your existing data and imports the new one.**

bozicm commented 2 years ago

For me what worked consistently for last FOSS 5.5.2 version was:

This procedure worked on both 6.1.0 (beta) and 6.1.0 Alpha 2.

For Alpha 2: this worked in spite of ... it.feio.android.omninotes.alpha_preferences.xml: open failed: ENOENT (No such file ..

federicoiosue commented 2 years ago

@bozicm did you tried the latest version on Play Store?

May you provide a list of the files the archive contains (just the first folder level)?

bozicm commented 2 years ago

@bozicm did you tried the latest version on Play Store?

Yes, worked in 6.0.5 too.

May you provide a list of the files the archive contains (just the first folder level)?

Example for looking into the old folder:

Internal Memory > Omni Notes Foss > 2020.09.03-22.43 > 2020.09.03-22.43

files/
it.feio.android.omninotes.foss_prefereferences.xml
omni-notes

EDIT: fixed typo in folder with date format.

federicoiosue commented 1 year ago

Restoration of legacy backups is not available anymore starting from 6.2.0 so I'm closing the issue as it's no more actual.