您现在的位置是:网站首页> 编程资料编程资料
一键备份gitolite服务器的Shell脚本_linux shell_
2023-05-26
318人已围观
简介 一键备份gitolite服务器的Shell脚本_linux 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您可能感兴趣的文章:
相关内容
- Shell中取今天、昨天、前天的时间操作代码_linux shell_
- Shell脚本判断Apache进程是否存在_linux shell_
- Shell脚本监控网站页面正常打开情况_linux shell_
- shell中使用echo打印彩色字体和彩色背景的方法_linux shell_
- Shell脚本实现温和方式重启Centos系统_linux shell_
- Shell脚本判断Linux系统是32位还是64位的几种方法分享_linux shell_
- Shell脚本中调用、引用、包含另外一个脚本文件的两种方法_linux shell_
- shell脚本实现批量测试局域网主机是否在线_linux shell_
- shell脚本实现文件锁功能_linux shell_
- shell中的数组操作小结和冒泡排序实现脚本分享_linux shell_
