配置gitlab的备份目录路径设置

# vim /etc/gitlab/gitlab.rb
gitlab_rails['manage_backup_path'] = true
gitlab_rails['backup_path'] = "/var/opt/gitlab/backups" #gitlab备份目录
gitlab_rails['backup_archive_permissions'] = 0644 #生成的备份文件权限
gitlab_rails['backup_keep_time'] = 604800 #备份保留天数为7天

配置生效

# gitlab-ctl reconfigure
# gitlab-ctl restart

手动备份gitlab

# gitlab-rake gitlab:backup:create
定时备份
# crontab -e
#每周日零点备份gitlab
00 00 * * 7 /usr/bin/gitlab-rake gitlab:backup:create >/dev/null 2>&1

gitlab恢复操作

gitlab只能还原与备份文件相同的gitlab版本

# yum install -y gitlab-ce
# gitlab-rake gitlab:backup:restore BACKUP=1546407036_2019_01_02_11.2.1
Unpacking backup ... done
GitLab version mismatch:
Your current GitLab version (11.5.0) differs from the GitLab version in the backup!
Please switch to the following version and try again:
version: 11.2.1
# yum remove gitlab-ce
# yum install -y gitlab-ce-11.2.1
# gitlab-ctl reconfigure
# gitlab-ctl start
# gitlab-rake gitlab:backup:restore BACKUP=1546407036_2019_01_02_11.2.1