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.

Installation (using uv)

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

  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

uv run src/gfetch/app.py

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_cli-0.1.0.tar.gz (49.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_cli-0.1.0-py3-none-any.whl (33.1 kB view details)

Uploaded Python 3

File details

Details for the file gfetch_cli-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for gfetch_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0a8a06cc3efb7d827c9c568b6fe38e1627fab9f92fe5b3cf1e47840a9f90ae8b
MD5 e543d13fbdcae84d9e5d7701a3edde04
BLAKE2b-256 85803b15437ebce43e7e5f6bb1d4c230ec12b8a1a271289068ec5721104e9c1c

See more details on using hashes here.

File details

Details for the file gfetch_cli-0.1.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for gfetch_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7e79411acd9a293cc573439739b7b4fb4ebcf5a7d3f8d7d43be66a9fea80fb2
MD5 43c85faadac2d1ff8eef92aff84bc778
BLAKE2b-256 5de3ccb06fb75fa463fb11c5ade0c470ae663f2f674f14c42eabbc4b99eae11e

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