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.1.tar.gz (49.2 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.1-py3-none-any.whl (33.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for gfetch_cli-0.1.1.tar.gz
Algorithm Hash digest
SHA256 12dae084edfd6e32d5369ec206945d1a3addba747ba5a69f59e88ed404b4e8de
MD5 db456cc2a9bb6f64aba9a2b177c00733
BLAKE2b-256 cd68ccbbeb24f9ebb67d76f1236c85b2e7d39be53ac0b32ac8151d7a7cb0f9ab

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for gfetch_cli-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e9a10102f6bebc1063c41cafdaf94982f1e39af9de3982eefbdfbda8ab9da66d
MD5 6c0ea12ea4e8c1c438a2593a480cc6fe
BLAKE2b-256 80bed71800ad0b3ada8282b3d051798b5dae0d5f69e0242872c8e2fc549096fd

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