A second copy of a Git repository can help you recover from an outage, but it is not the same as a GitLab disaster-recovery backup. Mirroring normally copies Git refs and objects: it does not automatically preserve issues, merge requests, CI variables, runners, or the instance configuration. Decide which assets you need before enabling synchronization.
Choose the direction before touching settings
If your on-premises GitLab instance is the source of truth and GitLab.com is the standby destination, push mirroring is usually the natural direction. Commits pushed to the source are propagated to the destination. Avoid having developers push directly to both sides: divergent branches complicate recovery.
Pull mirroring works in the opposite direction: the destination polls an upstream repository. According to GitLab documentation, pull mirroring is a Premium/Ultimate feature. Check the licensing and direction of synchronization rather than assuming the same configuration works on every tier.
Set up the destination repository
- Create a private project on GitLab.com for the mirrored repository and restrict access to the recovery team.
- Choose a dedicated service identity or an appropriately scoped token for authentication. Store the credential securely and establish a rotation procedure.
- On the on-premises project, open Settings → Repository → Mirroring repositories (menu labels can vary by version).
- Add the GitLab.com target URL, select Push and configure the authentication method available to your instance.
- Decide whether to mirror only protected branches and whether divergent refs should be preserved. Document the decision.
- Save and trigger or wait for synchronization, then inspect the mirror status for errors.
Prove that synchronization works
Create a harmless test branch and commit in the source repository. Check that the corresponding branch and commit hash appear on GitLab.com. Compare the source and mirror with git ls-remote from a trusted workstation:
git ls-remote https://gitlab.example.org/team/project.git HEAD
git ls-remote https://gitlab.com/team/project-mirror.git HEAD
These commands show the commit ID referenced by HEAD. For full branch coverage, compare all relevant refs rather than only the default branch. Be aware that mirroring is asynchronous; a lagging mirror is not necessarily a failed one.
What happens during an outage?
Write down who is authorized to promote the mirror, how developers update their Git remotes, and how you prevent split-brain once the primary instance returns. A useful tabletop exercise is to clone the mirror from a separate machine, run the build without privileged production secrets, and verify that the branch and tag history you need is present.
Keep a separate tested GitLab backup for application data such as issues and merge requests. Mirror status and backup success are different monitoring signals, and both should alert the right team.
Security and operational checklist
- Protect the backup project and restrict membership.
- Minimize token permissions and rotate credentials.
- Monitor mirror failures and replication lag.
- Decide how protected branches and deleted refs should be handled.
- Test recovery, rather than assuming that a green synchronization icon is sufficient.
For related practices, see our Ubuntu Server security guide and Docker performance guide.
Official documentation: GitLab repository mirroring and push mirroring.
Original source reference: view the source article. This edition has been independently revised.





