gitlab 仓库迁移&升级

第一步,克隆项目到本地

完全迁移需将 --bare 换成 --mirror ,然后修改远程项目地址为第二步建的空项目,再执行push命令。使用--mirror推送时容易报错

git clone --bare http://127.0.0.1:8080/houtai/test.git

 第二步,在目标服务器新建一个空项目

http://10.15.4.11:7979/houtai/test.git

第三步,push项目到目标服务器新建项目

// 进入项目目录
cd test.git
// 推送到目标服务器
git push --mirror http://10.15.4.11:7979/houtai/test.git

结束

注:原项目使用方式只需切换远程地址

git remote set-url origin http://10.15.4.11:7979/houtai/test.git
// 查看地址是否切换成功
git remote -v

升级可能用到的命令

# 备份文档
gitlab-rake gitlab:backup:create

# 还原命令 到版本号就行 
gitlab-rake gitlab:backup:restore BACKUP=1685357636_2023_05_29_11.3.0

# gitLab 升级不能跨版本,需要先升级到指定版本才可以继续升级
# 升级顺序参考官网地址:
# https://docs.gitlab.com/ee/update/index.html#upgrade-paths
# 或
# https://gitlab-com.gitlab.io/support/toolbox/upgrade-path/?current=11.3.14&target=15.11.6&distro=docker&edition=ce

# docker 安装
# 拉取指定版本,例如15.4.6版本
docker pull gitlab/gitlab-ce:15.4.6-ce.0 &

# 安装
sudo docker run --detach \
  --publish 443:443 --publish 80:80 --publish 8222:22 \
  --name gitlabs \
  --restart always \
  --volume /home/gitlabs/config:/etc/gitlab:Z \
  --volume /home/gitlabs/logs:/var/log/gitlab:Z \
  --volume /home/gitlabs/data:/var/opt/gitlab:Z \
    gitlab/gitlab-ce:15.4.6-ce.0


# 安装时会执行:gitlab-ctl reconfigure, 该命令会升级仓库信息
# 版本13 升级 版本14容易失败,最好每次升级成功后都先备份下

# rpm 安装
# 以centos7安装版本13.12.15为例
wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-13.12.15-ce.0.el7.x86_64.rpm/download.rpm
rpm -ivh gitlab-ce-15.11.6-ce.0.el7.x86_64.rpm

# 修改配置
vi /etc/gitlab/gitlab.rb

gitlab-ctl reconfigure

gitliab下载地址

gitlab/gitlab-ce - Packages · packages.gitlab.com

 错误处理

1,错误提示:Whoops, something went wrong on our end

查询日志:tail -n 600 /var/log/gitlab/gitlab-rails/production.log

错误信息包含:OpenSSL::Cipher::CipherError ():

处理方法:

# 进入db控制台
sudo gitlab-rails dbconsole

# 执行如下,清除token
UPDATE projects SET runners_token = null, runners_token_encrypted = null;
UPDATE namespaces SET runners_token = null, runners_token_encrypted = null;
UPDATE application_settings SET runners_registration_token_encrypted = null;
UPDATE application_settings SET encrypted_ci_jwt_signing_key = null;
UPDATE ci_runners SET token = null, token_encrypted = null;

2,由备份文件还原仓库

1)解压备份文件,找到 仓库名.bundle文件

2)在gitlab私服创建新的仓库,记录新仓库地址

3)执行如下命令

# 解压
git clone 仓库名.bundle

# 进入仓库
cd 仓库名

# 执行
git remote rename origin old-origin
git remote add origin 仓库地址
git push -u origin --all
git push -u origin --tags

注, 该还原方法会造成部分标签丢失

你可能感兴趣的:(开发工具,git)