SecUSo / privacy-friendly-backup

Backup Application for PFAs
https://secuso.aifb.kit.edu/105.php
GNU General Public License v3.0
32 stars 4 forks source link

Can't restore To-Do List backup from old phone #17

Open kidhanis opened 1 year ago

kidhanis commented 1 year ago

I’m trying to migrate data from an old phone to a new one using Privacy Friendly Backup. However, I can’t restore data from the backup file generated by the app. I tried wiping the data from both apps in both phones, but restoring still didn't work in either phone.

To-Do List version: 2.4.2 Backup version: 1.3 Old Phone: Zenfone 2 running Marshmallow New Phone: Samsung Galaxy S10e running Android 11

Observed behavior

I find this error in the logcat when trying to restore the data: SQLiteLog: (1) no such table: sqlite_sequence

I made a backup in the new phone, which is a fresh app install with just a few new tasks, and restore works fine in this case. I then compared the contents of this backup with the backup of the old phone, and I noticed two main differences in the JSON format:

  1. The order of objects in the content array is different: in the new phone, the todo_list object (the one that starts with \"tableName\":\"todo_list\") is first in the array, while in the old phone it comes last. This array also contains the sqlite_sequence object, so the error shown above might come from here.
  2. The todo_list table is described in the backup file of the old phone like this: CREATE TABLE todo_list (\\n\\t_id\\tINTEGER PRIMARY KEY AUTOINCREMENT,\\n\\tname TEXT NOT NULL\\n) These control characters don't show up in the backup of the new phone, and this output matches the table format found in privacy-friendly-todo-list/app/src/main/assets/from_1_to_2.sql I've used this app since at least 2018, so I believe that the To-Do List app in the old phone used to have the old database version and this script migrated the database to the new version.

Workaround

I found a workaround due to the observations described above: after moving the todo_list object to the first position in the array, restoring works in both phones, so now I can see all the data in the new phone. Any subsequent backup I make can be restored without issues.

Expected behavior

Successfully restore data to new phone without having to modify the backup file.

Steps to reproduce

This can all be done with one phone.

  1. Install version 1.0.1 of To-Do List, which had the old database version
  2. Add lists and tasks in the app
  3. Upgrade To-Do List to version 2.4.2
  4. Go to the Backup app and make a backup of To-Do List. If you inspect the backup and expand "database" -> "content", the fourth and last Object in that array should be the todo_list object.
  5. Wipe data of To-Do List
  6. Restore the backup. To-Do List will still be empty if the backup wasn't restored.
  7. To make the backup work, export it and edit the file to move the todo_list object to the first position in the content array instead of the fourth. Then, import back to the Backup app and try steps 5 and 6 again.