A command-line tool for backing up private GitHub repositories from an organization to local storage or remote object storage.
Repo Backup CLI (rbk) provides functionality to:
- List all private, non-archived repositories in a GitHub organization
- Create local backups of repositories as archive files
- Create remote backups to object storage (Azure Blob Storage or S3-compatible storage)
The backup feature of this CLI leverages GitHub's Migration API to create a migration archive of all private non-archived repositories from a specified organization and then downloads or uploads this archive to your desired storage location.
The CLI supports two different storage backends for remote backups:
Azure Blob Storage is Microsoft's object storage solution for the cloud. To use Azure Blob Storage as your backend:
- Set
STORAGE_BACKEND=azurein your configuration - Configure the following environment variables:
AZURE_STORAGE_ACCOUNT_NAME- Your Azure Storage account nameAZURE_STORAGE_API_KEY- Your Azure Storage API keyAZURE_STORAGE_ACCOUNT_URL- Your Azure Storage account URLAZURE_STORAGE_CONTAINER_NAME- Your Azure Storage container name
The CLI also supports S3-compatible object storage services (such as MinIO, AWS S3, DigitalOcean Spaces, etc.). To use S3-compatible storage:
- Set
STORAGE_BACKEND=objectin your configuration - Configure the following environment variables:
OBJECT_STORAGE_ENDPOINT- The endpoint URL of your S3-compatible serviceOBJECT_STORAGE_ACCESS_KEY- Your access keyOBJECT_STORAGE_SECRET_KEY- Your secret keyOBJECT_STORAGE_BUCKET_NAME- The bucket name where backups will be storedOBJECT_STORAGE_USE_SSL- Whether to use SSL (true/false, defaults to true)
This project requires several development dependencies which can be installed using Homebrew:
# Install all dependencies using the included Brewfile
brew bundleYou can use the included justfile to set up the environment:
just setupThe above command will create a .env file in the root directory from the .env.template file. You should replace the variables in it with the correct values.
- Go 1.25+ - The project requires Go version 1.25 or later
- Just - (Optional) Command runner for development tasks (installable via
brew install just)
git clone https://github.com/kumojin/repo-backup-cli.git
cd repo-backup-cliInstall all development dependencies using the included Brewfile:
brew bundleThis will install Go, Just, and other required tools.
You can build the project using either Go directly or the included Justfile:
go build -o rbk .just buildBoth commands will create an executable binary named rbk in the current directory.
To install the binary globally so you can run rbk from anywhere:
go install .This will install the binary to your $GOPATH/bin directory (make sure it's in your $PATH).
Test that the binary works correctly:
./rbk --helpOr if you installed globally:
rbk --helprbk [command] [flags]
-c, --config- Path to environment configuration file (default: ".env")-o, --organization- GitHub organization to use
The CLI uses an env file (.env by default) as its config:
CLI_GITHUB_TOKEN- A GitHub personal access token with the necessary permissionsSENTRY_DSN- (Optional) Your Sentry DSN in case you want to capture logs and errorsSTORAGE_BACKEND- The storage backend to use (azureorobject)
For Azure Blob Storage (STORAGE_BACKEND=azure):
AZURE_STORAGE_ACCOUNT_NAME- Your Azure Storage account nameAZURE_STORAGE_API_KEY- Your Azure Storage API keyAZURE_STORAGE_ACCOUNT_URL- Your Azure Storage account URLAZURE_STORAGE_CONTAINER_NAME- Your Azure Storage container name
For S3-Compatible Storage (STORAGE_BACKEND=object):
OBJECT_STORAGE_ENDPOINT- The endpoint URL of your S3-compatible serviceOBJECT_STORAGE_ACCESS_KEY- Your access keyOBJECT_STORAGE_SECRET_KEY- Your secret keyOBJECT_STORAGE_BUCKET_NAME- The bucket name where backups will be storedOBJECT_STORAGE_USE_SSL- Whether to use SSL (true/false)
You can also export the variables in your environment and the CLI will pick them up
List all private, non-archived repositories in the specified organization. Used primarily for debugging.
rbk reposCreate a backup of repositories from an organization:
rbk backup [local|remote]Save the backup archive to local storage:
rbk backup localThis will save the archive as archive.tar.gz in the current directory.
Upload the backup archive to your configured object storage backend:
rbk backup remoteThis will create a blob/object with the name format YYYY-MM-DD-org-migration.tar.gz and upload it to your configured storage container/bucket (Azure Blob Storage or S3-compatible storage).
# List all private repos in the organization
rbk repos --organization myorg
# Create a local backup of repositories
rbk backup local --organization myorg
# Create a remote backup to object storage
rbk backup remote --organization myorg --config custom.envVS Code launch configurations are provided in the .vscode/launch.json file for debugging for all operations above.
This project includes a justfile with common development tasks. Use the following command to list them all:
justThe GitHub token must be a classic personal access token (not a fine-grained token) with the following permissions:
repo- Full control of private repositoriesadmin:org- Full control of orgs and teams, read and write org projects
To create a classic token follow these instructions.