Archives
An archive is a folder, for example Archive.mailarc. Inside are:
- packs: compressed files holding the original message bytes;
- evidence logs: append-only journals recording where and when each message was seen, chained by hashes;
- seals: checkpoints that fix those chains;
- a catalog: a database built from the logs, for browsing;
- a search index: rebuilt from the archive at any time.
Do not edit anything inside by hand. Every tool opens the archive through a lock: one writer at a time (import, sync, seal), or any number of readers (search, verify, export, the reader app).
Create
mailarc init ~/Mail/Archive.mailarcThe folder must not exist yet. mailarc never overwrites or deletes an existing one.
Upgrade to version 2
Accounts and sync need archive format version 2:
mailarc upgrade ~/Mail/Archive.mailarc --to-version 2The upgrade keeps every stored message and log byte for byte, but older mailarc versions can no longer open the result, and there is no way back. Make a backup copy first. Version 2 is still being validated.
Check
mailarc verify ~/Mail/Archive.mailarc # re-hash every message and check every log
mailarc verify ~/Mail/Archive.mailarc --deep # also check the catalog databaseverify only reads. It reports problems; it never repairs anything. Exit code 0 means everything checked out.
Rebuilding the catalog
A sync, import or seal opens the archive for writing in a moment. It checks that the catalog still ends exactly where the logs and packs end, and carries on from there. If anything does not match, for example after a crash, or when the catalog was changed by hand or by an older mailarc, it rebuilds the catalog from the logs first. That takes longer on a large archive, about half a minute per 100,000 messages.
To rebuild the catalog on purpose, run mailarc rethread ARCHIVE. Rereading every stored message is the job of mailarc verify, not of opening.
Jobs
Every import and sync is recorded as a job, with its status and how many messages it committed:
mailarc jobs ~/Mail/Archive.mailarcA job interrupted by a crash or power loss shows as interrupted; the next run of the same import or sync continues from what was committed.
Statistics
mailarc stats ~/Mail/Archive.mailarc # an overview as text
mailarc stats ~/Mail/Archive.mailarc --json # every number, for scriptsstats shows what the archive holds: messages, conversations and their dates, sizes on disk, messages by year, each account with how many messages its server no longer has and its last clean run, the largest folders, attachments by kind, the largest messages, and whether the search index and daily seal are current. It only reads, and may run while the reader app has the archive open. On a million messages it takes about 15 seconds. The reader app shows the same numbers with charts.
Daily seal
Each day the archive records a sealed snapshot of its logs. A sync or import does this as it closes, so if you sync daily nothing else is needed. Otherwise schedule mailarc seal ARCHIVE once a day; see Syncing on a schedule.
Backups
The archive is a plain folder. Back it up while no import or sync is running, or copy it with your backup tool and run mailarc verify on the copy. The catalog and search index are rebuilt from the packs and logs if they go missing, so packs, evidence and seals are what matter most.
Account settings are not in the archive. Back up the account settings file separately; see Where the settings live. Passwords are in your system's keychain and are not part of either.
For a second copy you can read on another computer, see Take your archive on a flash drive.
Moving or sharing an archive
An archive contains no passwords and no references to them. Someone who gets a copy can open it in the reader app and search it, but cannot sync it until they add their own account. The archive is not encrypted: anyone with the folder can read the mail in it. Encryption is planned for after version 1. Searches saved in the archive itself, with the desktop app, come along.
Copying messages to another archive
mailarc copy copies the messages a search matches from one archive into another:
mailarc copy ~/Mail/Archive.mailarc ~/Mail/Project.mailarc 'from:[email protected] after:2024-01-01'- The messages arrive in the same folders, with their labels and flags, under accounts marked as copied. A message in three folders arrives in the same three.
- A message the other archive has already is stored only once; it gains the copied folders.
- The source archive is only read, and may stay open in the reader app. The destination must be version 2 and not open in another program.
- Each copy records where it came from: the source archive's ID and the message's position in its evidence log. The two archives' logs stay separate.
- Spam is left out, as in a search, unless the query says
is:spamor names its folder within:. Add--include-spamto copy the spam a query matches too. To copy a whole archive:mailarc copy SOURCE DESTINATION '' --include-spam. - Messages are written in batches of up to 256, and each batch is saved durably at once.
- Ctrl-C stops after the current batch is written. Everything copied so far stays; run the same command again to finish. Messages already copied are reported as already there, and nothing is written for them.
- Afterwards the destination's search index is brought up to date, if it has one.
The selection comes from the source's search index, as for mailarc export; if that index is behind, the command says so. The desktop app copies selected messages too; see Copying to another archive.