Thursday, October 1, 2015

Bitbucket Clone All Repos

I needed to backup all the repositories for a Bitbucket account/team. Almost 100 of them. The other fun part is that they are a mixture of bit and mecurial repos.

 Thankfully, Bitbucket has a rest api that makes it easy to get a list of repositories for a team. It also tells you what kind of repo it is. I created a powershell script to get the list of repositories, determine the type, and then clone the repo.  Maybe it would have been more purposeful to do this with bash, but I've never used bash and know a bit of powershell.

 The script is not polished and doesn't handle branch/fork cases. But it's a start. I put it up on github if it can help anyone.

 https://github.com/mlbrown7/scripts/blob/master/BitBucketTeamCloneAll.ps1