logo
0
2
WeChat Login

GitBack

The primary repository is hosted at cnb.cool/mmdjiji/GitBack — please submit all issues and pull requests there. The GitHub repository is a read-only mirror.

English | 简体中文

A Git-based code backup system that supports scheduled automatic backups from GitHub, GitLab, CNB, and any Git repository, with a built-in CGit web interface for browsing.

Features

  • GitHub / GitHub Enterprise
  • GitLab / Self-hosted GitLab
  • CNB.cool
  • Any Git repository URL
  • Scheduled automatic backup (cron expressions)
  • Stateless, one-command Docker deployment
  • Built-in CGit web interface for browsing backups

Quick Start

1. Clone the repository

git clone https://cnb.cool/mmdjiji/GitBack
cd GitBack

2. Create the configuration file

cp config.yaml.example config.yaml

3. Edit the configuration file

Edit config.yaml to add your access tokens and configure backup sources. Note that the top-level YAML key names correspond to the backup folder names.

# Trigger
on:
  cron: 0 0 * * *  # Run backup daily at midnight

# GitHub backup configuration
github:
  type: github
  access_token: your_github_token  # Requires read:org, repo scopes (for Fine-grained tokens, at least Contents and Metadata read-only)
  owned: true          # Back up repos you own
  starred: true        # Back up repos you starred
  collaborator: true   # Back up repos you collaborate on
  org_member: true     # Back up repos from your organizations

# GitLab backup configuration
gitlab:
  type: gitlab
  access_token: your_gitlab_token  # Requires api scope
  owned: true          # Back up repos you own
  starred: true        # Back up repos you starred
  member: true         # Back up repos from your teams

# CNB backup configuration
cnb:
  type: cnb
  access_token: your_cnb_token  # Requires repo-code:r, repo-basic-info:r, account-engage:r scopes
  owned: true          # Back up repos you own
  starred: true        # Back up repos you starred
  member: true         # Back up repos from your teams

# Specify repository URLs directly
repo:
  type: repo
  include:
    - https://example.com/some-repo.git

Token creation links:

4. Start the service

docker compose up -d

Once started:

  • The gitback container will back up repositories to ./repos on the configured cron schedule
  • The cgit container provides a web interface at http://localhost:8787 for browsing backups

Rate Limiting

To avoid triggering platform limits (e.g., GitHub's CPU quota: connections are dropped if operations consume more than 90 seconds of CPU time within a 60-second window), GitBack has two levels of built-in rate limiting:

Interval Limiting

A minimum gap is enforced between consecutive git operations:

DomainMax ConcurrencyMin Interval
github.com110s
gitlab.com18s
cnb.cool18s
Self-hosted / other32s

Sliding Window Limiting

On top of interval limiting, a per-minute sliding window prevents excessive requests when backing up large numbers of repositories:

DomainWindow DurationMax Operations per Window
github.com60s5
gitlab.com60s6
cnb.cool60s6
Self-hosted / other60s20

When the sliding window limit is reached, subsequent tasks are automatically queued until the window expires.

Rate limiting is built-in and requires no additional configuration.

CGit Web Interface

Configure CGit via environment variables in compose.yaml:

environment:
  - CGIT_TITLE=GitBack           # Page title
  - CGIT_DESC=Git backup system  # Page description
  # - BASIC_AUTH_USER=admin      # Basic auth username (optional)
  # - BASIC_AUTH_PASS=12345678   # Basic auth password (optional)

License

MIT

About

基于 Git 的代码备份系统,支持定时自动备份 GitHub、GitLab、CNB 及任意 Git 仓库,并通过 CGit 提供 Web 浏览界面

GitBackrepo-named
Language
JavaScript99%
Dockerfile1.1%