Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mirror a git repository by pulling?

Tags:

git

mirror

I am wondering if there is an easy way, ie like a simple cron job, to regularly pull from a remote git repository to a local read only mirror for backup purposes?

Ideally it would pull all branches and tags, but the master/trunk/head would be sufficient.

I just need a way to make sure that if the master git server dies, we have a backup location that we could manually fail over to.

like image 529
corydoras Avatar asked May 03 '10 07:05

corydoras


People also ask

How do I mirror a git repository?

Navigate to the repository you just cloned. Pull in the repository's Git Large File Storage objects. Mirror-push to the new repository. Push the repository's Git Large File Storage objects to your mirror.

What is git remote mirroring?

Git mirroring is when a mirror copies the refs & the remote-tracking branches. It's supposed to be a functionally identical copy that is interchangeable with the original.


1 Answers

First create a mirror with

git clone --mirror [email protected]:repo.git 

then setup a cron job like this:

*/1 * * * * gitbackup cd /backup/repo.git && git fetch -q --tags 

This will backup the changesets every minute. Maybe you want to do this less frequently.

like image 108
gregor Avatar answered Sep 23 '22 06:09

gregor