Skip to content
GitHub stars

Setup Guide

Install Release

macOS / Linux:

Terminal window
curl -fsSL https://msgvault.io/install.sh | bash

Windows (PowerShell):

Terminal window
powershell -ExecutionPolicy ByPass -c "irm https://msgvault.io/install.ps1 | iex"

The installer detects your OS and architecture, downloads the latest release from GitHub Releases, verifies the SHA-256 checksum, and installs the binary.

Verify the installation:

Terminal window
msgvault --help

Conda-Forge

If you use conda or pixi:

Terminal window
# Using pixi (recommended)
pixi global install msgvault
# Using conda
conda install -c conda-forge msgvault

Build From Source

Requires Go 1.25+ and a C/C++ compiler (GCC or Clang). CGO is required because msgvault uses mattn/go-sqlite3 (SQLite with FTS5) and go-duckdb (Parquet analytics), both of which compile native extensions.

Terminal window
git clone https://github.com/wesm/msgvault.git
cd msgvault
make install

Installs to ~/.local/bin or $GOPATH/bin. For a debug build use make build, or make build-release for an optimized binary with stripped debug symbols.

Verify the installation:

Terminal window
msgvault --help

Configure OAuth

Create a Google Cloud project, enable the Gmail API, and download your client_secret.json. See the full OAuth Setup Guide.

Where to put config.toml

msgvault stores all data (config, database, tokens, attachments) in a single directory. The default location depends on your platform:

PlatformData directoryConfig file
macOS / Linux~/.msgvault/~/.msgvault/config.toml
WindowsC:\Users\<you>\.msgvault\C:\Users\<you>\.msgvault\config.toml

To store data on a different drive or location, use the --home flag or set the MSGVAULT_HOME environment variable. If MSGVAULT_HOME is set, paths in the table above are relative to that directory instead:

Per-command (any platform):

Terminal window
msgvault sync --home E:/msgvault

Windows (PowerShell, persistent):

Terminal window
$env:MSGVAULT_HOME = "E:\msgvault"
# Or set it permanently:
[Environment]::SetEnvironmentVariable("MSGVAULT_HOME", "E:\msgvault", "User")

macOS / Linux (persistent):

Terminal window
export MSGVAULT_HOME=/mnt/data/msgvault

The --home flag takes priority over MSGVAULT_HOME. See Configuration for all options.

Create the config file

macOS / Linux:

[oauth]
client_secrets = "/path/to/client_secret.json"

Windows — use forward slashes in the path:

[oauth]
client_secrets = "C:/Users/you/Downloads/client_secret.json"

Add Your Account

Terminal window
msgvault add-account you@gmail.com

This opens your browser for OAuth consent. For headless servers, see the copy-token workflow.

If you plan to deploy to a remote host (NAS, cloud VM, etc.), run msgvault setup after this step to generate a ready-to-run deployment bundle with Docker Compose and remote configuration. See the Remote Deployment guide.

Add an IMAP Account

To sync mail from a non-Gmail provider (Fastmail, Outlook, Yahoo, self-hosted, etc.), use add-imap:

Terminal window
msgvault add-imap --host imap.fastmail.com --username you@fastmail.com

You will be prompted for your password. The command tests the connection before saving credentials. Use an app-specific password if your provider supports them.

Common IMAP servers:

ProviderHostPortNotes
Fastmailimap.fastmail.com993App password recommended
Outlook / Hotmailoutlook.office365.com993App password required with 2FA
Yahooimap.mail.yahoo.com993App password required
iCloudimap.mail.me.com993App-specific password required
Gmail (IMAP)imap.gmail.com993Use add-account for Gmail API instead
Self-hostedyour server hostname993

For STARTTLS connections (port 143), add --starttls:

Terminal window
msgvault add-imap --host mail.example.com --username you@example.com --starttls

After adding the account, sync it the same way as a Gmail account:

Terminal window
msgvault sync-full

IMAP accounts are stored in the same database as Gmail accounts. All tools (TUI, search, MCP, web server) work with IMAP messages the same way.

Sync Email

Terminal window
# Test with a small batch first
msgvault sync-full you@gmail.com --limit 100
# Or sync a specific date range
msgvault sync-full you@gmail.com --after 2024-01-01 --before 2024-02-01
# Sync everything (no limit)
msgvault sync-full you@gmail.com

What to Expect

The initial full sync downloads every message and attachment from Gmail, so it can take a while. In testing we have observed roughly 50 messages per second on fast internet, but the Gmail API has per-user quotas that may throttle throughput further. An account with hundreds of thousands of messages and large attachments may take several hours; an account with millions of messages could take significantly longer. We recommend starting with --limit or a date range to verify everything works before kicking off the full run.

The good news: syncs are resumable (see below), and once the initial sync is complete, incremental syncs only fetch new and changed messages, which is much faster.

Full Sync Flags

FlagDescription
--limit NDownload at most N messages
--after YYYY-MM-DDOnly messages after this date
--before YYYY-MM-DDOnly messages before this date
--queryGmail search query filter
--noresumeStart fresh instead of resuming
--verboseShow detailed progress

Incremental Sync

After the initial full sync, use incremental sync for efficient updates. It uses the Gmail History API to fetch only new and changed messages:

Terminal window
msgvault sync you@gmail.com
# Or sync all accounts at once
msgvault sync

Resumable Checkpoints

If a sync is interrupted (network error, Ctrl+C), run the same command again. It resumes from the last checkpoint:

Terminal window
# This resumes automatically
msgvault sync-full you@gmail.com --after 2024-01-01 --before 2024-02-01

Checkpoint data is stored in the sync_checkpoints table. Use --noresume to discard checkpoints and start over.

Rate Limiting

msgvault uses token bucket rate limiting to respect Gmail API quotas. The default is 5 requests per second, configurable in config.toml:

[sync]
rate_limit_qps = 5

Reduce this value if you encounter rate limit errors during large syncs.

Safety

Sync operations are read-only. They use only messages.list and messages.get Gmail APIs. No write operations are performed. Your Gmail data remains untouched.

Explore

Terminal window
# Search your archive
msgvault search from:alice@example.com
# Launch the interactive TUI
msgvault tui
# View stats
msgvault stats
msgvault TUI showing the Senders view

See Searching and Interactive TUI for more.