This container makes a backup daily of your GitHub repositories, uploads them to S3 object storage and keeps up to defined number of backups.
Under the hood it uses:
- python-github-backup to take backups
- AWS SDK for Python to upload and manage backup files
-
Generate GitHub access token
-
Clone this repo to
/opt/github-backup
(or any other suitable location):git clone https://github.com/kapitanov/auto-github-backup.git /opt/github-backup
-
Build docker image:
cd /opt/github-backup docker-compose build
-
Create
.env
file containing env variables (see table below). -
Start docker container:
docker-compose up -d
Backups will be taken on daily basis and uploaded (in
.tar.gz
format) to S3 object storage. All backups older than$BACKUP_KEEP_DAYS
will be deleted from S3.
This container is configured via environment variables:
Variable | Is required | Default value | Description |
---|---|---|---|
GITHUB_USER |
Yes | Comma-separated list of GitHub user names | |
GITHUB_ACCESS_TOKEN |
Yes | GitHub access token | |
S3_ACCESS_KEY |
Yes | Access key for S3 | |
S3_SECRET_KEY |
Yes | Secret key for S3 | |
S3_BUCKET |
Yes | S3 bucket name | |
S3_URL |
No | S3 service URL (not needed for AWS S3) | |
S3_PREFIX |
No | S3 filename prefix (e.g. backups/github/ ) |
|
BACKUP_KEEP_DAYS |
No | 30 |
Max age of backups (in days) |
GITHUB_USER=github-user-1,github-user-2,github-user-3
GITHUB_ACCESS_TOKEN=my-github-access-token
S3_BUCKET=my-github-backups
S3_ACCESS_KEY=my-s3-access-key
S3_SECRET_KEY=my-s3-secret-key
GITHUB_USER=github-user-1,github-user-2,github-user-3
GITHUB_ACCESS_TOKEN=my-github-access-token
S3_URL=https://custom-s3-service.com/
S3_BUCKET=my-github-backups
S3_ACCESS_KEY=my-s3-access-key
S3_SECRET_KEY=my-s3-secret-key