https://github.com/urpagin/github-mirror-user
Mirrors all GitHub repositories of a user and exposes them using a performant git frontend (Forgejo).
https://github.com/urpagin/github-mirror-user
automatic backup cron crond cronjob data-sovereignty docker forgejo git github local mirror mirroring private public repos repositories repository self-hosted
Last synced: 2 months ago
JSON representation
Mirrors all GitHub repositories of a user and exposes them using a performant git frontend (Forgejo).
- Host: GitHub
- URL: https://github.com/urpagin/github-mirror-user
- Owner: Urpagin
- License: mit
- Created: 2025-07-21T19:56:27.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2025-07-21T22:18:16.000Z (3 months ago)
- Last Synced: 2025-07-21T22:24:00.646Z (3 months ago)
- Topics: automatic, backup, cron, crond, cronjob, data-sovereignty, docker, forgejo, git, github, local, mirror, mirroring, private, public, repos, repositories, repository, self-hosted
- Language: Shell
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# github-mirror-user π
A small **Docker Compose** setup to periodically mirror all repositories, public & private, of your GitHub account and make them available with a high-performance git frontend, [Forgejo](https://forgejo.org/).
> [!NOTE]
> This project can **only** be installed with Docker Compose. You may use Docker alone, but you'll have to manually create the commands.## Features β¨
* Periodic mirroring of **all** repositories, public and private of a GitHub account you have access.
* Nice and lightweight git frontend.
* Optional simple Discord webhook error logging.## Installation π οΈ
> [!TIP]
> Please follow the instructions carefully. They may feel out of order, but the `.env` file needs to be populated with both a GitHub token **and** a Forgejo token.1. Clone the repository π
```bash
git clone https://github.com/Urpagin/github-mirror-user.git
cd github-mirror-user
```2. Initialize the frontend π
2.1 Launch the frontend
```bash
sudo docker compose up -d server
```2.2 Create the admin account
Visit [http://127.0.0.1:64175](http://127.0.0.1:64175) (replace with your machine's IP) and follow the instructions.
2.3 Create your Forgejo token
Generate your Forgejo token (see instructions in the `.env` file) and place it in the `.env` file.
3. Populate fully the `.env` file π
Read and follow the instructions contained inside the `.env` file carefully.
4. Start the containers π³
```bash
sudo docker compose up -d
```5. Verify & Enjoy π
Wait for the cronjob to run (you can [modify the cron interval](https://crontab.guru/) by changing the startup command of the cron container in the `docker-compose.yml` file; make sure to force recreate the containers afterward).
You can check the logs of all the containers interactively using this command:
```bash
docker compose up -d --force-recreate
``````bash
sudo docker compose logs -f
```## Containers π¦
### Forgejo
Forgejo is similar to GitLab, Gitea, or Gogs. It's written in Go and designed to be lightweight.
> Forgejo is a self-hosted lightweight software forge. Easy to install and low maintenanceβit just does the job.
* π [Website](https://forgejo.org/)
* π₯ [Source](https://codeberg.org/forgejo/forgejo)### Alpine (cron)
We run the cron daemon in a small Alpine Linux container to periodically execute the mirroring script (`crontab_script.sh`). β°
## Small Behaviour Explanation
If you receive a code 55 from the Discord webhook, it means the `crontab_script.sh` script is running,
and it is run once more, almost making them overlap, if not for the lockfile logic on top of the script.## Security π
> [!IMPORTANT]
> Ensure logs remain secure and private, as some logging includes sensitive tokens for GitHub and Forgejo!The script doesn't account for deleted repositories, *yet*. Maybe Forgejo accounts for this, since all repos are of the
"mirror" type, they might get deleted as upstream is deleted.