How do I migrate from a private git server to Bitbucket Server without manually creating all the projects/repositories again?

I would like to move all the repositories from our old server (gitblit) to Bitbucket Server for the JIRA integration.

Is there a way to mass-import all the repositories without manually recreating all the projects and repositories and cloning/pushing them again?

Also, is there a way to directly link our JIRA projects with Bitbucket, so I don't need to recreate all the Bitbucket projects? The link has been established, but I can only really see JIRA users.

Thanks!

3 answers

1 accepted

1 vote
Jeff Thomas Atlassian Team Jan 25, 2016

There is the Stash Importer tool that will help accomplish part of what you're after and reduce some of the manual work.

The command line tool will take a collection of repositories on disk, create the project/repositories and then push them to Bitbucket Server. It can do this iteratively so you can refine the project/repo names for each on-disk repository. You'll need to have a clone of all the repositories you'd like to import on the same machine that the script is being run from. 

The binary is available at https://bitbucket.org/atlassianlabs/stash-importer/downloads/stash-importer-0.1-distribution.zip

There is a readme file in the binary distribution which explains how to use it.

* A quick search in the Atlassian Marketplace returns nothing for an "gitblit" related add-ons.

Reference: https://www.wildcardcorp.com/blog/migrating-a-lot-of-repositories-to-stash

So I guess your best way here is to create it via the BBSERV API. A quick search in google said something about a company migrating them programatically via scripts, just like this.

Reference: https://www.wildcardcorp.com/blog/migrating-a-lot-of-repositories-to-stash

Thanks to both of you!

I managed to import our projects with a combination of both solutions.

The Stash Importer nicely created the projects and repositories, but failed actually importing those:

Failed to create Stash repository for repository "Something": Failed to create repository "Something" in project "ABC": key not found: cloneUrl

Probably some changes to the API?

Anyway, I then regexed the devil out of the import.list to fit the clone_repos script, which (after a minor alteration) nicely moved all the repositories. I think there's room for improvement (by using bare repos and mirrors), but it worked nicely.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

1,745 views 1 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you