Mercurial > repos > public > bitbucket_backup_scripts
comparison download_user_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 | |
6 if [ -d "$USER" ] | |
7 then | |
8 echo "User folder already exists" | |
9 exit 1 | |
10 fi | |
11 | |
12 mkdir "$USER" | |
13 cd $USER | |
14 | |
15 i=1 | |
16 NEXT_URL="https://api.bitbucket.org/2.0/repositories/${USER}?pagelen=100&role=member" | |
17 while [ $NEXT_URL != null ] | |
18 do | |
19 curl -u $USER $NEXT_URL > repoinfo"$i".json | |
20 jq -r '.values[] | .links.clone[1].href' repoinfo"$i".json >> repos.txt | |
21 i=$((i++)) | |
22 NEXT_URL=`jq -r '.next' repoinfo"$i".json` | |
23 done | |
24 | |
25 exit 0 | |
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 .. |