Forked from davidegironi/_bitbucket-git-downloader.sh
Created
November 2, 2023 08:05
-
-
Save bsdnomad/c34b6bc21e49b151ac7623c8dab3fc43 to your computer and use it in GitHub Desktop.
Script to download all repositories from a Bitbucket account
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bitbucket Git Downloader | |
# Copyright (c) Davide Gironi, 2021 | |
# Released under GPLv3 | |
# Downloads all the repository from a Bitbucket account |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Bitbucket Git Downloader | |
# Copyright (c) Davide Gironi, 2021 | |
# Released under GPLv3 | |
DATAFOLDER=gitdata | |
if [ -z "$GIT_USERNAME" ]; then | |
echo "No GIT_USERNAME supplied" | |
exit | |
fi | |
if [ -z "$GIT_PASSWORD" ]; then | |
echo "No GIT_PASSWORD supplied" | |
exit | |
fi | |
if [ ! -d "$DATAFOLDER" ]; then | |
echo "data folder does not exists" | |
exit | |
fi | |
cd $DATAFOLDER | |
user=$GIT_USERNAME:$GIT_PASSWORD | |
url='https://api.bitbucket.org/2.0/user/permissions/repositories' | |
while [ ! "$url" == "null" ] | |
do | |
curl -u $user $url > repositories.json | |
jq -r '.values[] | .repository.links.html.href' repositories.json > repositories.txt | |
for repo in `cat repositories.txt` | |
do | |
REPOSITORYNAME=`basename "$repo"` | |
echo "Cloning" $REPOSITORYNAME | |
if [ -d $REPOSITORYNAME ] | |
then | |
cd $REPOSITORYNAME | |
git pull | |
cd .. | |
else | |
git clone $repo | |
fi | |
done | |
url=`jq -r '.next' repositories.json` | |
done | |
rm repositories.json | |
rm repositories.txt | |
cd - |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Bitbucket Git Downloader | |
# Copyright (c) Davide Gironi, 2021 | |
# Released under GPLv3 | |
#downloads all the repository from a Bitbucket account | |
#set you credential | |
#to store your password use git credential helper | |
# git config --global credential.helper store | |
export GIT_USERNAME=gitusername | |
export GIT_PASSWORD=gitpassword | |
./bitbucketgitdownloader.sh | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment