kapitanov / auto-github-backup

Automatic backup of GitHub repos to S3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

auto-github-backup

Docker Cloud Build Status Docker Pulls GitHub

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:

Install and run

  1. Generate GitHub access token

  2. 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
  3. Build docker image:

    cd /opt/github-backup
    docker-compose build
  4. Create .env file containing env variables (see table below).

  5. 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.

Configuration

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)

Example .env file for AWS S3

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

Example .env file for custom S3-compatible service

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

About

Automatic backup of GitHub repos to S3

License:MIT License


Languages

Language:Python 46.7%Language:Shell 44.2%Language:Dockerfile 9.1%