Gayhub被微软收购了,从网上找了一个备份脚本,还是有备无患下吧。
原地址https://blog.csdn.net/guguant/article/details/78204912

#!/bin/bash
# tool
# auto backup all repositories from github
if [[ $# -eq 0 ]] || [[ $1 = "-h" ]];then
    echo -e "\033[31m--------------------------------------------------------\033[0m"
    echo "Usage1: $0 URL"
    echo "   e.g: $0 https://github.com/Guguant?tab=repositories"
    echo ""
    echo "Usage2: $0 Username Page"
    echo "   e.g: $0 Guguant 1"
    echo -e "\033[31m--------------------------------------------------------\033[0m"
    exit 1;
fi

url=""
username=""
if [ $# == 1 ];then
    url="https://github.com/knickersgod?tab=repositories"
    username=${url%\?*}
    username=${username##*/}
else
    username=$1
    url="https://github.com/${username}?page=${2}&tab=repositories"
fi

patten1="a href=\"/"${username}"/"
r_path=`curl "${url}" | grep "${patten1}"`

# get repositories url path
path_head="https://github.com/"
for p in ${r_path}
do
    if [[ $p =~ "href" ]];then
        p=${p#*/}
        p=${p%\"*}

        p=${path_head}${p}
        echo -e "\033[33m ====== Download ====================\033[0m"
        echo -e "\033[32m $p \033[0m"
        git clone ${p}
        echo -e "\033[33m ====== $p has been Finished =================\033[0m"
    fi
done

标签: none

添加新评论