58-CICD持续集成工具-Git和GitLab

时间:2023-02-07 19:15:30

Ubuntu 编译安装 git

  • 拉取git安装包(获取国外资源网速受限,可以clon到gitee项目中,从国内拉取)

58-CICD持续集成工具-Git和GitLab

[root@ubuntu2204 ~]#apt update;apt -y install gcc make dh-autoreconf libcurl4-
gnutls-dev libexpat1-dev
[root@ubuntu2204 ~]#git clone https://gitee.com/lbtooth/git.git
[root@ubuntu2204 ~]#cd git
[root@ubuntu2204 git]#make -j `grep -c processor /proc/cpuinfo` prefix=/apps
[root@ubuntu2204 git]#make prefix=/apps/git install
[root@ubuntu2204 git]#echo 'PATH=/apps/git/bin/:$PATH' > /etc/profile.d/git.sh
[root@ubuntu2204 git]#. /etc/profile.d/git.sh
[root@ubuntu2204 ~]#git version
git version 2.39.1.388.g2fc9e9ca3c

案例: 利用git做项目的完整过程

  • 初始化项目文件夹、创建文件、修改文件、回滚、创建分支、合并、日志查看
[root@ubuntu2204 ~]#mkdir /meta-project
#进入要管理的文件夹
[root@ubuntu2204 ~]#cd /meta-project

#执行初始化命令
[root@ubuntu2204 meta-project]#git init
提示:使用 'master' 作为初始分支的名称。这个默认分支名称可能会更改。要在新仓库中
提示:配置使用初始分支名,并消除这条警告,请执行:
提示:
提示: git config --global init.defaultBranch <名称>
提示:
提示:除了 'master' 之外,通常选定的名字有 'main'、'trunk' 和 'development'。
提示:可以通过以下命令重命名刚创建的分支:
提示:
提示: git branch -m <name>
已初始化空的 Git 仓库于 /meta-project/.git/
[root@ubuntu2204 meta-project]#touch test.html
[root@ubuntu2204 meta-project]#vim test.html
[root@ubuntu2204 meta-project]#cat test.html
hello git

#管理目录下的文件状态
[root@ubuntu2204 meta-project]#git status
位于分支 master

尚无提交

未跟踪的文件:
(使用 "git add <文件>..." 以包含要提交的内容)
test.html

提交为空,但是存在尚未跟踪的文件(使用 "git add" 建立跟踪)
#提交新创建文件
[root@ubuntu2204 meta-project]#git add .

#个人信息配置:用户名和邮箱,只需配置一次即可
[root@ubuntu2204 meta-project]#git config --global user.name "mooreyxia"
[root@ubuntu2204 meta-project]#git config --global user.email "root@mooreyxia.com"
[root@ubuntu2204 meta-project]#git config --global color.ui true

#提交
[root@ubuntu2204 meta-project]#git commit -m "项目开发基本功能v0.0.1"
[master (根提交) 520d79d] 项目开发基本功能v0.0.1
1 file changed, 1 insertion(+)
create mode 100644 test.html

#查看版本记录
[root@ubuntu2204 meta-project]#git log
commit 520d79d9a0a2101bde0f87fa08a96a56a35f71e7 (HEAD -> master)
Author: mooreyxia <root@mooreyxia.com>
Date: Mon Feb 6 20:58:35 2023 +0800

项目开发基本功能v0.0.1

#记录图形展示
[root@ubuntu2204 meta-project]#git log --pretty=oneline --graph --all
* 520d79d9a0a2101bde0f87fa08a96a56a35f71e7 (HEAD -> master) 项目开发基本功能v0.0.1
[root@ubuntu2204 meta-project]#git log --graph --pretty=format:'%h -%d %s (%an, %cd)'
* 520d79d - (HEAD -> master) 项目开发基本功能v0.0.1 (mooreyxia, Mon Feb 6 20:58:35 2023 +0800)
[root@ubuntu2204 meta-project]#touch test1.txt
[root@ubuntu2204 meta-project]#vim test1.txt
[root@ubuntu2204 meta-project]#cat test1.txt
test2
[root@ubuntu2204 meta-project]#git add .
[root@ubuntu2204 meta-project]#git commit -m "添加功能"
[master 7413b37] 添加功能
1 file changed, 1 insertion(+)
create mode 100644 test1.txt
[root@ubuntu2204 meta-project]#git log
commit 7413b378144a3a9765eb8fe2286dba2f14f999a8 (HEAD -> master)
Author: mooreyxia <root@mooreyxia.com>
Date: Mon Feb 6 21:02:00 2023 +0800

