bepaald / signalbackup-tools

Tool to work with Signal Backup files.
GNU General Public License v3.0
790 stars 38 forks source link

Unsuccessful merge feedback #61

Closed lnoss closed 1 year ago

lnoss commented 2 years ago

Hello!

I followed all the instructions, the merge is successful... but it fails when the merged backup is imported in Signal. It starts importing and then after a while, it crashes. I notice nothing except warnings about stickers, attachment data not found, sms reactions, etc.

No success with importing the oldest backup (version 119) and export it again to have two backup in the same version (version 130). Same problem when importing the merged backup.

Thanks.

Edit: crash logs contain a SQLiteConstraintException on a foreign key.

bepaald commented 2 years ago

Thanks for your feedback, I'm wondering if you are running into the same problem as here: https://github.com/signalapp/Signal-Android/issues/12048#issuecomment-1065883028

If you are, that would not be a problem with the merge, but in Signal. Obviously you have imported the old backup (to get it up-to-date) but did you try to import the newest backup as well? It may crash with the same error.

If the crash really only occurs with the merged backup, the output of the merge might actually have some interesting info for me.

Thanks!

bepaald commented 2 years ago

If you are running into the issue I linked above, and it also occurs with the (unmerged) new backup, there may be an easy fix if you don't want to wait for a fix in Signal itself by the way. Let me know.

lnoss commented 2 years ago

I will try to follow your advices a bit later, thanks for trying! I'll keep you posted.

lnoss commented 2 years ago

I tried to import the backups separately and they both work. The merged one doesn't and the exception is the same than in the other issue.

lnoss commented 2 years ago

I tried to import the merged backup in Signal beta channel, it still crashes. I don't really know if it is worth it to import the backups (so still in beta) and export them before merging them again... Should I try no check where the foreign key is not validated?

bepaald commented 2 years ago

I tried to import the backups separately and they both work. The merged one doesn't and the exception is the same than in the other issue.

Thanks, I'm afraid that does mean there is a bug in my code. There have been some changes in the signal database recently that I needed to handle, I hoped I had but apparently I have more work to do. I'll investigate and work on it as soon as I have time.

Should I try no check where the foreign key is not validated?

If you can, that would be probably very helpful, because I'm not sure which table is giving you the trouble. I just tested merging some of my backups which contain the newest tables, and restoring that merged file seems to work fine (but the tables in my database do not have many entries yet, so I might be lucky).

If you can not find out which foreign key constraint fails, you might try signalbackup-tools [merged.backup] [pwd] --runsqlquery "DELETE FROM msl_payload" --runsqlquery "DELETE FROM msl_message" --runsqlquery "DELETE FROM msl_recipient" -o [output]. That should hopefully take care of it, assuming the problem is in the same tables as others have had lately. (and, though it wouldn't actually solve the bug in this program, it would tell me where to look for it)

bepaald commented 2 years ago

I can't say I'm making much progress on this (though I've had little time). Did you manage to find out which foreign key is giving issues? Or try my other suggestion?

If neither is possible, I would love to see the output produced by the program when merging, it might give me a few hints...

lnoss commented 2 years ago

I didn't forget. I just got overwhelmed. I'll look into it!

lnoss commented 2 years ago

Right, things are never simple. The task image-editor-app:compileDebugUnitTestKotlin is failling when I'm compiling (unresolved reference for junit). I need to look for similar issues.

bepaald commented 2 years ago

No worries! Sorry, didn't mean to rush you, I know all about being busy. Take all the time you need.

bepaald commented 2 years ago

Hi, there have been some code changes that could possibly affect this issue. If you have the time and inclination, you might want to try the merge again with the current version. I would love to hear if anything has changed. Thanks!

bepaald commented 2 years ago

Hi. I'm nearly 100% sure this is fixed now (if it wasn't before). From a log sent by another user running into this problem (through email), I'm fairly certain I found the cause of this. I thought sqlite would enforce the foreign key constraints when set on a table, but it turns out it doesn't by default. Apart from fixing all(?) possible causes of key constraint violations, the program now also checks for violations and prints a useful error message if one is found. So, whenever you have time, please try again and report back. Thanks!

lnoss commented 2 years ago

Ugh... Sorry for the delay you could have fixed it sooner then. I will check Tuesday to confirm. Thanks. Edit : so I think it worked for one of the backup, but I need to test with another backup that I don't have at hand, I'll check on Friday.

bepaald commented 1 year ago

Just for cleanup and lack of response, I'm assuming this is fixed or impossible to re-test. Please feel free to open a new issue if this is still a thing. Thanks!