master TOC | chapter TOC | support

commands to (re-)sync mirrors

You don't have to put all the slaves in gitolite.mirror.slaves. For example, let's say you have some repos that are very active, and two of your mirrors that are halfway across the world are getting pushed very frequently. But you don't need those mirrors to be that closely updated, perhaps because they are halfway across the world and those guys are asleep ;-)

Or maybe there was a network glitch and even the default slaves are now lagging, so they need to be manually synced.

Or a slave realised that one of its repos is lagging for some reason, and wants to request an immediate update.

Whatever the reason, you need ways to sync a repo from a command line. Here are ways to do that:

  1. On the master server, you can start a background job to mirror a repo. The command/syntax is

    gl-mirror-shell request-push reponame [list of keys/slaves]
    

    The list at the end is optional, and can be a mix of slave names or your own gitolite mirror config keys. (Yes, you can have any key, named anything you like, as long as it starts with gitolite.mirror.).

    If the list is not supplied, the gitolite.mirror.slaves key is used.

    Keys can have values that in turn contain a list of keys/slaves. The list is recursively expanded but recursion is not detected. Order is preserved while duplicates are removed. If you didn't get that, see the example :-)

    Warning: the gitolite.mirror.slaves key should have only hosts, no keys, in it.

    The program exits with a return value of "1" if it found no slaves in the list passed, otherwise it fires off the background job, prints an informative message, and exits with a return value of "0".

    We'll take an example. Let's say your gitolite config file has this:

    repo ip1
        config gitolite.mirror.master       =   "frodo"
        config gitolite.mirror.slaves       =   "sam merry pippin"
        config gitolite.mirror.hourly       =   "sam legolas"
        config gitolite.mirror.nightly      =   "gitolite.mirror.hourly gimli"
        config gitolite.mirror.all          =   "gitolite.mirror.nightly gitolite.mirror.hourly gitolite.mirror.slaves"
    

    Then the following commands have the results described in comments:

    gl-mirror-shell request-push ip1
    # which is the same as:
    gl-mirror-shell request-push ip1 gitolite.mirror.slaves
    # pushes to sam, merry, pippin
    
    gl-mirror-shell request-push ip1 gollum
    # pushes only to gollum.  Note that gollum is not a member of any of
    # the slave lists we defined.
    
    gl-mirror-shell request-push ip1 gitolite.mirror.slaves gollum
    # pushes to sam, merry, pippin, gollum
    
    gl-mirror-shell request-push ip1 gitolite.mirror.slaves gitolite.mirror.hourly
    # pushes to sam, merry, pippin, legolas
    
    gl-mirror-shell request-push ip1 gitolite.mirror.all
    # pushes to sam, legolas, gimli, merry, pippin
    

    The last two examples show recursive expansion with order-preserving duplicate removal (hey there's now a published conference paper on gitolite, so we have to use jargon somewhere or they won't accept follow-on papers!).

    If you do something like this:

    config gitolite.mirror.nightly      =   "gimli gitolite.mirror.nightly"
    

    or this:

    config gitolite.mirror.nightly      =   "gimli gitolite.mirror.hourly"
    config gitolite.mirror.hourly       =   "legolas gitolite.mirror.nightly"
    

    you deserve what you get.

  2. If you want to start a foreground job, the syntax is gl-mirror-shell request-push ip1 -fg gollum. Foreground mode requires one (and only one) slave name -- you cannot send to an implicit list, nor to more than one slave.

  3. Cronjobs and custom mirroring schemes are now very easy to do. Use either of the command forms above and write a script around it. Appendix A contains an example setup.

  4. Once in a while a slave will realise it needs an update, and wants to ask for one. It can run this command to do so:

    ssh sam request-push ip2
    

    If the requesting server is not one of the slaves listed in the config variable gitolite.mirror.slaves on the master, it will be rejected.

    This is always a foreground push, reflecting the fact that the slave may want to know why their push errored out or didn't work last time or whatever.