Simple tool to backup a Gmail account.
- Performs full and incremental sync using the Gmail API.
- Saves only message contents, not metadata such as labels.
- Message saved in EML format, which just the raw email data in RFC2822 format.
- Restore functionality not yet implemented.
To install gmbackup using Go:
go install github.com/rigtorp/gmbackup@latestAlternatively, you can build it from source:
git clone https://github.com/rigtorp/gmbackup.git
cd gmbackup
go build .- Go to the Google Cloud Console.
- Create a new project or select an existing one.
- Search for Gmail API and click Enable.
- Go to APIs & Services > OAuth consent screen:
- Select External (or Internal if using Google Workspace) and click Create.
- Fill in the required fields (App name, User support email, Developer contact information).
- Click Save and Continue.
- Under Scopes, click Add or Remove Scopes, search for
https://www.googleapis.com/auth/gmail.readonly, check it, and click Add to table. Click Update and then Save and Continue. - Under Test users, click Add Users and add your Gmail address. Click Save and Continue.
- Go to APIs & Services > Credentials:
- Click Create Credentials > OAuth client ID.
- Select Application type: Desktop app.
- Name it (e.g.,
gmbackup) and click Create. - Download the JSON file and rename it to
credentials.json.
You can either provide the client credentials JSON file in
$XDG_CONFIG_HOME/gmbackup/credentials.json or use the --client-id and
--client-secret flags.