LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

gyb

command-line tool for backing up and restoring Gmail

TLDR

Backup Gmail
$ gyb --email [user@gmail.com] --action backup
copy
Restore emails
$ gyb --email [user@gmail.com] --action restore
copy
Estimate backup size
$ gyb --email [user@gmail.com] --action estimate
copy
Backup only recent messages
$ gyb --email [user@gmail.com] --action backup --search "newer_than:[7d]"
copy
Count messages
$ gyb --email [user@gmail.com] --action count
copy
Fast incremental backup (skip refreshing labels for already-backed-up messages)
$ gyb --email [user@gmail.com] --action backup --fast-incremental
copy

SYNOPSIS

gyb [options]

DESCRIPTION

GYB (Got Your Back) is a command-line tool for backing up and restoring Gmail using the Gmail API over HTTPS.It supports incremental backups, search queries to filter specific messages, and can also restore from mbox exports (e.g., Google Takeout). Backups are stored locally with a SQLite index.

PARAMETERS

--email ADDR

Gmail address.
--action ACT
Action: backup, restore, restore-mbox, estimate, count, purge, print-labels, quota, reindex.
--local-folder DIR
Local backup directory.
--search QUERY
Gmail search query to filter messages.
--fast-incremental
Skip refreshing labels/flags for already-backed-up messages.
--label-restored LABEL
On restore, additionally apply this label to all messages.
--strip-labels
Remove existing labels during restore.
--spam-trash
Include Spam and Trash folders.
--service-account
Use Google Service Account authentication.
--help
Display help information.

CAVEATS

Requires OAuth authorization. Rate limited by Gmail API. Large mailboxes take time.

HISTORY

GYB was created by Jay Lee as an open-source Gmail backup tool, widely used for Google Workspace migrations.

SEE ALSO

offlineimap(1), mbsync(1), mutt(1)

Copied to clipboard
Kai