mailcellar
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 searchsearches the backups, offloaded mail included, andmailcellar restoreputs 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.
- Keep mail as it is: a hash chain shows the backup hasn't changed
since each message was saved (
verify --chain), and a legal hold keeps the mail a dispute or an audit needs out of reach of offloading, pruning and dedup, in Gmail and in the backup.
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 hold add|list|show|release keep mail for a dispute or an audit
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.
- Install.
uv tool install mailcellar # from PyPI; puts the mailcellar command on your PATH
pipx install mailcellarworks too, with Python 3.14. To run it from a clone instead, see Development. - 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.
- Add the account.
mailcellar setuptakes the downloaded JSON, saves it in the config folder, lists the account inaccounts.tomland 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. - 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
- 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 withmailcellar 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:
- Setting up Google Cloud: the project and OAuth client mailcellar signs in with, and the first consent screen.
- Backing up, and keeping the backup safe: the
routine, a second copy of the data root and checking it,
backup --prune. - Scheduled backups: run backups unattended, and what happens when a token needs signing in.
- Migrating from gyb: continue an existing Got Your Back backup.
- Finding mail, and deciding what to offload:
search, and whichreportanswers what. - Offloading old mail safely: a worked example, from writing a rule to restoring.
- Removing duplicate mail: a worked example, from matching to trashing.
- Restoring mail: undo an offload, recover one message, rebuild or copy an account, load a Takeout file.
- Exporting mail: copy mail out as an mbox or a zip.
- Keeping mail on hold: keep mail for a dispute or an audit, in Gmail and the backup, and hand it over.
- Recovering when something goes wrong: an expired token, a long gap, an interrupted run, a lost data root.
- Troubleshooting and FAQ: slow runs,
countresults, chats, why not IMAP or Takeout.
Command reference, every command and option:
- Backups:
backup,count,meta,verify - Configuration: the config folder,
accounts.toml,settings.toml;setup,auth,schedule,config - What changes Gmail: the commands that write to Gmail
- Removing duplicates:
dedup - Offloading old mail:
offload, and the rule keys - Restoring mail:
restore - Exporting mail:
export - Searching mail:
search - Reports:
report
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
Metadata
Release files for mailcellar 0.15.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mailcellar-0.15.2.tar.gz | 311.1 kB | With provenance | Details for mailcellar-0.15.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mailcellar-0.15.2-py3-none-any.whl | Python 3 | none | any | Details for mailcellar-0.15.2-py3-none-any.whl |
Total release size: 528.2 kB
Release files / mailcellar-0.15.2.tar.gz
| Download URL | mailcellar-0.15.2.tar.gz |
|---|---|
| Size | 311.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d5488d4c74f1d693faa4513e180ff8b29a9b552f7ec52b8281479e832cb1501b
|
|
BLAKE2b-256 checksum How to use checksums |
cd4d2272cdb6cd731c68f35b8ed31e2b58be0449c044ac6bff87ad2516df5107
|
| 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 logRelease files / mailcellar-0.15.2-py3-none-any.whl
| Download URL | mailcellar-0.15.2-py3-none-any.whl |
|---|---|
| Size | 217.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
82de4f0b940d78caad5a9a0dac9ab6a01bf431fa4ab6f671e95a989915efa9ea
|
|
BLAKE2b-256 checksum How to use checksums |
c98887f4cc9c022c9f39c588c5513fe48852d5c2b8180028a0ac79b82e64efd6
|
| 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 logSecurity for mailcellar 0.15.2
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.
Attestation for mailcellar-0.15.2.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 logA 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.