LinuxCommandLibrary

gyb

Backup and restore Gmail or Google Workspace

TLDR

Estimate the number and the size of all emails on your Gmail account

$ gyb --email [email@gmail.com] --action estimate
copy

Backup a Gmail account to a specific directory
$ gyb --email [email@gmail.com] --action backup --local-folder [path/to/directory]
copy

Backup only important or starred emails from a Gmail account to the default local folder
$ gyb --email [email@gmail.com] --search "[is:important OR is:starred]"
copy

Restore from a local folder to a Gmail account
$ gyb --email [email@gmail.com] --action restore --local-folder [path/to/directory]
copy

SYNOPSIS

gyb [--email <email_address>] [--action <action>] [--service <service>] [options]
Example: gyb --email user@example.com --action backup --service gmail --folder inbox

PARAMETERS

--email <email_address>
    Specifies the Google Workspace user account to operate on.

--action <action>
    Defines the operation to perform (e.g., backup, restore, info, purge).

--service <service>
    Specifies the Google service to interact with (e.g., gmail, calendar, drive, contacts, keep, photos).

--oauth <path>
    Specifies the path to the OAuth2 client secrets file.

--local-folder <path>
    Sets the local directory for storing backup data.

--messages <query>
    (Gmail) Filters messages based on a Gmail search query.

--folder <folder_name>
    (Gmail) Specifies specific Gmail folders/labels to back up.

--all-labels
    (Gmail) Backs up messages from all labels, including system labels.

--restore-to <email_address>
    (Restore) Specifies the target email for restoration.

--debug
    Enables verbose debugging output for troubleshooting.

--version
    Displays the current gyb version and exits.

DESCRIPTION

gyb (Got Your Back) is a powerful and flexible command-line tool designed for backing up and restoring data from Google Workspace (formerly G Suite) accounts. It supports comprehensive backups of various Google services, including Gmail messages, Google Calendar events, Google Drive files, Google Contacts, Google Keep notes, and Google Photos metadata.

Developed primarily in Python, gyb is cross-platform and can run on Linux, macOS, and Windows. It leverages Google's APIs for secure authentication via OAuth2, ensuring that your data is accessed with appropriate permissions. Its key strength lies in its ability to perform incremental backups, only downloading new or changed data, which saves bandwidth and time. gyb is widely used by individuals and administrators for archiving important Google data or migrating it between accounts. It's a non-GUI solution, making it ideal for scripting and automated backup tasks.

CAVEATS

gyb requires initial setup for OAuth2 authentication with Google, which involves creating a Google Cloud Project and obtaining client secrets. This process can be complex for new users. Data limitations and API quotas imposed by Google can affect large backup operations. While powerful, gyb is a command-line tool, which may not be suitable for users preferring a graphical interface. It's crucial to regularly update gyb to ensure compatibility with Google's evolving APIs and security protocols.

AUTHENTICATION SETUP

gyb requires a one-time setup of OAuth2 client secrets through the Google Cloud Console. This process generates a client_secrets.json file, which gyb uses to authenticate with your Google account. Detailed instructions are available on the official gyb documentation.

INCREMENTAL BACKUPS

One of gyb's most valuable features is its ability to perform incremental backups. After the initial full backup, subsequent runs only download new or changed data, significantly reducing backup time and bandwidth usage. This is managed by gyb tracking the state of your data locally.

HISTORY

gyb was created by Jay Lee and first released around 2011-2012, initially focusing on Gmail backups. Over the years, its capabilities expanded significantly to include other Google Workspace services like Calendar, Drive, Contacts, Keep, and Photos. Its development has been driven by the need for robust, automated, and secure command-line backups for Google's ecosystem. gyb gained popularity among system administrators, IT professionals, and technically proficient users due to its reliability and comprehensive feature set for managing Google data outside of the web interface. It continues to be actively maintained, adapting to changes in Google's APIs and adding new features.

SEE ALSO

rclone(1), gsutil(1), gdrive

Copied to clipboard