添加功能

commit 520d79d9a0a2101bde0f87fa08a96a56a35f71e7
Author: mooreyxia <root@mooreyxia.com>
Date: Mon Feb 6 20:58:35 2023 +0800

项目开发基本功能v0.0.1

#查看所有的历史提交记录
[root@ubuntu2204 meta-project]#git reflog
7413b37 (HEAD -> master) HEAD@{0}: commit: 添加功能
520d79d HEAD@{1}: commit (initial): 项目开发基本功能v0.0.1

#回退到指定的commitID
[root@ubuntu2204 meta-project]#git reset --hard 7413b37
HEAD 现在位于 7413b37 添加功能
[root@ubuntu2204 meta-project]#git reflog
7413b37 (HEAD -> master) HEAD@{0}: reset: moving to 7413b37
7413b37 (HEAD -> master) HEAD@{1}: commit: 添加功能
520d79d HEAD@{2}: commit (initial): 项目开发基本功能v0.0.1
[root@ubuntu2204 meta-project]#git reset --hard 520d79d
HEAD 现在位于 520d79d 项目开发基本功能v0.0.1
[root@ubuntu2204 meta-project]#git status
位于分支 master
无文件要提交,干净的工作区
[root@ubuntu2204 meta-project]#ls
test.html
[root@ubuntu2204 meta-project]#git reset --hard 7413b37
HEAD 现在位于 7413b37 添加功能
[root@ubuntu2204 meta-project]#ls
test1.txt test.html
[root@ubuntu2204 meta-project]#git commit -m "review ok"
位于分支 master
无文件要提交,干净的工作区
[root@ubuntu2204 meta-project]#ls
test1.txt test.html

#查看分支和当前分支
[root@ubuntu2204 meta-project]#git branch
* master

#创建分支
[root@ubuntu2204 meta-project]#git branch dev
[root@ubuntu2204 meta-project]#git branch
dev
* master

#切换分支
[root@ubuntu2204 meta-project]#git checkout dev
切换到分支 'dev'
[root@ubuntu2204 meta-project]#vim index.html
[root@ubuntu2204 meta-project]#cat index.html
branch test1
[root@ubuntu2204 meta-project]#git add .
[root@ubuntu2204 meta-project]#git commit -m "Branch commit1"
[dev 2fd8cc8] Branch commit1
1 file changed, 1 insertion(+)
create mode 100644 index.html
[root@ubuntu2204 meta-project]#git branch
* dev
master
[root@ubuntu2204 meta-project]#ls
index.html test1.txt test.html
[root@ubuntu2204 meta-project]#git checkout maste
error: 路径规格 'maste' 未匹配任何 git 已知文件
[root@ubuntu2204 meta-project]#git checkout master
切换到分支 'master'
[root@ubuntu2204 meta-project]#ls
test1.txt test.html
[root@ubuntu2204 meta-project]#git checkout dev
切换到分支 'dev'
[root@ubuntu2204 meta-project]#ls
index.html test1.txt test.html

#删除分支
[root@ubuntu2204 meta-project]#git branch -d debug
error: 分支 'debug' 未发现。
[root@ubuntu2204 meta-project]#git branch debug
[root@ubuntu2204 meta-project]#git branch
debug
* dev
master
[root@ubuntu2204 meta-project]#git branch -d debug
已删除分支 debug(曾为 2fd8cc8)。
[root@ubuntu2204 meta-project]#git merge dev
已经是最新的。
[root@ubuntu2204 meta-project]#git checkout master
切换到分支 'master'

#将指定分支合并至当前分支
[root@ubuntu2204 meta-project]#git merge dev
更新 7413b37..2fd8cc8
Fast-forward
index.html | 1 +
1 file changed, 1 insertion(+)
create mode 100644 index.html
[root@ubuntu2204 meta-project]#git branch
dev
* master
[root@ubuntu2204 meta-project]#ls
index.html test1.txt test.html
[root@ubuntu2204 meta-project]#git log
commit 2fd8cc8035478b548804a189c71715c523cdabf5 (HEAD -> master, dev)
Author: mooreyxia <root@mooreyxia.com>
Date: Mon Feb 6 21:07:44 2023 +0800

