bbcloner: create mirrors of your public and private Bitbucket Git repositories
Monday, April 15th, 2013
I wrote a small tool that assists in creating mirrors of your public and private Bitbucket Git repositories and wikis. It also synchronizes already existing mirrors. Initial mirror setup requires that you manually enter your username/password. Subsequent synchronization of mirrors is done using Deployment Keys.
You can download a tar.gz, a Debian/Ubuntu package or clone it from the Bitbucket page.
Features
- Clone / mirror / backup public and private repositories and wikis.
- No need to store your username and password to update clones.
- Exclude repositories.
- No need to run an SSH agent. Uses passwordless private Deployment Keys. (thus without write access to your repositories)
Usage
Here's how it works in short. Generate a passwordless SSH key:
$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key: /home/fboender/.ssh/bbcloner_rsa<ENTER> Enter passphrase (empty for no passphrase):<ENTER> Enter same passphrase again: <ENTER>
You should add the generated public key to your repositories as a Deployment Key. The first time you use bbcloner, or whenever you've added new public or private repositories, you have to specify your username/password. BBcloner will retrieve a list of your repositories and create mirrors for any new repositories not yet mirrored:
$ bbcloner -n -u fboender /home/fboender/gitclones/ Password: Cloning new repositories Cloning project_a Cloning project_a wiki Cloning project_b
Now you can update the mirrors without using a username/password:
$ bbcloner /home/fboender/gitclones/ Updating existing mirrors Updating /home/fboender/gitclones/project_a.git Updating /home/fboender/gitclones/project_a-wiki.git Updating /home/fboender/gitclones/project_b.git
You can run the above from a cronjob. Specify the -s argument to prevent bbcloner from showing normal output.
The mirrors are full remote git repositories, which means you can clone them:
$ git clone /home/fboender/gitclones/project_a.git/ Cloning into project_a... done.
Don't push changes to it, or the mirror won't be able to sync. Instead, point the remote origin to your Bitbucket repository:
$ git remote rm origin $ git remote add origin git@bitbucket.org:fboender/project_a.git $ git push remote: bb/acl: fboender is allowed. accepted payload.
Get it
Here are ways of getting bbcloner:
- Debian / Ubuntu package. Install with: sudo dpkg -i bbcloner-X.YY.deb
- Source package. Install with: tar -vxzf bbcloner-X.YY.tar.gz && cd bbcloner-X.YY && sudo ./install.sh
More information
Fore more information, please see the Bitbucket repository.