2016-09-16 37 views
0

當前我們有一個bash腳本,它將通過硬盤上每個存儲庫的bitbucket存儲克隆並備份該硬盤。最近雖然庫的數量已經超過100。到位桶API PAGELEN計數我一直無法找到一個更好的辦法來做到這一點,使我們可以備份超過100使用bash腳本備份bitbucket的問題

repositories=`curl -s -S --user <user>:<password> https://api.bitbucket.org/2.0/repositories/<name>\?pagelen\=100 | jq -r '.values[] | "\(.full_name)"'` 

echo "backup-bitbucket STARTED -- " $(date +"%m-%d-%Y"+"%T") >> ${LOGFILE} 

# Back up each bitbucket repository by cloning or pulling the latest changes 
for i in $repositories 
do 
    echo "Starting backup for repository ${i}..." >> ${LOGFILE} 

    if [ -d "${BACKUPTODIR}${i}" ]; then 
      git -C ${BACKUPTODIR}${i} pull 
    else 
      git clone https://<user>:<password>@bitbucket.org/${i}.git ${BACKUPTODIR}${i} 
    fi 

    echo "Completing backup for repository ${i}..." >> ${LOGFILE} 
done 

在這個問題上的任何幫助將不勝感激

+1

嘗試加入'&頁= 2'來看看你未來的100項 – CMPS

+0

如果我編輯捲曲以包括'\?pagelen \ = 100&page = 2'jq轉換不會發生,我得到直JSON –

+0

檢查我的答案,您需要在url附加引號 – CMPS

回答

1

我試過它在我的終端上,並且有可能在url中添加page選項。

所以&page=2給你未來100個結果

當您添加&page確保你把引號將URL

+0

感謝您的協助! –