华域联盟 linux shell 一键备份gitolite服务器的Shell脚本

一键备份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脚本

转载请保留出处和原文链接:https://www.cnhackhy.com/16059.htm

本文来自网络,不代表华域联盟立场,转载请注明出处。

作者: sterben

发表回复

联系我们

联系我们

2551209778

在线咨询: QQ交谈

邮箱: [email protected]

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部