本机备份
利用crontab备份
#定时备份
0 9-21/4 * * 1-5 /opt/gitlab/bin/gitlab-rake gitlab:backup:create
#删除超过7天的备份
30 2 * * * find "/var/opt/gitlab/backups/" -name "*.tar" -mtime +7 -type f -exec rm -rf {} \;
#每5分钟同步时间
5 * * * * /usr/sbin/ntpdate us.pool.ntp.org
异机备份
#利用rsync(需提前配置)进行同步,此同步只是同步源主机备份的tar包
30 10-22/6 * * * rsync -vzrtopg --progress --delete --password-file=/etc/rsync_client.pass backup@192.168.6.102::gitlab /var/opt/gitlab/backups/
#数据源同步
5 10-22/2 * * * rsync -vzrtopg --progress --delete --password-file=/etc/rsync_client.pass backup@192.168.6.102::opt_gitlab /opt/gitlab
5 10-22/2 * * * rsync -vzrtopg --progress --delete --exclude backups/ --password-file=/etc/rsync_client.pass backup@192.168.6.102::var_opt_gitlab /var/opt/gitlab
注意:
1.同步源数据需要关闭备份机上的GitLab服务
2.第二步同步/var/opt/gitlab具体可以同步这个目录 /var/opt/gitlab/git-data/repositories