Branch commit1

commit 7413b378144a3a9765eb8fe2286dba2f14f999a8
Author: mooreyxia <root@mooreyxia.com>
Date: Mon Feb 6 21:02:00 2023 +0800

添加功能

commit 520d79d9a0a2101bde0f87fa08a96a56a35f71e7
Author: mooreyxia <root@mooreyxia.com>
Date: Mon Feb 6 20:58:35 2023 +0800

项目开发基本功能v0.0.1
[root@ubuntu2204 meta-project]#
  • 注册和创建的远程软件仓库

58-CICD持续集成工具-Git和GitLab

58-CICD持续集成工具-Git和GitLab


Git 全局设置:

git config --global user.name "YOLO懒喵"
git config --global user.email "12393996+mooreyxia@user.noreply.gitee.com"
创建 git 仓库:

mkdir test-project
cd test-project
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin https://gitee.com/mooreyxia/test-project.git
git push -u origin "master"
已有仓库?

cd existing_git_repo
git remote add origin https://gitee.com/mooreyxia/test-project.git
git push -u origin "master"
  • 将本地仓库同步至远程仓库
[root@ubuntu2204 meta-project]#git config -l
user.name=mooreyxia
user.email=root@mooreyxia.com
color.ui=true
core.repositoryformatversinotallow=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
#给远程仓库起别名
[root@ubuntu2204 meta-project]#git remote add origin https://gitee.com/mooreyxia/test-project.git

#查看关联
[root@ubuntu2204 meta-project]#git remote
origin
[root@ubuntu2204 meta-project]#git remote -v
origin https://gitee.com/mooreyxia/test-project.git (fetch)
origin https://gitee.com/mooreyxia/test-project.git (push)

#推送master分支
[root@ubuntu2204 meta-project]#git push -u origin "master"
Username for 'https://gitee.com': mooreyxia
Password for 'https://mooreyxia@gitee.com':
枚举对象中: 9, 完成.
对象计数中: 100% (9/9), 完成.
使用 2 个线程进行压缩
压缩对象中: 100% (5/5), 完成.
写入对象中: 100% (9/9), 774 字节 | 258.00 KiB/s, 完成.
总共 9(差异 0),复用 0(差异 0),包复用 0
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/mooreyxia/test-project.git
* [new branch] master -> master
分支 'master' 设置为跟踪来自 'origin' 的远程分支 'master'。

#只推送dev分支
[root@ubuntu2204 meta-project]#git checkout dev
切换到分支 'dev'
[root@ubuntu2204 meta-project]#git push origin dev
Username for 'https://gitee.com': mooreyxia
Password for 'https://mooreyxia@gitee.com':
总共 0(差异 0),复用 0(差异 0),包复用 0
remote: Powered by GITEE.COM [GNK-6.4]
remote: Create a pull request for 'dev' on Gitee by visiting:
remote: https://gitee.com/mooreyxia/test-project/pull/new/mooreyxia:dev...mooreyxia:master
To https://gitee.com/mooreyxia/test-project.git
* [new branch] dev -> dev
  • 查看gitee网站可以看到仓库有文件上传成功

58-CICD持续集成工具-Git和GitLab



搭建GitLab

  • 注意:如果内存较低,可以会导致Gitlab有些服务无法启动,建议4G以上内存

案例:

  • Ubuntu 国内镜像下载并安装 GitLab
[root@ubuntu2022 ~]#wget https://mirrors.tuna.tsinghua.edu.cn/gitlabce/ubuntu/pool/bionic/main/g/gitlab-ce/gitlab-ce_15.8.1-ce.0_amd64.deb
[root@ubuntu2022 ~]#dpkg -i gitlab-ce_15.8.1-ce.0_amd64.deb
  • 搭建DNS服务
DOMAIN=mooreyxia.org
HOST=gitlab
HOST_IP=10.0.0.200
LOCALHOST=`hostname -I | awk '{print $1}'`

. /etc/os-release


