10

How can signal-desktop messages be exported?

I want to backup my correspondence.

Is it possible at all?

1 Answer 1

15

Yes, it is possible.

Just save this in a file <yourFilename>:

sigBase="${HOME}/.config/Signal/";
key=$( /usr/bin/jq -r '."key"' ${sigBase}config.json );
db="${HOME}/.config/Signal/sql/db.sqlite";
clearTextMsgs="${sigBase}clearTextMsgs.csv";

/usr/bin/sqlcipher -list -noheader "$db" "PRAGMA key = \"x'"$key"'\";select json from messages;" > "$clearTextMsgs";

and call it via bash <yourFilename>. Or render it executable with chmod 700 <yourFilename> and call it directly: ./<yourFilename>

This script uses sqlcipher and jq with signal-desktop's database key to open, decrypt and extract all messages in JSON format into clearTextMsgs.csv inside your signal-desktop folder ~/.config/Signal.

Besides the key extraction by filtering JSON with jq (from ~/.config/Signal/config.json), the crucial bit happens here:

sqlcipher -list -noheader <DB> <SQL>

where <SQL> contains the PRAGMA key definition and the actual SQL statement (SELECT json FROM messages;).

One can then use jq to access any key/value from the messages backup.

You have to install sqlcipher and jq for that:

sudo apt install sqlcipher jq

Note:

While this does extract all messages, we need to specify that "all" in signal-desktop has the meaning of "all messages actually loaded". So, in order to extract every single message, the slider of the active contact has to be slid way up, then signal-desktop will load previously not availalble messages (lather rinse repeat until satisfied). Do so as far in the past you would want your messages loaded. This gets tedious quite quickly. Remember to do so for all of your contacts' histories.

Having that said, it is technically feasable to backup your message history, in practice it is a manual job. A way around this might be a cron job backing up all recent messages, maybe once a day. Then this is likely to contain duplicates and might miss messages in case signal-desktop has been restarted.

In any case, this method is working fine if the (not too far -- read: a couple of months maybe) history is to be searched programmatically once in a while.

7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.