Mercurial > repos > public > bitbucket_backup_scripts
comparison download_team_repos.sh @ 0:507ba2547208 default tip
Initial commit
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 30 Jun 2020 15:52:36 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:507ba2547208 |
---|---|
1 #!/bin/bash | |
2 | |
3 # Usage: downloader.sh username teamname | |
4 USER=${1} | |
5 TEAM=${2} | |
6 | |
7 if [ -d "$TEAM" ] | |
8 then | |
9 echo "Team folder already exists" | |
10 exit 1 | |
11 fi | |
12 | |
13 mkdir "$TEAM" | |
14 cd $TEAM | |
15 | |
16 i=1 | |
17 NEXT_URL="https://api.bitbucket.org/2.0/repositories/${TEAM}?pagelen=100" | |
18 | |
19 while [ $NEXT_URL != null ] | |
20 do | |
21 curl -u $USER $NEXT_URL > repoinfo"$i".json | |
22 jq -r '.values[] | .links.clone[1].href' repoinfo"$i".json >> repos.txt | |
23 i=$((i++)) | |
24 NEXT_URL=`jq -r '.next' repoinfo"$i".json` | |
25 done | |
26 | |
27 for repo in `cat repos.txt` | |
28 do | |
29 echo "Cloning" $repo | |
30 if echo "$repo" | grep -q ".git"; then | |
31 command="git" | |
32 else | |
33 command="hg" | |
34 fi | |
35 $command clone $repo | |
36 done | |
37 | |
38 cd .. |