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.



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

for page in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
    curl --user ${username}:${password}${username}?page=${page}\&role=contributor | grep -o '"ssh:[^ ,]\+' | xargs -L1 echo >> repos
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
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...

2,035 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