如何让百度快照找到自己的网站ppt免费下载模板网站
思路:
1. ssh 配置
2. reps.txt 列出所有仓库名
3. exp的自动化备份脚本
--
环境安装:
exp需要依赖安装的文件,所以先执行下(以ubuntu为例):
   sudo apt-get install expect 
操作步骤:
ssh 配置
1. 添加公钥至 Gitee(Linux服务器)
 
ssh-keygen -t rsa -C "your_email@example.com" -f ~/.ssh/gitee
 cat ~/.ssh/gitee.pub
 2. 编写 config 文件
 
 在 ~/.ssh/ 目录中创建或编辑 config 文件,添加以下内容:
Host GiteeUser gitHostname gitee.comIdentityFile ~/.ssh/gitee
 

注意事项
-  
确保
~/.ssh/目录和config文件的权限设置正确。通常使用以下命令设置权限: 
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"  ;# 假设镜像仓库存储在当前目录下,名称为 $line.git# 检查镜像仓库是否存在if {![file exists $mirror_path]} {# 如果不存在,克隆镜像spawn git clone --mirror $repo_path} else {# 如果存在,进入镜像目录并执行更新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
 
 
推荐方案
对于数字资产的长期备份,推荐使用 git clone --mirror 和 git fetch --all 的结合方式.
再做个定时任务,就OKAY了。
