在CentOS上迁移GitLab数据库是一个复杂但必要的任务,以下是详细的迁移策略:
备份当前数据库:
pg_dump
命令备份PostgreSQL数据库:sudo -u postgres pg_dump -d gitlabhq_production > gitlab-backup.sql
备份GitLab配置文件和附件:
/etc/gitlab/gitlab.rb
和 /var/opt/gitlab/config
目录。/var/opt/gitlab/shared
目录。停止GitLab服务:
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
sudo -u postgres createdb gitlabhq_production_new
sudo -u postgres psql gitlabhq_production_new < gitlab-backup.sql
恢复GitLab配置文件和附件:
恢复数据库:
gitlab-rake gitlab:backup:restore
命令恢复数据库备份:sudo gitlab-rake gitlab:backup:restore BACKUP_TIMESTAMP
更新新服务器上的GitLab配置:
/var/opt/gitlab/gitlab.rb
文件,更新数据库连接信息:gitlab_rails['gitlab_shell_ssh_port'] '22'
gitlab_rails['gitlab_shell_ssh_host'] 'your-new-server-ip'
重新配置并启动GitLab:
sudo gitlab-ctl reconfigure
sudo gitlab-ctl start