color () {
RES_COL=60
MOVE_TO_COL="echo -en \\033[${RES_COL}G"
SETCOLOR_SUCCESS="echo -en \\033[1;32m"
SETCOLOR_FAILURE="echo -en \\033[1;31m"
SETCOLOR_WARNING="echo -en \\033[1;33m"
SETCOLOR_NORMAL="echo -en \E[0m"
echo -n "$1" && $MOVE_TO_COL
echo -n "["
if [ $2 = "success" -o $2 = "0" ] ;then
${SETCOLOR_SUCCESS}
echo -n $" OK "
elif [ $2 = "failure" -o $2 = "1" ] ;then
${SETCOLOR_FAILURE}
echo -n $"FAILED"
else
${SETCOLOR_WARNING}
echo -n $"WARNING"
fi
${SETCOLOR_NORMAL}
echo -n "]"
echo
}


install_dns () {
if [ $ID = 'centos' -o $ID = 'rocky' ];then
yum install -y bind bind-utils
elif [ $ID = 'ubuntu' ];then
apt update
apt install -y bind9 bind9-utils bind9-host bind9-dnsutils
else
color "不支持此操作系统,退出!" 1
exit
fi

}

config_dns () {
if [ $ID = 'centos' -o $ID = 'rocky' ];then
sed -i -e '/listen-on/s/127.0.0.1/localhost/' -e '/allow-query/s/localhost/any/' -e 's/dnssec-enable yes/dnssec-enable no/' -e 's/dnssec-validation yes/dnssec-validation no/' /etc/named.conf
cat >> /etc/named.rfc1912.zones <<EOF
zone "$DOMAIN" IN {
type master;
file "$DOMAIN.zone";
};
EOF
cat > /var/named/$DOMAIN.zone <<EOF
\$TTL 1D
@ IN SOA master admin (
1 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS master
master A ${LOCALHOST}
$HOST A $HOST_IP
EOF
chmod 640 /var/named/$DOMAIN.zone
chgrp named /var/named/$DOMAIN.zone
elif [ $ID = 'ubuntu' ];then
sed -i 's/dnssec-validation auto/dnssec-validation no/' /etc/bind/named.conf.options
cat >> /etc/bind/named.conf.default-zones <<EOF
zone "$DOMAIN" IN {
type master;
file "/etc/bind/$DOMAIN.zone";
};
EOF
cat > /etc/bind/$DOMAIN.zone <<EOF
\$TTL 1D
@ IN SOA master admin (
1 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS master
master A ${LOCALHOST}
$HOST A $HOST_IP
EOF
chgrp bind /etc/bind/$DOMAIN.zone
else
color "不支持此操作系统,退出!" 1
exit
fi



}

start_service () {
systemctl enable named
systemctl restart named
systemctl is-active named.service
if [ $? -eq 0 ] ;then
color "DNS 服务安装成功!" 0
else
color "DNS 服务安装失败!" 1
exit 1
fi
}

install_dns
config_dns
start_service

bash install_dns.sh

[root@ubuntu2204 ~]#dig gitlab.mooreyxia.org

; <<>> DiG 9.18.1-1ubuntu1.3-Ubuntu <<>> gitlab.mooreyxia.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 7747
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;gitlab.mooreyxia.org. IN A

;; AUTHORITY SECTION:
org. 3600 IN SOA a0.org.afilias-nst.info. hostmaster.donuts.email. 1675735758 7200 900 1209600 3600

;; Query time: 240 msec
;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)
;; WHEN: Tue Feb 07 10:17:59 CST 2023
;; MSG SIZE rcvd: 131
  • 解压gitlab包并且安装
#新版直接安装会报错,修改配置文件中的Gitlab地址后重新加载配置即可
[root@ubuntu2204 ~]#dpkg -i gitlab-ce_15.8.1-ce.0_amd64.deb
正在选中未选择的软件包 gitlab-ce。
(正在读取数据库 ... 系统当前共安装有 66490 个文件和目录。)
准备解压 gitlab-ce_15.8.1-ce.0_amd64.deb ...
正在解压 gitlab-ce (15.8.1-ce.0) ...
正在设置 gitlab-ce (15.8.1-ce.0) ...
[2023-02-07T10:28:23+08:00] WARN: Please install an English UTF-8 locale for Cinc Client to use, falling back to C locale and disabling UTF-8 support.
It looks like there was a problem with public attributes; run gitlab-ctl reconfigure manually to fix.
dpkg: 处理软件包 gitlab-ce (--install)时出错:
已安装 gitlab-ce 软件包 post-installation 脚本 子进程返回错误状态 1
在处理时有错误发生:
gitlab-ce

#修改配置文件后重新加载
[root@ubuntu2204 ~]#vim /etc/gitlab/gitlab.rb
[root@ubuntu2204 ~]#grep "^[a-Z]" /etc/gitlab/gitlab.rb
external_url 'http://gitlab.mooreyxia.com'

[root@ubuntu2204 ~]#gitlab-ctl reconfigure
[2023-02-07T11:00:54+08:00] WARN: Please install an English UTF-8 locale for Cinc Client to use, falling back to C locale and disabling UTF-8 support.
ffi-libarchive could not be loaded, libarchive is probably not installed on system, archive_file will not be available
[2023-02-07T11:00:56+08:00] INFO: Started Cinc Zero at chefzero://localhost:1 with repository at /opt/gitlab/embedded (One version per cookbook)
Cinc Client, version 17.10.0
Patents: https://www.chef.io/patents
Infra Phase starting
[2023-02-07T11:00:56+08:00] INFO: *** Cinc Client 17.10.0 ***
[2023-02-07T11:00:56+08:00] INFO: Platform: x86_64-linux
[2023-02-07T11:00:56+08:00] INFO: Cinc-client pid: 22907
[2023-02-07T11:00:58+08:00] INFO: Setting the run_list to ["recipe[gitlab]"] from CLI options
[2023-02-07T11:00:58+08:00] INFO: Run List is [recipe[gitlab]]
[2023-02-07T11:00:58+08:00] INFO: Run List expands to [gitlab]
....
Notes:
Default admin account has been configured with following details:
Username: root
Password: You didn't opt-in to print initial root password to STDOUT.
Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours. --> 这里有初始密码

NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

gitlab Reconfigured!


#验证运行状态
[root@ubuntu2204 ~]#gitlab-ctl status
[2023-02-07T11:06:15+08:00] WARN: Please install an English UTF-8 locale for Cinc Client to use, falling back to C locale and disabling UTF-8 support.
run: alertmanager: (pid 24374) 95s; run: log: (pid 24091) 144s
run: gitaly: (pid 24239) 104s; run: log: (pid 23549) 290s
run: gitlab-exporter: (pid 24350) 97s; run: log: (pid 24034) 160s
run: gitlab-kas: (pid 24327) 98s; run: log: (pid 23824) 266s
run: gitlab-workhorse: (pid 24336) 98s; run: log: (pid 23954) 180s
run: logrotate: (pid 23474) 304s; run: log: (pid 23506) 301s
run: nginx: (pid 23962) 175s; run: log: (pid 23974) 173s
run: node-exporter: (pid 24345) 98s; run: log: (pid 24011) 168s
run: postgres-exporter: (pid 24383) 94s; run: log: (pid 24108) 136s
run: postgresql: (pid 23682) 277s; run: log: (pid 23694) 274s
run: prometheus: (pid 24359) 97s; run: log: (pid 24071) 148s
run: puma: (pid 23890) 193s; run: log: (pid 23899) 191s
run: redis: (pid 23510) 299s; run: log: (pid 23519) 297s
run: redis-exporter: (pid 24352) 97s; run: log: (pid 24051) 156s
run: sidekiq: (pid 23908) 187s; run: log: (pid 23925) 184s

#user root
#pwd 在/etc/gitlab/initial_root_password

58-CICD持续集成工具-Git和GitLab

  • 汉化设置

58-CICD持续集成工具-Git和GitLab

  • 验证端口及状态
[root@ubuntu2204 ~]#lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 35974 root 7u IPv4 184247 0t0 TCP *:http (LISTEN)
nginx 35975 gitlab-www 7u IPv4 184247 0t0 TCP *:http (LISTEN)
nginx 35976 gitlab-www 7u IPv4 184247 0t0 TCP *:http (LISTEN)
  • Gitlab的常用命令
gitlab-rails #用于启动控制台进行特殊操作,如修改管理员密码、打开数据库控制台( gitlab-rails
dbconsole)等
gitlab-psql #数据库命令行
gitlab-rake #数据备份恢复等数据操作
#客户端命令行操作行
gitlab-ctl
gitlab-ctl reconfigure #修改过配置后需要执行重新配置
gitlab-ctl stop #停止gitlab
gitlab-ctl start #启动gitlab
gitlab-ctl restart #重启gitlab
gitlab-ctl status #查看组件运行状态
gitlab-ctl tail #查看所有日志
gitlab-ctl tail nginx #查看某个组件的日志
gitlab-ctl service-list #列出服务

