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

Suggest an answer

Log in or Join to answer
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...

716 views 0 4
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot