https://github.com/druidfi/git-backupper
Backup Git repositories and sync them to S3 compliant storage
https://github.com/druidfi/git-backupper
backups bash-script git github s3
Last synced: 6 months ago
JSON representation
Backup Git repositories and sync them to S3 compliant storage
- Host: GitHub
- URL: https://github.com/druidfi/git-backupper
- Owner: druidfi
- License: mit
- Created: 2023-03-21T05:44:43.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-17T11:28:24.000Z (over 1 year ago)
- Last Synced: 2025-05-07T05:11:41.324Z (6 months ago)
- Topics: backups, bash-script, git, github, s3
- Language: Shell
- Homepage:
- Size: 47.9 KB
- Stars: 11
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```console
GH_OWNER=myorg GH_LIST_LIMIT=5 ./backup.sh
```
```console
S3_BUCKET=mybucket AWS_ACCESS_KEY_ID=mykey AWS_SECRET_ACCESS_KEY=mysecret ./s3.sh
```
To some S3-compliant service e.g. UpCloud:
```console
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](.github/workflows/backup.yml) to see how to use with Github Actions workflow.
## Environment variables
For `backup.sh`:
| Name | Value | Description |
|----------------|---------|---------------------------------|
| GH_TOKEN | | Specific token to use |
| GH_OWNER | octocat | GitHub organization |
| GH_LIST_LIMIT | 100 | How many repositories to backup |
| GIT_CLONE_MODE | ssh | Clone using ssh or https |
For `s3.sh`:
| Name | Value | Description |
|-----------------------|----------------------------------|------------------------------|
| S3_BUCKET | | Target S3 bucket for backups |
| AWS_ACCESS_KEY_ID | | awscli credential |
| AWS_SECRET_ACCESS_KEY | | awscli credential |
| AWSCLI_FLAGS | --only-show-errors --no-progress | Flags for awscli |
| S3_REGION | eu-central-1 | Default region |
## Docker image
Use prebuild image:
```console
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`:
```console
docker build . --progress plain -t git-backupper
```
## TODO
- Add S3 script running to Docker image
- Possibility to backup custom repositories