GitLab 的数据备份和恢复

  • 备份相关配置文件
/etc/gitlab/gitlab.rb
/etc/gitlab/gitlab-secrets.json #双因子验证等使用此文件
  • 备份配置文件命令
gitlab-ctl backup-etc --backup-path <DIRECTORY>
#如果不指定--backup-path <DIRECTORY>,则默认备份至/etc/gitlab/config_backup/

案例:

[root@ubuntu2204 test-project]#gitlab-ctl backup-etc
[2023-02-07T15:18:13+08:00] WARN: Please install an English UTF-8 locale for Cinc Client to use, falling back to C locale and disabling UTF-8 support.
Could not find '/etc/gitlab/config_backup' directory. Creating.
Running configuration backup
Creating configuration backup archive: gitlab_config_1675754294_2023_02_07.tar
/etc/gitlab/
/etc/gitlab/gitlab.rb
/etc/gitlab/initial_root_password
/etc/gitlab/gitlab-secrets.json
/etc/gitlab/trusted-certs/
Configuration backup archive complete: /etc/gitlab/config_backup/gitlab_config_1675754294_2023_02_07.tar
Keeping all older configuration backups

[root@ubuntu2204 test-project]#ls /etc/gitlab/config_backup/
gitlab_config_1675754294_2023_02_07.tar

