# Daily exporting of all of your messages in a compact textual archive

**URL:** <https://forum.delta.chat/t/daily-exporting-of-all-of-your-messages-in-a-compact-textual-archive/4884>\
**Category:** Show and Tell\
**Tags:** open-standards\
**Created:** [March 11, 2026, 4:29pm UTC](https://forum.delta.chat/t/daily-exporting-of-all-of-your-messages-in-a-compact-textual-archive/4884 "2026-03-11T16:29:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ian](https://forum.delta.chat/user_avatar/forum.delta.chat/ian/32/3164_2.png) [@ian](https://forum.delta.chat/u/ian)\
**Post date:** [March 11, 2026, 4:29pm UTC](https://forum.delta.chat/t/daily-exporting-of-all-of-your-messages-in-a-compact-textual-archive/4884/1 "2026-03-11T16:29:33Z")

</div>

```bash
#!/bin/sh

get_fingerprint() {
cat << EOF |
select fingerprint
from keypairs join public_keys
on keypairs.public_key == public_keys.public_key
order by is_default
desc
limit 1
;
EOF
    sqlite3 -csv -batch "$1"
}

get_messages() {
  local PRINT

  readonly PRINT="`get_fingerprint "$DB"`"
cat << EOF |
.separator "&&"

select
 '${PRINT}' as profile,
 m.chat_id as chat_id,
 m.id as m_id,
 datetime(m.timestamp, 'unixepoch') as date,
 replace(replace(replace(replace(replace(
  case when instr(concat(char(10),m.param,char(10)),concat(char(10),'S=30',char(10)))>0 then m.param else m.txt end,
  '&','&amp;'),'\"','&quot;'),'<','&lt;'),'>','&gt;'),char(10),'<br>') as data,
 case
  when instr(concat(char(10),m.param,char(10)),concat(char(10),'S=30',char(10)))>0 then 2
  when instr(concat(char(10),m.param,char(10)),concat(char(10),'S=32',char(10)))>0 then 1
  else 0 end as xdc,
 coalesce(c.fingerprint, '') as fingerprint,
 m.timestamp as timestamp
from msgs as m join contacts as c
on m.to_id>0 and m.to_id==c.id
or m.to_id==0 and c.id==1
where from_id==1
and deleted==0
and (
 hidden==0
 and instr(concat(char(10),m.param,char(10)),concat(char(10),'S='))==0
 or 1==$NEEDWEBXDC
  and (
   instr(concat(char(10),m.param,char(10)),concat(char(10),'S=30',char(10)))>0
   or instr(concat(char(10),m.param,char(10)),concat(char(10),'S=32',char(10)))>0
  )
)
order by m.chat_id, m.id
;

EOF
  sqlite3 -csv -batch "$1" |
  sed -r '
    s~(&)""(&)~\1\2~g
    s~"(.)~\1~g
  '
}

cat_db() {
  local DCDIR DB
  find ~ -mount -type d -name "DeltaChat" |
  while read -r DCDIR; do
    find "$DCDIR" -mount -type f -name "dc.db" |
    while read -r DB; do
      echo "$DB" >&2
      get_messages "$DB"
    done
  done |
  sort -u --compress-program=gzip
}

main() {
  local OUTDIR OUTALL NEW
  [-n "$NEEDWEBXDC"] || NEEDWEBXDC=1
  readonly OUTDIR="$HOME/cache/chat/delta-chat"
  readonly OUTALL="$OUTDIR/mymsgall-3.csv.gz"
  mkdir -p "$OUTDIR" || exit 1
  readonly NEW="`mktemp --suffix="dcmsg.tmp.csv.gz"`"

  {
    cat_db

    zcat "$OUTALL" 2>/dev/null
  } |
  sort -u --compress-program=gzip |
  gzip -9 > "$NEW"

  mv "$NEW" "$OUTALL"
}

main "$@"

```

## Related

> [@Export Chat to zip](https://support.delta.chat/t/export-chat-to-zip/1225/1):
>
> This is a note about the progress on the current plan of implementing Exporting Chats to an universal format for use for archival or as proof of something. This is just meant as a todo-list/issue and not as an open feature discussion, if you want to propose an better idea please do so in a new or existing Feature Proposal topic. You may post small improvement ideas here as long as they don’t blow up the scope like “re-importing the exported chat”. The current idea is just to have something li…

> [@App/feature request: export an entire chat's transcript](https://support.delta.chat/t/app-feature-request-export-an-entire-chats-transcript/4433/1):
>
> I’m trying to create a word cloud using text from my conversations among friends from different chat groups we share as a birthday card. In order to do this, I need all the raw text data from our chats. Exporting chat content from Instagram and Messenger was a breeze, Signal is impossible and, though I thought this would be simple in delta chat, there does not seem to be a way to export a chat transcript with metadata from delta chat (as a JSON, for example, with timestamp, sender display name, …

> [@Export/backup single chat](https://support.delta.chat/t/export-backup-single-chat/1183/1):
>
> Background: Someone deleted a chat accidentally. To get lost information there should be a possibility to backup/export (undo) a full chat and import it again. Request is: a function to export a chat to a single file (chat-backup-file) a function to import that chat-backup-file it should be possible to import that chat-backup-file at any DC installation (!) When someone losts a chat completely (e.g. friend1) there is always a second backup at “friends device” (friend2)! So the best approac…

> [@Delta Chat überfordert mich: wie lassen sich Chat-Nachrichten exportieren?](https://support.delta.chat/t/delta-chat-uberfordert-mich-wie-lassen-sich-chat-nachrichten-exportieren/1720/1):
>
> Ich würde das tolle DC-Programm gerne für mich produktiv einsetzen, allerdings gibt es immer noch scheinbar unlösbare Schwierigkeiten. Vielleicht fehlt mir auch nur die generelle Erfahrung mit Chat-Programmen. Ich möchte die Chat-Nachrichten in meinem normalen E-Mail-Programm archivieren und in DC später löschen. Der Grund ist, dass ich die Nachrichten nur an einem Ort ‘archivieren’ will. Bislang habe ich dafür noch keine funktionierende Lösung gefunden. Die Funktion ‘Chats auf externem Speiche…
