gitlab服务有非常简洁的每日备份命令,
从production的gitlab的每日备份中restore到backup环境也非常方便。
一、Production gitlab每日备份
1. Production gitlab环境上编写脚本
cat /root/gitlab_bak.sh
gitlab-rake gitlab:backup:create > /var/opt/gitlab/backups/log/$(date +"%Y-%m-%d-%H:%M:%S").log
运行这个脚本,会生成tar包到gitlab配置文件中指定的backup路径。
gitlab配置文件(/etc/gitlab/gitlab.rb)中配置backup路径的部分如下:(默认路径为/var/opt/gitlab/backups)
### Backup Settings
###! Docs: https://docs.gitlab.com/omnibus/settings/backups.html
# gitlab_rails['manage_backup_path'] = true
gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"
2. 创建定时任务进行每日备份
0 2 *