Skip to main content

mailcellar

CI

Gmail storage full? Move old mail out of Gmail without losing it. mailcellar keeps a local backup of your Gmail accounts. You can then take old mail out of Gmail by rule while the backup keeps it, and it stays searchable, exportable and restorable whenever you need it.

  • Back up every account incrementally, in Got Your Back's format; an existing gyb backup carries on where it is.
  • Offload old mail by rule, in stages you check: plan, review, label, look in Gmail, then trash. Nothing is ever permanently deleted from Gmail, and the backup is checked for every message before it goes.
  • Find and restore it later: mailcellar search searches the backups, offloaded mail included, and mailcellar restore puts mail back into Gmail, into the same account or another.
  • Deduplicate, export and report: remove duplicate copies within and across accounts, copy mail out as an mbox or a zip, and see what takes up the space.

What changes Gmail. Only dedup apply, offload apply and restore --yes, and each is a dry run until you add a flag. The first two label mail, then move it to Trash, which Gmail empties after 30 days; nothing is ever permanently deleted from Gmail. restore only adds mail. Everything else, including backup, only reads (details).

It runs on your own computer with your own Google Cloud project: there is no service in between, and your mail goes nowhere but between Gmail and your disk. Setting up the project takes about ten minutes (guide). mailcellar is in beta: it is used on real mailboxes, and its backups are in gyb's fixed format, but commands and options may still change before 1.0. It runs on macOS and Linux and needs Python 3.14, which uv installs for you.

mailcellar setup   [ADDRESS]       add an account from a downloaded OAuth client
mailcellar backup  [ACCOUNT ...]   incremental backups in gyb's format
mailcellar count   [ACCOUNT ...]   compare Gmail with the backup
mailcellar meta    [ACCOUNT ...]   fill the per-message sidecar for older mail
mailcellar verify  [ACCOUNT ...]   check that the backup's files are still intact
mailcellar schedule install|status|remove   run backups regularly, unattended
mailcellar dedup   …               find duplicates and remove them from Gmail, in stages
mailcellar offload …               take old mail out of Gmail, keeping it in the backup
mailcellar restore ACCOUNT …       put backed-up mail back into Gmail
mailcellar export  ACCOUNT …       copy mail out as an mbox file or a zip of .eml files
mailcellar search  QUERY …         find mail in the backups, offloaded mail included
mailcellar report  …               storage, bulk mail, volume, threads, labels, correspondents,
                                   backup health, top senders
mailcellar config                  where the config and data live; each account's state

backup, count and meta take every configured account unless given some (an address, a config name like work, or a unique part of an address). Each command takes --help.

Results go to stdout; progress, warnings and errors go to stderr. Add -v anywhere on the line to also see Gmail's retries and rate-limit waits (waits of 10 seconds or more show without it), or -q to see only warnings and errors.

How it fits together: How it works.

Quick start

You need uv (it provides Python 3.14) and a Google account.

  1. Install.
    uv tool install mailcellar    # from PyPI; puts the mailcellar command on your PATH
    
    pipx install mailcellar works too, with Python 3.14. To run it from a clone instead, see Development.
  2. Create an OAuth client in the Google Cloud console: a project with the Gmail API enabled, a consent screen with yourself as a test user, and an OAuth client of type Desktop app. Download its JSON. The step-by-step version, including Testing versus In production (Testing tokens expire after 7 days), is Setting up Google Cloud.
  3. Add the account. mailcellar setup takes the downloaded JSON, saves it in the config folder, lists the account in accounts.toml and signs in, read-only. It asks for what you don't give and changes nothing in Gmail:
    mailcellar setup alex@example.org --client ~/Downloads/client_secret_*.json
    
    The backups go in ~/mailcellar. To keep them somewhere else, set it in ~/.config/mailcellar/settings.toml:
    data_dir = "/Volumes/Archive/mailcellar"
    
    The files and their keys are in Configuration.
  4. Back up, then check.
    mailcellar config         # the config and data folders; the account's client and tokens
    mailcellar backup work    # the first backup; resumes where it left off if stopped
    mailcellar count work     # what Gmail has against what the backup has
    
  5. Schedule it. Gmail keeps change history for about four weeks, so back up at least that often. A longer gap still works, but lists the whole mailbox again.
    mailcellar schedule install     # macOS: a launchd agent, weekly; elsewhere: a cron line
    
    If the consent screen is in Testing, tokens expire after 7 days: publish it, or renew with mailcellar auth work --scope readonly --renew. See Scheduled backups.

Then keep the backup safe, and when you are ready to free space, offload old mail.

Documentation

The documentation site has the guides and the reference.

Guides, in the order you will want them:

Command reference, every command and option:

Development

To run mailcellar from a clone, with the tests and tools:

git clone https://github.com/mailcellar/mailcellar.git
cd mailcellar
uv sync                                    # the dependencies, and mailcellar in editable mode
uv run mailcellar config                   # every command, run from the clone
uv run pytest                              # all tests; no network, never the real config or data
uv run pytest --cov                        # the same, with a branch-coverage report
uv run ruff format && uv run ruff check

The code is one package, src/mailcellar/: cli.py dispatches to backup/, dedup/, offload/, restore/ and report/, which share paths.py, gmailapi.py and message.py. uv sync installs it in editable mode; python -m mailcellar works too. See How it works.

How to contribute, and the rules changes follow: CONTRIBUTING.md.

Acknowledgements

mailcellar's backups use the on-disk format of Got Your Back (gyb) by the GAM team, so backups made by either tool can be read by the other. mailcellar is a separate project and shares no code with gyb.

mailcellar is not affiliated with or endorsed by Google or the gyb project. Gmail and Google Workspace are trademarks of Google LLC.

License

Apache License 2.0: see LICENSE and NOTICE.

Metadata

Release files for mailcellar 0.13.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mailcellar 0.13.0
File Size Uploaded Provenance Actions
mailcellar-0.13.0.tar.gz 285.6 kB With provenance Details for mailcellar-0.13.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mailcellar 0.13.0
File Interpreter ABI Platform Actions
mailcellar-0.13.0-py3-none-any.whl Python 3 none any Details for mailcellar-0.13.0-py3-none-any.whl

Total release size: 485.4 kB

Release files / mailcellar-0.13.0.tar.gz

Download URL mailcellar-0.13.0.tar.gz
Size 285.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f8f012dad2bf3429b25f8c5bc053d6dc5a859ae8a0baece4e7e0092d62a3c569
BLAKE2b-256 checksum
How to use checksums
65c25f6b9bf8ec2ada3fc935d6280afbc57d9bf0693850828dd2308003b6bf25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / mailcellar-0.13.0-py3-none-any.whl

Download URL mailcellar-0.13.0-py3-none-any.whl
Size 199.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
77d620c04102a89f5f465a0695b453e72690c220c47dc79d0dc1ccf960f0c61f
BLAKE2b-256 checksum
How to use checksums
acbc4b57650d4e480a8d17ac15c623861d0542591c7eec3068f507c1ff7a1650
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for mailcellar 0.13.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mailcellar-0.13.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page