Help to Write a Backup Script for Bitbucket Repositories

I have been trying to write an script to backup my repos at Bitbucket using the paged feature of the REST API. Here, the code I wrote.

 

#!/bin/bash

echo -n "Username: ";
read username;
echo -n "Password: "; 
read -s password
echo
rm -f repos 

for page in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
do
    curl --user ${username}:${password} https://api.bitbucket.org/2.0/repositories/${username}?page=${page}\&role=contributor | grep -o '"ssh:[^ ,]\+' | xargs -L1 echo >> repos
done
cat repos | xargs -L1 git clone
exit 0;

However, I can only fetch my own repos but not those one where I am a contributor and I don't own. Observe that I tried to use role=contributor but it seems to be ignored.

Any ideas?

0 answers

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
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

22,317 views 26 12
Join discussion

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