bepaald / signalbackup-tools

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

Successful merge feedback #76

Closed mivanit closed 1 year ago

mivanit commented 2 years ago

I used the merge backup feature to merge backups of sizes ~14gb and ~110mb, and everything seems to work fine!

I've made pr #75 to the readme describing the default password behavior when none is specified -- I presumed that it would generate a new one but it actually uses the password of the second (last?) backup specified.

I haven't checked everything in detail (obviously) but the total number of messages and attachments both seem correct. This was done with backups version > 140, if that's useful.

Below are the errors/warnings I noticed from the logs. I didn't save the full logs, but searching for error or warning only returned items of the types below.

non-unique storage key

It might be worth noting that the passwords to the different backups were different, and the backups were non-overlapping with a gap of several weeks

section of log ``` Importing statements from source table 'storage_key'...8 entries... Error : After sqlite3_step(): UNIQUE constraint failed: storage_key.key Query: "INSERT INTO storage_key (_id,type,key) VALUES (?,?,?)" Error : After sqlite3_step(): UNIQUE constraint failed: storage_key.key Query: "INSERT INTO storage_key (_id,type,key) VALUES (?,?,?)" Error : After sqlite3_step(): UNIQUE constraint failed: storage_key.key Query: "INSERT INTO storage_key (_id,type,key) VALUES (?,?,?)" Error : After sqlite3_step(): UNIQUE constraint failed: storage_key.key Query: "INSERT INTO storage_key (_id,type,key) VALUES (?,?,?)" Error : After sqlite3_step(): UNIQUE constraint failed: storage_key.key Query: "INSERT INTO storage_key (_id,type,key) VALUES (?,?,?)" Error : After sqlite3_step(): UNIQUE constraint failed: storage_key.key Query: "INSERT INTO storage_key (_id,type,key) VALUES (?,?,?)" Error : After sqlite3_step(): UNIQUE constraint failed: storage_key.key Query: "INSERT INTO storage_key (_id,type,key) VALUES (?,?,?)" Error : After sqlite3_step(): UNIQUE constraint failed: storage_key.key Query: "INSERT INTO storage_key (_id,type,key) VALUES (?,?,?)" Importing statements from source table 'mention'...0 entries... Importing statements from source table 'payments'...0 entries... ```

entries in usually empty tables

this one comes up many times, always right after Compacting table: payments (_id)

I've never made any payments with signal though, as far as I can recall

section of log ``` setMinimumId mention compactIds Compacting table: mention (_id) setMinimumId reaction compactIds Compacting table: reaction (_id) setMinimumId notification_profile Adjusting 'notification_profile_allowed_members.notification_profile_id' to match changes in 'notification_profile' Adjusting 'notification_profile_schedule.notification_profile_id' to match changes in 'notification_profile' compactIds Compacting table: notification_profile (_id) setMinimumId notification_profile_allowed_members compactIds Compacting table: notification_profile_allowed_members (_id) setMinimumId notification_profile_schedule compactIds Compacting table: notification_profile_schedule (_id) setMinimumId payments compactIds Compacting table: payments (_id) WARNING : Found entries in a usually empty table. Trying to deal with it, but problems may occur. setMinimumId storage_key compactIds Compacting table: storage_key (_id) setMinimumId sender_key_shared compactIds Compacting table: sender_key_shared (_id) setMinimumId sender_keys compactIds Compacting table: sender_keys (_id) setMinimumId pending_retry_receipts compactIds Compacting table: pending_retry_receipts (_id) setMinimumId avatar_picker compactIds Compacting table: avatar_picker (_id) setMinimumId distribution_list Adjusting 'recipient.distribution_list_id' to match changes in 'distribution_list' Adjusting 'distribution_list_member.list_id' to match changes in 'distribution_list' compactIds ```

attachment data not found

there are a bunch of messages (~4k) like the following after Writing SqlStatementFrame(s)...

Dealing with table 'part'... 123/12345 entries...Warning: attachment data not found (rowid: 1243, uniqueid: 1234567789012)
bepaald commented 2 years ago

Thank you so much for you report, it is always good to hear when things are still working.

I've made pr #75 to the readme describing the default password behavior when none is specified -- I presumed that it would generate a new one but it actually uses the password of the second (last?) backup specified.

Yes, I noticed, I will respond to that one right after this.

non-unique storage key [...] entries in usually empty tables [...]

