gitlab备份迁移
1. 备份
#/bin/bash
#用途:备份gitlab
DAY=`date +%Y-%m-%d`
BAK_DIR=/data/backup/
chown -R git.git $BAK_DIR
mkdir -p $BAK_DIR/logs/
gitlab-rake gitlab:backup:create >/data/backup/logs/$DAY-bakup.log 2>&1
2. 迁移恢复
2.1 安装gitlab
#1.安装依赖
yum install curl policycoreutils openssh-serveropenssh-clients
yum install curl policycoreutils policycoreutils-python openssh-server openssh-clients -y
yum install policycoreutils-python.x86_64
#2.下载安装包,安装
gitlab安装包下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.10.1-ce.0.el7.x86_64.rpm
chmod 755 gitlab-ce-11.10.1-ce.0.el7.x86_64.rpm
rpm -ivh gitlab-ce-11.10.1-ce.0.el7.x86_64.rpm
2.2 恢复备份文件
#在旧服上执行
scp -P 22201 /etc/gitlab/gitlab.rb root@xxx.xxx.xxx.xxx:/etc/gitlab/gitlab.rb
gitlab-ctl stop
scp -P 22201 1662392365_2022_09_05_11.10.1_gitlab_backup.tar root@xxx.xxx.xxx.xxx:/data/backup/
#在新服上执行
gitlab-rake gitlab:backup:restore BACKUP=1662392365_2022_09_05_11.10.1 (备份文件编号)
gitlab-ctl reconfigure
#重新加载配置并启动所有项目
gitlab-ctl reconfigure
gitlab-ctl restart
gitlab-ctl status
3. 校验
登录gitlab,检查group与project数量,随机查看project