Mirror github to Gitlab

In a local gitlab I created a copy of project nova (https://github.com/openstack/nova).

How do I keep the local nova repo in sync with github, updating maybe once per hour or per day?

I would like a solution similar to what is described here for bitnami: http://wiki.bitnami.com/Applications/BitNami_GitLab#Keeping_in_sync_with_the_GitLab_repository_at_GitHub

(I used Devstack to install Openstack.)


Solution 1:

GitLab now has this feature built-in!
Since GitLab EE 8.2 it's supported. Hooray!

Pulling from a remote respository

You can set up a repository to automatically have its branches, tags, and commits updated from an upstream repository.
...

When creating a new project, you can enable repository mirroring when you choose to import the repository from "Any repo by URL". Enter the full URL of the Git repository to pull from and click on the Mirror repository checkbox.

GitLab auto mirroring
(source: gitlab.com)

>

For an existing project, you can set up mirror pulling by visiting your project's Settings ➔ Repository and searching for the "Pull from a remote repository" section. Check the "Mirror repository" box and hit Save changes at the bottom.
...

Solution 2:

If you never need local commits, the following recipe will work:

Clone the repo with --mirror:

git clone --mirror https://github.com/openstack/nova.git

Then in a cronjob, you do this for an hourly update:

0 * * * * cd /path/to/nova.git && git fetch

The --mirror sets up the refspecs in such a way that subsequent fetches will update all local refs, so you don't need to merge the changes in. Of course that does mean that commits pushed to that repo are lost.

Solution 3:

I wrote a project with the intention of adding remote mirrors to GitLab. You can check it out here...

https://github.com/sag47/gitlab-mirrors