在CentOS系统中,GitLab的备份和恢复流程主要包括以下几个步骤:
curl, openssh-server, postfix 等。gitlab-ce-omnibus 包安装GitLab。/etc/gitlab/gitlab.rb 文件,设置备份路径,例如:gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"
gitlab_rails['backup_archive_permissions'] = 0644
gitlab_rails['backup_keep_time'] = 604800 # 备份保留天数为7天
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
sudo gitlab-rake gitlab:backup:create
/var/opt/gitlab/backups 目录下。crontab 设置定时任务,例如每天凌晨2点执行备份:0 2 * * * /usr/bin/gitlab-rake gitlab:backup:create
/usr/bin/gitlab-rake 符号链接存在,或替换为实际路径。/etc/gitlab/gitlab.rb 文件中。pg_dump 命令备份数据库:sudo -u postgres pg_dump -Fc --rolegitlab-psql --passwordYOUR_POSTGRESQL_PASSWORD gitlabhq_production > /backup/gitlab/db_backup.dump
tar 文件:sudo tar -czvf /backup/gitlab/backup.tar.gz /backup/gitlab/
sudo find /backup/gitlab/ -type f -name "*.tar.gz" -mtime 7 -exec rm {} \;
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
tar -xzf gitlab_backup.tar.gz
sudo gitlab-rake gitlab:backup:restore BACKUP=备份文件名
yes 以确认操作。cp -r repositories/* /var/opt/gitlab/git-data/repositories/
sudo gitlab-ctl start
sudo gitlab-ctl restart
gitlab.rb 和 gitlab-secrets.json 配置文件,这些需要手动备份。希望这些信息能帮助您在CentOS系统中成功备份和恢复GitLab。如果有任何问题,请随时联系。