一键备份gitolite服务器的Shell脚本
运行一次就能够把gitolite服务器上的仓库备份到本地.第一次运行会创建远程仓库的本地镜像,以后每次运行会把本地镜像更新.
本程序只支持ssh方式
其他的gitserver貌似不会在sshgit@xxx的时候返回repo列表,所以只能手动备份.
#!/bin/shserver=serv_addr
root_dir=`pwd`
echo"whillbackindir:${root_dir}"
ssh"git@${server}"|awk'{print$1$2,$3}'|grep"^RW"|awk'{print$2}'|whilereadlinedo
echo""
echo"-------------------------------------"
if[!-d"${root_dir}/${line}.git"];then
echo"reponotinitonlocal,initit..."
mkdir-p"${root_dir}/${line}.git"
cd"${root_dir}/${line}.git"
cd..
gitclone--mirror"git@${server}:${line}.git"
else
echo"repoalreadyinitonlocal,updateit..."
cd"${root_dir}/${line}.git"
gitremoteupdate
gitgc
fidone