一键备份gitolite服务器的Shell脚本

发布时间:2022-04-19 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了一键备份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

脚本宝典总结

以上是脚本宝典为你收集整理的一键备份gitolite服务器的Shell脚本全部内容,希望文章能够帮你解决一键备份gitolite服务器的Shell脚本所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:一键备份