Skip to main content

A CLI app to back up your gmail emails locally

Project description

gfetch-cli - save gmail emails locally

The CLI version of gfetch-web!

This app helps you create local backups of your Gmail emails. It saves raw .eml files, cleaned .txt files, and attachments, each to their own directory.

It is built using Python and the Gmail API.

[!NOTE] The following instructions assume you are using uv.

Running Gfetch without installation

uvx gfetch

[!NOTE] You will not be able to download emails without a valid credentials.json file (see Setting up Google Cloud).

[!WARNING] Invoking gfetch in this way will create a directory called gfetch and its subdirectories in your current working directory!

Installation for local development

Clone this repository:

git clone git@github.com:jwjacobson/gfetch-cli.git

Navigate to the gfetch-cli directory:

cd gfetch-cli

Install dependencies:

uv sync

Create a .env file from the provided template:

cp env-template .env

If you use the default values from env-template, the project layout will be as follows:

src
└── gfetch
    ├── cleaned_emails
    │   └── attachments
    ├── raw_emails
    ├── credentials.json
    └── token.json
    (.py files omitted for clarity)

[!NOTE]

  • The cleaned_emails, raw_emails, and attachments directories are not part of the repo, but will be created when you run the app.
  • You have to manually download credentials.json (see Setting up Google Cloud below); token.json will be generated automatically when you authenticate with the app.

[!WARNING] credentials.json contains sensitive data and should not be put in version control. It is already listed in .gitignore but might not be covered if you change the filename.

Setting up Google Cloud

For now, Gfetch requires you to create your own credentials to use it.

  1. Go to the Google Cloud Console and create an account if you don't have one
  2. Using the navigation menu in the top-left of the screen, go to APIs & Services, then Enable APIs and Services
  3. Search gmail in the box and find the Gmail API, then enable it
  4. In the APIs & Services menu, click Credentials, then click Create Credentials, then OAuth Client ID
  5. For application type, select Desktop App and name it how you desire -- perhaps gfetch?
  6. Follow the prompts to generate credentials
  7. Once you've created the credentials, must download them immediately, as you won't be able to access them again once you've left the confirmation screen. Download the credentials JSON and save it as credentials.json in src/gfetch/

Running gfetch after local installation

uv run gfetch

Or, if you have Just installed:

just run

Follow the onscreen instructions to back up your emails!

[!NOTE] At present, Gfetch only allows you to download all correspondence with a given address.

If you don't have a valid token, your default browser will open for you to authenticate with the account of your choice when you enter a correspondent's email. You will also have to grant access to Gfetch in order to download your emails. I promise I'm not doing anything with them! (terms of service to be published soon)

License

Gfetch is free software, released under version 3.0 of the GPL. Everyone has the right to use, modify, and distribute gfetch subject to the stipulations of that license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gfetch-0.1.6.tar.gz (33.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gfetch-0.1.6-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

Details for the file gfetch-0.1.6.tar.gz.

File metadata

  • Download URL: gfetch-0.1.6.tar.gz
  • Upload date:
  • Size: 33.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.8

File hashes

Hashes for gfetch-0.1.6.tar.gz
Algorithm Hash digest
SHA256 4e109e61142976d439b7b4421ec272f772cee2e1f685d790993c95cd791d9dec
MD5 0ee2876bb5e39682c0aaafdb5781f015
BLAKE2b-256 963ba453267ed9b353c5f2fc312a227d76f6b9e1ba8cb09c7cfb2e01d6fdac1b

See more details on using hashes here.

File details

Details for the file gfetch-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: gfetch-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 25.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.8

File hashes

Hashes for gfetch-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b61f68b557ad49d9260284831510e15cace32381047a0bb440b23b2c3ad43a6b
MD5 c5b82dfb03a8b1fa0072ede344fae539
BLAKE2b-256 c2142f7fe129e4b5cc61854a55b930d24f2694353d8315a4ade93028995ed649

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page