在 CentOS 上回滚 GitLab,通常分为 GitLab 应用版本回滚 和 代码仓库回滚 两种场景。下面分别说明。
rpm -q gitlab-ce
# 或
cat /opt/gitlab/version-manifest.txt
gitlab-ctl stop
yum install -y gitlab-ce-16.0.0-ce.0.el7.x86_64
或从清华镜像下载:
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-16.0.0-ce.0.el7.x86_64.rpm
rpm -Uvh gitlab-ce-16.0.0-ce.0.el7.x86_64.rpm
gitlab-ctl reconfigure
gitlab-ctl start
⚠️ 注意:
gitlab-rake gitlab:backup:create
git log
git reset --hard <commit_id>
git push --force origin branch_name
git revert <commit_id>
git push origin branch_name
如果升级失败且数据库已变更:
# 恢复备份
gitlab-rake gitlab:backup:restore BACKUP=时间戳
备份文件位置:
/var/opt/gitlab/backups/
✅ 回滚前一定备份
✅ 尽量使用 revert 而非 reset
✅ 生产环境避免跨大版本回滚
如果你能告诉我:
我可以直接给你精确回滚命令。