gpack is a command-line tool to backup your coding projects to Google Drive by zipping them up.
- Interactive Menu (
gpack): Rungpackwith no arguments to open an interactive dashboard showing project status, configured Google Drive destination, linked Google account, last backup time, change status, and option selections. gpack init: Initialize a project, set storage location, and create.gpackignore.gpack login: Authenticate with your Google Account. Supports logging into multiple accounts simultaneously and switching or linking them to specific projects.gpack logout: Disconnect your account and remove credentials. Supports logging out of a single account or all accounts.gpack push(orgpack backup): Backup the current project (zip & upload). It checks if changes occurred before creating a new backup unless overridden.gpack list: List backups and show storage usage for the current project.gpack trim: Reduce backup count (auto-keep last 5, custom N, or interactive deletion).gpack load(orgpack restore): List and download backups of the project from Google Drive, and restore/extract the files back into the project.
Prerequisites: Node.js installed (v18+ recommended).
npm install -g git+https://github.com/mikeevans82/gpack.git- Clone or Download this repository.
- Install dependencies:
npm install # Build the project npm run build - Link globally (optional, to run
gpackfrom anywhere):Now you can runnpm link
gpackin any terminal.
To use gpack, you need your own Google Cloud Project credentials (client ID and secret) currently, or you can use provided ones if available.
- Go to Google Cloud Resource Manager.
- Create (or edit) a project.
- Enable Google Drive API in that project.
- Go to Credentials -> Create Credentials -> OAuth client ID.
- Application type: Desktop app.
- Copy the Client ID and Client Secret.
- Run
gpack loginand follow the prompts to enter these credentials.
To avoid your login expiring every 7 days:
- Go to APIs & Services -> OAuth consent screen in your Google Cloud Console.
- Click Publish App (or set status to Production).
- Confirm the push to production.
- You do not need to submit for verification.
- When you login, you will see a "Google hasn't verified this app" warning.
- Click Advanced -> Go to (Project Name) (unsafe). This is safe for your own private app.
- Navigate to your project folder.
- Run
gpack initto configure the Google Drive destination folder. - Run
gpack loginto log in to one or more Google Accounts. If multiple accounts are logged in, you can link the project to a specific account. - Run
gpackwith no arguments to launch the interactive menu, or rungpack pushto perform a quick backup.
To save storage and avoid duplicate backups, gpack performs a validation check before zipping and uploading:
- For Git Projects: Checks if any new commits have been made since the last backup date, and checks for uncommitted changes (
git status --porcelain). - For Non-Git Projects: Recursively walks the directory (ignoring node_modules, build outputs, and config files) to check if any file's modification time is newer than the last backup.
- Bypassing the check: You can override the change check and force a backup by running:
You will also be asked if you want to force a backup if you choose the "Make a Backup" option in the interactive menu when no changes are present.
gpack push --force # or gpack push -f
To restore a backup, run:
gpack load
# or select "Load / Restore a Backup" in the interactive menuThis lists your backups on Google Drive, downloads your selected zip file to a temporary location, extracts it using the native system tar command (preserving your file structure), and cleans up.
Backups are named using the following pattern:
ProjectName_YYYY-MM-DDTHH-mm-ss-mssZ.zip
For example: gpack_2024-01-30T14-55-00-123Z.zip
- Project config is stored in
.gpack/config.json. - Ignore rules are in
.gpackignore(syntax similar to .gitignore). Default ignores:node_modules,.git,.gpack,dist,coverage,.env.