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.5.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.5-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gfetch-0.1.5.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.5.tar.gz
Algorithm Hash digest
SHA256 78dede92c5080667935a995693f3a0bd593e81c293a3b9bc2d84202d36a8324e
MD5 15116143bf352216dc3ec831af30bb75
BLAKE2b-256 3ed2334cc8c1af17251272e40a9a46c9398d22558776ae88264d1fc8a0549a32

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for gfetch-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 6bb1e5a19868062c0ab3de4574a2f87adbb1771d7c70b4e7a29bcf488711a85e
MD5 c3ebfe6ff0529ed352d191ffe0cb7e21
BLAKE2b-256 f35675998a8cd2ad1d1accdc698f8876ec09a099523b5263fb28ce35be1f24f8

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