Skip to content

Repository files navigation

Git Backupper

Backup organization's GitHub repositories with Github CLI.

  • Clones repository with --mirror mode
  • Clones repository wiki if exists
  • Gets repository issues as JSON
  • Creates tar.gz archive file
  • Sync backup archives to S3 bucket

Requirements

  • Github CLI
  • jq
  • awscli

Note: all these are pre-installed on Github Action runners and in Docker image (see below).

Usage

These scripts can be used with e.g. CI workflow, Docker container or as it is:

GH_OWNER=myorg GH_LIST_LIMIT=5 ./backup.sh
S3_BUCKET=mybucket AWS_ACCESS_KEY_ID=mykey AWS_SECRET_ACCESS_KEY=mysecret ./s3.sh

To some S3-compliant service e.g. UpCloud:

S3_BUCKET=mybucket S3_REGION=europe-1 ENDPOINT_URL=https://foobar.upcloudobjects.com AWS_ACCESS_KEY_ID=mykey AWS_SECRET_ACCESS_KEY=mysecret ./s3.sh

See Github workflow to see how to use with Github Actions workflow.

Environment variables

For backup.sh:

NameValueDescription
GH_TOKENSpecific token to use
GH_OWNERoctocatGitHub organization
GH_LIST_LIMIT100How many repositories to backup
GIT_CLONE_MODEsshClone using ssh or https

For s3.sh:

NameValueDescription
S3_BUCKETTarget S3 bucket for backups
AWS_ACCESS_KEY_IDawscli credential
AWS_SECRET_ACCESS_KEYawscli credential
AWSCLI_FLAGS--only-show-errors --no-progressFlags for awscli
S3_REGIONeu-central-1Default region

Docker image

Use prebuild image:

docker run -ti --rm -e GH_TOKEN=YOUR_PAT -e GH_OWNER=myorg -e GH_LIST_LIMIT=5 \ -v `pwd`/backups:/app/backups ghcr.io/druidfi/git-backupper

Build image as git-backupper:latest:

docker build . --progress plain -t git-backupper

TODO

  • Add S3 script running to Docker image
  • Possibility to backup custom repositories

About

Backup Git repositories and sync them to S3 compliant storage

Topics

Resources

Stars

14 stars

Watchers

2 watching

Forks

Packages

Used by

Contributors

Languages