[root@ubuntu2204 test-project]#tar tvf /etc/gitlab/config_backup/gitlab_config_1675754294_2023_02_07.tar
tar: 从成员名中删除开头的“/”
drwxrwxr-x root/root 0 2023-02-07 15:18 /etc/gitlab/
-rw------- root/root 140237 2023-02-07 11:00 /etc/gitlab/gitlab.rb
-rw------- root/root 749 2023-02-07 11:01 /etc/gitlab/initial_root_password
-rw------- root/root 19408 2023-02-07 11:37 /etc/gitlab/gitlab-secrets.json
drwxr-xr-x root/root 0 2023-02-07 11:01 /etc/gitlab/trusted-certs/
  • 备份相关配置
#默认在/etc/gitlab/gitlab.rb文件中指定备份路径,如果目录空间不足,可以修改新的目录
#注意:修改完配置需要执行gitlab-ctl reconfigure
# gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"
#备份的文件权限,所有者和所属组为git
# gitlab_rails['backup_archive_permissions'] = 0644
#默认备份过期时长为7天,单位为s, 之后会被自动删除
# gitlab_rails['backup_keep_time'] = 604800
  • 执行恢复
#前提条件
备份和恢复使用的版本要一致
还原相关配置文件后,执行gitlab-ctl reconfigure
确保gitlab正在运行状态

#恢复前先停止两个服务
[root@ubuntu2204 ~]#gitlab-ctl stop puma
[root@ubuntu2204 ~]#gitlab-ctl stop sidekiq
#恢复时指定备份文件的时间部分,不需要指定文件的全名
[root@ubuntu2204 ~]#gitlab-backup restore BACKUP=备份文件名的时间部分
#示例
[root@ubuntu2204 ~]#gitlab-backup restore BACKUP=1583562898_2020_03_07_11.11.8
#Next, restore /etc/gitlab/gitlab-secrets.json if necessary, as previously
mentioned.Reconfigure, restart and check GitLab:
[root@ubuntu2204 ~]#gitlab-ctl reconfigure
[root@ubuntu2204 ~]#gitlab-ctl restart
#后续检查可选做
[root@ubuntu2204 ~]#gitlab-rake gitlab:check SANITIZE=true
#In GitLab 13.1 and later, check database values can be decrypted especially if
/etc/gitlab/gitlab-secrets.json was restored, or if a different server is the
target for the restore.
[root@ubuntu2204 ~]#gitlab-rake gitlab:doctor:secrets

我是moore,大家一起加油!