git-mirror/README.md
2020-09-15 12:08:11 +02:00

50 lines
1.6 KiB
Markdown

# Git mirror
Run this script to synchronize a repository once.
## Dependencies
* bash
* git
* Tor and torify (see section "Tor")
## Usage
```
./git-mirror.sh <workdir> <leader> <follower...>
```
## Get started
Create a git repo, add remotes for the leader and the followers:
```bash
mkdir ~/git-mirror-my-repo; cd ~/git-mirror-my-repo
git init
git remote add github https://github.com/interesting/repo
git remote add gitea ssh://git@git.example.org/me/interesting-repo
git remote add gitlab ssh://git@git.example.com/myself/interesting-repo
```
Make sure Tor is running (see section "Tor"). Then run the mirroring script:
```bash
cd
git clone https://git.zeus.gent/midgard/git-mirror.git; cd git-mirror
./git-mirror.sh ~/git-mirror-my-repo github gitea gitlab
```
The first remote, github is the leader. The others are followers that are updated.
## Automate
To automate mirroring, run it periodically, for example once every 30 minutes. On a *NIX you could
use cron for this, or write a system service definition for your system supervisor (such as
systemd, OpenRC or runit).
## Tor
Unless the option `--notor` is used, the leader is fetched over Tor through torify. Make sure Tor
is running, or pass `--notor` to the script, like so:
```bash
./git-mirror.sh ~/git-mirror-my-repo github gitea gitlab
```
## Motivation
GitHub has always been hypocritical, promoting open source while keeping its own stack closed. When
GitHub was bought by Microsoft, the author decided to stop using it. Unfortunately a lot of
software still only has a presence on GitHub. To make it easier to work with those, this simple
mirror script was written.