参考地址
http://www.jianshu.com/p/c913ce6c3eac
http://www.thinksaas.cn/topics/0/400/400475.html
http://www.jianshu.com/p/73890374b044
主机: 192.168.0.21
备用机: 192.16.0.29
操作环境: CentOs7
主仓库实现已经配置好
git clone git@192.168.0.21:/home/data/git/gittest.git
备用仓库
添加用户
[root@localhost home]# id git
id: git:无此用户
[root@localhost home]# useradd git
[root@localhost home]# passwd git
进入/home/data/git目录
从远程仓库克隆镜像仓库
git clone -mirror git@192.168.0.21:/home/data/git/gittest.git
更新镜像库
git remote update
使用公钥使更新时免输密码
ssh-keygen -t rsa -C "youemail@qq.com"
ssh git@192.168.0.21 'cat >> .ssh/authorized_keys' < /root/.ssh/id_rsa.pub
再试试
git remote update
Crontab实现定时更新
编写脚本文件
/home/data/git/sh/updategit.sh编写
#!/bin/sh
cd /home/data/git/gittest.git
git remote update >> /home/data/git/log/gitupdate.log
记得赋执行权限
chmod 755 gitupdate.sh
crontab -e
*/1 * * * * /home/data/git/sh/gitupdate.sh