These are actually both an indication of the same problem. I have never seen a backup file with entries in the 'storage_key' table, I'm not sure how to get entries in that table, and so I have never tested it properly. I had the program set up to try and deal with that table in a somewhat default way (but issue a warning), but I have now been reading Signal's source code and made adjustments. Hopefully (though I am unable to test), the errors and warnings concerning this table should now be gone. The solution, by the way, is to delete the double key entries before the merge. In your case, this wasn't done and thus the program failed to insert the double entries during merge. This causes an ugly error, but results in the exact same database as the program with the fix would create. So, thanks for reporting!

attachment data not found

This is a recurring problem. Really there is no error here, the attachment data is simply not there. Not too long ago I thought I had finally figured out under what circumstances this happened and suppressed the warning in those cases (fc1ddba0ede08e3f81288a5204179fe81496b0f5), but apparently not. You might be able to help me by running signalbackup-tools [input] [password] --scanmissingattachments on the merged backup. Though given the number of warnings, it will probably generate a lot of output. It might help me further understand when attachment data is expected to be missing.

Anyway, thanks again. Your report helped fix a small error in the program. Even so, I see no problems in you rmerge so I hope everything is working for you. If you encounter any problems later on, please let me know!

mivanit commented 2 years ago

Thanks! I really appreciate all the work you've put into this project, its super useful. I did not mean to complain about the errors -- I just thought it might be useful to provide them.

I'll scan for missing attachments and post the results here when I get the chance.

bepaald commented 2 years ago

Thanks! I really appreciate all the work you've put into this project, its super useful. I did not mean to complain about the errors -- I just thought it might be useful to provide them.

No worries, I'm very happy the program has been useful to you. I didn't think you were complaining, I really appreciate you taking the time to provide this useful feedback.

I'll scan for missing attachments and post the results here when I get the chance.

Cool, whenever you have time, no rush.

Thanks again!

ChiIIBiII commented 1 year ago

Hi, I also just merged my Signal backups. Amazing tool, worked flawlessly as far as I can tell, thank you so much! The only irregularity I could spot was the message "NOTE: Dropping column 'sms.reactions' from source : Column not present in target database". This might be the result of merging two different versions of databases, idk, I don't see any dropped messages though, but since I don't know what sms reactions are I don't know where to look for - at the same time because of that it probably really does not matter.

One feature that might be valuable would be the option to only print warnings, I probably had over a thousand lines of output and will not read through all of them. Also the default behaviour without the database password is still missing in the readme.

Minor stuff, awesome tool, Cheers :)

bepaald commented 1 year ago

Hey, thanks for the feedback! Glad it worked.

Yes, the 'dropping column' message is because of the differing database versions. When 'sms reactions' were introduced they were stored in a column of the message table in the database. But at some later time, they were moved to their own separate table. Message reactions are the quick emoji reactions you can leave on a message (see https://support.signal.org/hc/en-us/articles/360039929972-Message-Reactions). If there were any in the old database they will not have transferred over (since they were in the dropped column). If this is really important to you, you should just try to import en re-export the old backup so the Signal app will do the conversion, then do the merge again. If the old backup is too old to be imported, I could probably write something to save them if you really need (though it will take some time).

I agree the program is overly verbose. On the other hand, it is a program that has issues often enough to want a decent amount of output (if not for the user, for me, cause I can usually tell what the problem is from the output). Though somewhere on my to-do list is that I should output a lot less to the console and have the program write the full output to some log-file.

Thanks again for your feedback!

ChiIIBiII commented 1 year ago

Hey, no problem, no I don't need sms reactions I don't think it would be worth the work. As for the output, maybe add a quiet flag to supress non-warning/error output? Anyway, not a priority of course

jirislav commented 1 year ago

Hi, I'd like to note that I was also able to successfully merge two backups created today with latest Signal App, thanks for your work! ❤️

Note that I've used the fedora docker image.

Btw, the script failed when provided with the newer backup first, but when switched, it succeeded.

bepaald commented 1 year ago

Hey thanks! Happy to hear it.

Btw, the script failed when provided with the newer backup first, but when switched, it succeeded.

I've heard this before, but never could find a cause. I assume the program failed to generate a backup at all? Do you remember the programs output (there were probably some errors printed)? Do you know what versions the two databases were (or the dates)? Thanks!

jirislav commented 1 year ago

Sorry, I didn't keep the log output, I was just happy it worked the other way around. But I'm pretty sure that both backups were created the same day (3 days ago) with latest Signal app, where one had messages until ~ April 1st and the other had from that point onward (basically migration to a new phone without using the built-in backup & restore feature).

The backup with older data had to be first and with newer data had to be second.