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 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.3.tar.gz (32.6 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.3-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for gfetch-0.1.3.tar.gz
Algorithm Hash digest
SHA256 9e41aa09f429c11714e1535dee071e15dd7a8457d384c2ab8aed7a8d78f8493b
MD5 91218a682518b39269e0c6d327237892
BLAKE2b-256 faa91de94e7289b45dec88d3c994e73c143837ce5853fc353d4a4a1db0420d16

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for gfetch-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9957c7f5e1c18eb77d6de55a43d121707a40776ed2ec3e814a87053b03441c83
MD5 5d2f52995c6917c0fe96194a6983b756
BLAKE2b-256 c0d41b24cfbc1d9912eed822544e3dce1bfb690e62b0f53472013482577fc688

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