蚌埠做網(wǎng)站建設(shè)費用營銷推廣計劃書
思路:
1. ssh 配置
2. reps.txt 列出所有倉庫名
3. exp的自動化備份腳本
--
環(huán)境安裝:
exp需要依賴安裝的文件,所以先執(zhí)行下(以ubuntu為例):
? ?sudo apt-get install expect
操作步驟:
ssh 配置
1. 添加公鑰至 Gitee(Linux服務(wù)器)
?
ssh-keygen -t rsa -C "your_email@example.com" -f ~/.ssh/gitee
cat ~/.ssh/gitee.pub
?2. 編寫 config
文件
?在 ~/.ssh/
目錄中創(chuàng)建或編輯 config
文件,添加以下內(nèi)容:
Host GiteeUser gitHostname gitee.comIdentityFile ~/.ssh/gitee
注意事項
-
確保
~/.ssh/
目錄和config
文件的權(quán)限設(shè)置正確。通常使用以下命令設(shè)置權(quán)限:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/gitee
chmod 600 ~/.ssh/config
整理需要clone的倉庫名稱:reps.txt
rep001
rep002
rep003
自動化備份腳本?
vim clone_repos.exp
#!/usr/bin/expectset original_dir [pwd] ;# 記錄當前的原始目錄
set rep [open "reps.txt"]
while { [gets $rep line] != -1 } {set repo_path Gitee:chihj/$line.git"set mirror_path "$line.git" ;# 假設(shè)鏡像倉庫存儲在當前目錄下,名稱為 $line.git# 檢查鏡像倉庫是否存在if {![file exists $mirror_path]} {# 如果不存在,克隆鏡像spawn git clone --mirror $repo_path} else {# 如果存在,進入鏡像目錄并執(zhí)行更新cd $mirror_pathspawn git fetch --all --prune}expect {"Are you sure you want to continue connecting" {send "yes\r"expect eof}eof}# 返回到原始目錄cd $original_dir
}close $rep
運行:?
chmod +x clone_repos.exp
./clone_repos.exp
推薦方案
對于數(shù)字資產(chǎn)的長期備份,推薦使用 git clone --mirror
和 git fetch --all?
的結(jié)合方式.
再做個定時任務(wù),就OKAY了。