在CentOS系统上备份和恢复GitLab主要包括以下步骤:
gitlab-rake gitlab:backup:create
创建备份。这将在 /var/opt/gitlab/backups
目录下生成一个压缩包,包含Git仓库、数据库、上传文件、CI/CD相关数据等。crontab
设置定时任务,例如每天凌晨2点执行备份:0 2 * * * /usr/bin/gitlab-rake gitlab:backup:create
确保 /usr/bin/gitlab-rake
符号链接存在,或替换为实际路径。/etc/gitlab/gitlab.rb
文件中配置备份路径和权限:gitlab_rails['backup_path'] = "/mnt/backups"
gitlab_rails['backup_archive_permissions'] = 0644
gitlab_rails['backup_keep_time'] = 604800
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
/var/opt/gitlab/backups
目录。sudo gitlab-rake gitlab:backup:restore BACKUP=备份编号
其中备份编号是备份文件名的时间戳部分。sudo gitlab-ctl start
通过以上步骤,可以在CentOS上为GitLab设置有效的备份和恢复策略,确保数据安全和业务连续性。