An open API service indexing awesome lists of open source software.

https://github.com/simenandre/backup-repos


https://github.com/simenandre/backup-repos

Last synced: 2 months ago
JSON representation

Awesome Lists containing this project

README

          

# backup-repos

Back up all GitHub repositories for a user or organization to a Hetzner storage box.

Clones repos as bare git repositories, then rsyncs them over SSH. Supports incremental backups (fetches only new changes on subsequent runs).

## Configuration

All configuration is via environment variables:

| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| `GITHUB_TOKEN` | Yes | — | GitHub PAT with repo read scope |
| `GITHUB_OWNER` | Yes | — | GitHub user or org name |
| `GITHUB_OWNER_TYPE` | No | `org` | `user` or `org` |
| `STORAGE_BOX_HOST` | Yes | — | e.g. `uXXXXXX.your-storagebox.de` |
| `STORAGE_BOX_USER` | Yes | — | SSH username |
| `STORAGE_BOX_PORT` | No | `23` | SSH port (Hetzner default is 23) |
| `STORAGE_BOX_PATH` | No | `./backups` | Remote base path |
| `WORK_DIR` | No | `/tmp/backup-repos` | Local staging directory |

## Usage

### Run locally

```sh
export GITHUB_TOKEN=ghp_...
export GITHUB_OWNER=myorg
export STORAGE_BOX_HOST=uXXXXXX.your-storagebox.de
export STORAGE_BOX_USER=uXXXXXX

go run ./cmd/backup-repos
```

### GitHub Actions

The included workflow (`.github/workflows/backup.yml`) runs daily at 03:00 UTC. Configure these secrets in your repository settings:

- `BACKUP_GITHUB_TOKEN` — GitHub PAT (not the built-in `GITHUB_TOKEN`)
- `GITHUB_OWNER`
- `GITHUB_OWNER_TYPE`
- `STORAGE_BOX_HOST`
- `STORAGE_BOX_USER`
- `STORAGE_BOX_SSH_KEY` — Private SSH key for the storage box
- `STORAGE_BOX_PATH`

You can also trigger the workflow manually via the Actions tab.