Bitbucket Server Rest Api: Clone all repositories

I want to clone all repositories in my Bitbucket Server in order to have backups.

I trying to use Bitbucket rest api but not getting the required list of all repositories.

  curl -u username:password  https://servername:9090/rest/api/1.0/projects/~username/repos -k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    61    0    61    0     0    230      0 --:--:-- --:--:-- --:--:--   230{"size":0,"limit":25,"isLastPage":true,"values":[],"start":0}

 Is anything I am missing in command.

I have gone through the Bitbucket rest api doc but and using same command from there but not getting the required result.

2 answers

Try this. You may have to do some modifications.

Install stashy -

#!/usr/bin/env python

import stashy, os stash = stashy.connect("http://localhost:7990/stash", "admin", "admin")

projects =

for project in projects:
for repo in bitbucket.projects["%s" %(project["key"])].repos.list():
for url in repo["links"]["clone"]:
// http or ssh
if (url["name"] == "ssh"):
os.system("git clone %s" %(url["href"]))

Thanks for the response edwin. I have alredy tried this and it will not work.


1st- I am using bitbucket server.

2nd, With rest api of bitbucket server you can only list the personal repositories.

Try stashy instead (i've edited the script above), make sure you have access to the repos you want to backup.

Try this curl:

curl -sku username:password https://servername:9090/rest/api/1.0/users/usernamehere/repos

Is there a way to move from Stash to Bitbucket cloud?

Yes using the Stash server API and Bitbucket Cloud API but you have to do everything yourself manually or with a script, there is no Atlassian tool and they won't help you with the migration.

So I guess for a few repositories, better to this manually. It is SHAME that atlassian does not provide a tool that allow the migration between Atlassian products

Yes I agree, I developed a bash script to handle a migration which I may release on GitHub if I can clean it up and make it easy for others to run.

That would be great and I am sure it will help a lot of people :-)

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Jira Service Desk

Wy are we still using email for Service Desk workflows?

...attest to the experience of an urgent approval that gets lost in the boss’s inbox and requires that special “Please Approve” email or text message. In an age where we have distributed teams...

111 views 0 2
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