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.jsonfile (see Setting up Google Cloud).
[!WARNING] Invoking gfetch in this way will create a directory called
gfetchand its subdirectories in your current working directory!
Installation for local development
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, andattachmentsdirectories 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.jsonwill be generated automatically when you authenticate with the app.
[!WARNING]
credentials.jsoncontains sensitive data and should not be put in version control. It is already listed in.gitignorebut 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.
- Go to the Google Cloud Console and create an account if you don't have one
- Using the navigation menu in the top-left of the screen, go to
APIs & Services, thenEnable APIs and Services - Search
gmailin the box and find the Gmail API, then enable it - In the
APIs & Servicesmenu, clickCredentials, then clickCreate Credentials, thenOAuth Client ID - For application type, select
Desktop Appand name it how you desire -- perhapsgfetch? - Follow the prompts to generate credentials
- 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.jsoninsrc/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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e109e61142976d439b7b4421ec272f772cee2e1f685d790993c95cd791d9dec
|
|
| MD5 |
0ee2876bb5e39682c0aaafdb5781f015
|
|
| BLAKE2b-256 |
963ba453267ed9b353c5f2fc312a227d76f6b9e1ba8cb09c7cfb2e01d6fdac1b
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b61f68b557ad49d9260284831510e15cace32381047a0bb440b23b2c3ad43a6b
|
|
| MD5 |
c5b82dfb03a8b1fa0072ede344fae539
|
|
| BLAKE2b-256 |
c2142f7fe129e4b5cc61854a55b930d24f2694353d8315a4ade93028995ed649
|