一键备份gitolite服务器的Shell脚本
运行一次就能够把gitolite服务器上的仓库备份到本地. 第一次运行会创建远程仓库的本地镜像, 以后每次运行会把本地镜像更新.
本程序只支持 ssh方式
其他的git server貌似不会在 ssh git@xxx 的时候返回repo列表, 所以只能手动备份.
#!/bin/sh server=serv_addr root_dir=`pwd` echo "whill back in dir: ${root_dir}" ssh "git@${server}" | awk '{print $1$2,$3}' | grep "^RW" | awk '{print $2}' | while read line do echo " " echo "-------------------------------------" if [ ! -d "${root_dir}/${line}.git" ]; then echo "repo not init on local, init it ..." mkdir -p "${root_dir}/${line}.git" cd "${root_dir}/${line}.git" cd .. git clone --mirror "git@${server}:${line}.git" else echo "repo already init on local, update it ..." cd "${root_dir}/${line}.git" git remote update git gc fi done
相关推荐
huha 2020-10-16
laisean 2020-11-11
大牛牛 2020-10-30
firefaith 2020-10-30
liguojia 2020-10-20
wangzhaotongalex 2020-10-20
以梦为马不负韶华 2020-10-20
JohnYork 2020-10-16
Julyth 2020-10-16
applecarelte 2020-10-16
laisean 2020-09-27
flycappuccino 2020-09-27
liguojia 2020-09-27
wangzhaotongalex 2020-09-22
流年浅滩 2020-10-23
liujianhua 2020-10-22
woaimeinuo 2020-10-21
tufeiax 2020-09-03
laisean 2020-09-01
vvu 2020-09-16
libao 2020-09-16
Yyqingmofeige 2020-08-18
zhushixia 2020-08-17