Exporting an account
Bongo can build a ZIP of one account’s own data: mail, contacts and calendars.
Users start it themselves at Settings, then “Export account”
(/settings/export). Administrators can start the same export for a user they
manage, from the user’s page in the admin area.
What is in the ZIP
| Entry | Content |
|---|---|
mail/{NNN}-{name}.mbox |
One mbox file per own mailbox, in the mboxrd format. |
contacts/contacts.vcf |
All contacts of all own address books (the default book included) as vCard, the same file as the contacts export. |
calendars/{NNN}-{name}.ics |
One ICS file per own calendar, with its events, and its tasks for a calendar that holds tasks. A subscription calendar is included and marked "subscription": true in the manifest. |
manifest.json |
Always the last entry: format_version, user_id, created_at, requested_by_admin, one record per file (path, kind, name, count, bytes, sha256), missing_blobs, excluded and notes. |
File names inside the ZIP are the mailbox or calendar name with every character
outside A-Z a-z 0-9 . _ - replaced by _, shortened, and prefixed with a
running number, so a name such as ../x cannot become a path. The manifest
maps each entry back to the real name.
Not included, and listed under excluded in the manifest: shared folders,
shared address books and shared calendars, because they are other people’s
data. Message flags (read, starred) and tags are not included either, so that
every message is written byte for byte.
A message whose stored content is missing is skipped and counted in
missing_blobs; it does not stop the export.
The export is not a snapshot. Mail that arrives while it is being built may or may not be in it.
Mbox format and line endings
The mbox files use mboxrd quoting: a body line that starts with From (after
any number of >) gets one more >. Each message starts with a
From MAILER-DAEMON {date} line carrying its internal date.
bongo-import mbox reads this back and restores every message. It removes one
> from each line that matches >...From , which is what mboxo and mboxrd
writers do. (Earlier versions left >From lines as they were.)
- A message with CRLF line endings, as nearly all mail has, comes back byte for
byte: same count, same
Message-ID, same bytes. - A message stored with bare LF endings, or without a final line break, comes back with CRLF endings and a final CRLF.
bongo-importrefuses a line over 10 MiB.
Building, limits and download
The ZIP is built in the background and streamed to a temporary file under the
data directory. Mail is read one message at a time, so a large mailbox does not
fill memory. Contacts and calendars are not streamed: all of the account’s
contacts are loaded together to write contacts.vcf, and all of its events and
tasks are loaded together and then written one calendar at a time, each
calendar’s ICS file encoded in memory before it is added. Events, tasks and
contacts are small inline records, so this matters only for an account with a
very large calendar or address book. The export is offered for download for 24
hours, only to the person who started it, and is then deleted.
- One export is built at a time per account, whoever started it.
- One export a day for each requester and account. An administrator’s export does not use up the user’s own, and failed builds do not count.
- A node builds at most two exports at once, and refuses to start one while disk space is low (503). A running build checks again before each mailbox, every 100 messages, before the contacts, before each calendar and before it finishes; if disk space has become low it stops, removes its partial file and is marked failed (which does not use up the day’s export).
- Over a limit the answer is 429 with
Retry-After.
An export started by an administrator is listed and downloadable only by that administrator, and only while their scope still covers the user. The user never sees it. Every download request is authorised again; an export that is absent, expired, another account’s or another person’s is the same plain 404.
Where the files live, and clusters
Export state is node-local. Nothing goes through Raft and there is no Pebble key, so there is nothing to upgrade across a mixed-version cluster.
- Archives are at
{data_dir}/exports/{user_id}/{export_id}.zip, with a small JSON record next to each ({export_id}.json: status, who requested it, times, size and SHA-256). Directories are mode 0700, files 0600. - Ready exports survive a restart. A build that was running when the process stopped is marked failed at the next start and its partial file is removed.
- In a cluster, an export exists on the node that built it. The settings page lists, and a download works on, that node only; another node answers 404. The limits above are per node as well. Production runs one node.
- Every node sweeps its own files hourly and at start: expired exports, partial files with no build, and the whole directory of an account whose profile no longer exists on that node. Deleting an account also stops its running build and removes its files at once on the node that handles the deletion, and no new export of that account can start while the files are being removed. A build that finishes after its account’s profile is gone on that node (deleted there or elsewhere) is discarded: no archive and no record are kept.
Log lines carry the export: prefix and name user ids, export ids, counts and
sizes, never mailbox names or message content.