|
|
|
Having a mirrored version of repositories can prevent data loss and provide read access when the main instance is down. This is especially helpful for us, since we host the documentation of our systems on our systems, meaning that it might be more difficult than it has to be to recover when our GitLab instance is down.
|
|
|
|
|
|
|
|
While the repository code will likely still be available on some developer machines, it is more convenient to have an up-to-date version of the repo. Much more important are **wiki** repositories. They host most of our documentation and are not available on developer machines unless the are specifically cloned and updated.
|
|
|
|
|
|
|
|
GitLab supports mirroring repositories. There is push and pull mirroring. Push mirroring means that a GitLab instance will forward pushes to its mirror. Pull mirroring means that a GitLab instance is configured to periodically fetch the updates from the repository it is mirroring. Pull mirroring is a GitLab premium feature.
|
|
|
|
|
|
|
|
## 1. Push mirroring normal repo (UI)
|
|
|
|
|
|
|
|
The GitLab UI supports creating a mirror of a normal (non-wiki) repo. Mirrors are repos by some git Service such as GitLab or Github. This section assumes that a GitLab repo mirrors a different GitLab repo. The repository which is to be mirrored will be referred to as the *original repo*, the mirroring repo as the *mirror repo*.
|
|
|
|
|
|
|
|
1. **Create** the *mirror repo*. It shall be a blank repo (do not initialize it with a readme or anything else.)
|
|
|
|
2. In the *original repo* go to **Settings -> Repository -> Mirroring repositories**.
|
|
|
|
3. Get the **URL** of the *mirror repo*. It can be obtained by going to the repo home page and copying the SSH link from the *Clone* dropdown menu. This URL will look something like this `git@<HOST>:<NAMESPACE>/<PROJECT>.git`. Replace the colon with a forward slash and prepend `ssh://`, to get `ssh://git@<HOST>/<NAMESPACE>/<PROJECT>.git`.
|
|
|
|
4. In the *original repo* paste the URL obtained in the previous step into the *Git repository URL* field.
|
|
|
|
5. In the *original repo* click *Detect host keys*.
|
|
|
|
6. Verify the detected host keys. GitLab exposes the keys at `https://<GITLAB_DOMAIN>/help/instance_configuration`.
|
|
|
|
7. For the authentication method, choose *SSH public key*.
|
|
|
|
8. You can enable *Keep divergent refs*. When someone pushes to the mirror, this option allows the other branches to be updated. Otherwise, the mirror will not be updated anymore when on branch in the *mirror repo* diverges from the *original repo*.
|
|
|
|
9. Click the *Mirror repository* button.
|
|
|
|
10. This will add an entry in the list below. On the right of that table click the clipboard icon to copy the public **SSH key** which will be used to authenticate the *original repo* to the *mirror repo*.
|
|
|
|
11. In the *mirror repo* go to **Settings -> Repository -> Deploy Keys** and paste the SSH key. Give it a title and enable *Grant write permissions to this key*.
|
|
|
|
12. (Optional) If *CI* is running in the *original repo* it might also run in the *mirror repo*. If this matters, check **Settings -> General -> Visibility, project features, permissions -> CI/CD** in the *mirror repo*. Changes need to be saved explicitly.
|
|
|
|
13. In the *original repo*, click the update button next to the button for copying the public SSH key. This should push the changes to the *mirror repo*.
|
|
|
|
14. Check the home page of the *mirror repo*. The files from the *original repo* should be there.
|
|
|
|
15. Ensure that the people who should have access to the *mirror repo* do have access.
|
|
|
|
|
|
|
|
## 2. Mirroring as standalone server job
|
|
|
|
|
|
|
|
https://sharing-codeability.uibk.ac.at/development/repo_mirroring contains a script for setting up mirroring as a cron job on any server which has git installed and runs cron jobs. This script clones the repository and pushes it to the mirror. It also sets up a cron job which updates the mirror daily. See the readme there to learn more.
|
|
|
|
|
|
|
|
## Current State
|
|
|
|
|
|
|
|
The sharing platform including this wiki is mirrored at https://git.uibk.ac.at/informatik/qe/codeability/austauschplattform/austauschplattform.
|
|
|
|
|
|
|
|
The file-hooks repo is mirrored at https://git.uibk.ac.at/informatik/qe/codeability/austauschplattform/file-hooks.
|
|
|
|
|
|
|
|
The updates run as a cronjob for danielr@codeability-austria.uibk.ac.at. Upon failure, an email is sent to artemis-support-informatik@uibk.ac.at.
|
|
|
|
|
|
|
|
Access permissions are handled with GitLab project access tokens.
|
|
|
|
|
|
|
|
## Old setup
|
|
|
|
|
|
|
|
With the on board facilities of gitlab (as explained in 1. above), we now mirroring the repository to https://git.uibk.ac.at/informatik/qe/codeability/austauschplattform/austauschplattform as a backup).
|
|
|
|
|
|
|
|
Additionally I have set up a wiki mirroring job on artemis.codeability-austria.uibk.ac.at (on my personal account **michael**). It also mirrors the wiki with
|
|
|
|
|
|
|
|
```repo_mirroring/mirror-setup mirrorDir git@sharing-codeability.uibk.ac.at:sharing/codeability-sharing-platform.wiki.git git@git.uibk.ac.at:informatik/qe/codeability/austauschplattform/austauschplattform.wiki.git``` |
|
|
|
\ No newline at end of file |