gitlab 的备份与回复

news2024/10/27 7:21:23


一、gitlab备份

1.确定备份目录

        gitlab 默认的备份目录为/var/opt/gitlab/backups,可通过配置gitlab.rb配置文件进行修改,如:

[root@localhost ~]# vim /etc/gitlab/gitlab.rb
#若要修改备份文件的存储目录话,打开下面选项的注释并修改为自己的备份路径即可;#gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"

#gitlab备份所保留的时长,默认为七天
#Limit backup lifetime to 7 days - 604800 seconds
#gitlab_rails['backup_keep_time'] = 604800

    2.创建备份      

[root@localhost ~]# gitlab-backup create
#或者使用
[root@localhost ~]# gitlab-rake gitlab:backup:create
2023-03-15 23:01:47 -0400 -- Dumping database ... 
Dumping PostgreSQL database gitlabhq_production ... [DONE]
2023-03-15 23:01:51 -0400 -- done
2023-03-15 23:01:51 -0400 -- Dumping repositories ..
...
Creating backup archive: 1678935707_2023_03_15_14.9.5_gitlab_backup.tar ...                 
done
Uploading backup archive to remote storage  ... skipped
Deleting tmp directories ... done
done
done
done
done
done
done
done
done
done
Deleting old backups ... skipping
Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data 
and are not included in this backup. You will need these files to restore a 
backup.
Please back them up manually.
Backup task is done.

     3.查看备份的文件

        备份文件的格式为:EPOCH_YYYY_MM_DD_GitLab version_gitlab_backup.tar

 二、GitLab备份恢复


    1.gitlab恢复数据前提:

        GitLab的版本必须要与备份数据的版本一致!!!

     2.GitLab恢复步骤

        1:确保GitLab服务的启动可正常访问,并且版本必须和备份的数据版本一致;
        2:在恢复备份副本(备份文件)之前,首先确保本分副本位于/var/opt/gitlab/backups目录中;
        3:停止GitLab的数据库相关进程;

[root@localhost backups]# gitlab-ctl stop unicorn
[root@localhost backups]# gitlab-ctl stop sidekiq
ok: down: sidekiq: 0s, normally up
[root@localhost backups]# gitlab-ctl stop puma
ok: down: puma: 1s, normally up


        4:验证GitLab服务的状态;
            

[root@localhost backups]# gitlab-ctl status
run: alertmanager: (pid 215917) 83981s; run: log: (pid 15049) 202063s
run: gitaly: (pid 215926) 83980s; run: log: (pid 14326) 202224s
run: gitlab-exporter: (pid 215486) 84087s; run: log: (pid 14940) 202089s
run: gitlab-kas: (pid 215488) 84087s; run: log: (pid 14646) 202204s
run: gitlab-workhorse: (pid 215498) 84087s; run: log: (pid 14810) 202111s
run: grafana: (pid 215506) 84086s; run: log: (pid 15347) 201991s
run: logrotate: (pid 349753) 1282s; run: log: (pid 14230) 202236s
run: nginx: (pid 215522) 84086s; run: log: (pid 174881) 107021s
run: node-exporter: (pid 215532) 84085s; run: log: (pid 14899) 202095s
run: postgres-exporter: (pid 215538) 84086s; run: log: (pid 15185) 202053s
run: postgresql: (pid 215546) 84085s; run: log: (pid 14502) 202212s
run: prometheus: (pid 215555) 84085s; run: log: (pid 15003) 202076s
down: puma: 18s, normally up; run: log: (pid 140781) 127605s
run: redis: (pid 215576) 84084s; run: log: (pid 14276) 202231s
run: redis-exporter: (pid 215582) 84084s; run: log: (pid 14968) 202084s
down: sidekiq: 239s, normally up; run: log: (pid 14757) 202123s

        5:现在,使用备份副本的时间戳恢复备份;
           恢复命令如下         

 gitlab-backup restore BACKUP=1678977671_2023_03_16_14.9.5

           或

 gitlab-rake gitlab:backup:restore BACKUP=1678977671_2023_03_16_14.9.5

           BACKUP=备份归档文件时间戳 : 使用指定的备份归档文件进行恢复          

[root@localhost backups]# gitlab-backup restore BACKUP=1678977671_2023_03_16_14.9.5
Unpacking backup ... done
2023-03-16 10:58:44 -0400 -- Restoring database ... 
...
Do you want to continue (yes/no)? yes  #输入yes
...
Removing all tables. Press `Ctrl-C` within 5 seconds to abort
2023-03-16 15:00:50 UTC -- Cleaning the database ... 
2023-03-16 15:00:53 UTC -- done
Restoring PostgreSQL database gitlabhq_production ... ERROR:  must be owner of extension pg_trgm
ERROR:  must be owner of extension btree_gist
ERROR:  must be owner of extension btree_gist
ERROR:  must be owner of extension pg_trgm
...
2023-03-16 11:01:06 -0400 -- done
2023-03-16 11:01:06 -0400 -- Restoring uploads ... 
2023-03-16 11:01:06 -0400 -- done
2023-03-16 11:01:06 -0400 -- Restoring builds ... 
2023-03-16 11:01:06 -0400 -- done
2023-03-16 11:01:06 -0400 -- Restoring artifacts ... 
2023-03-16 11:01:06 -0400 -- done
2023-03-16 11:01:06 -0400 -- Restoring pages ... 
2023-03-16 11:01:06 -0400 -- done
2023-03-16 11:01:06 -0400 -- Restoring lfs objects ... 
2023-03-16 11:01:06 -0400 -- done
2023-03-16 11:01:06 -0400 -- Restoring terraform states ... 
2023-03-16 11:01:06 -0400 -- done
2023-03-16 11:01:06 -0400 -- Restoring packages ... 
2023-03-16 11:01:06 -0400 -- done
Do you want to continue (yes/no)? yes #输入yes即可

Deleting backups/tmp ... done
Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data 
and are not included in this backup. You will need to restore these files manually.
Restore task is done.

            在上面恢复的过程中可以看到有三处ERROR,这时不要慌张,急忙去打断恢复,亲测这三处ERROR不影响后续的恢复数据!只是权限的问题,下面会补充解决方案;

        注:可以在执行恢复命令时添加force=yes参数,这个参数的意思是在恢复过程中不再进行交互式询问(不用再输入yes了);
        命令如下:       

 gitlab-backup restore force=yes BACKUP=1678977671_2023_03_16_14.9.5

            或

gitlab-rake gitlab:backup:restore force=yes BACKUP=1678977671_2023_03_16_14.9.5

        6:重新加载重新启动GitLab组件:        

[root@localhost backups]# gitlab-ctl reconfigure
[root@localhost backups]# gitlab-ctl restart
ok: run: alertmanager: (pid 352840) 1s
ok: run: gitaly: (pid 352850) 0s
ok: run: gitlab-exporter: (pid 352864) 0s
ok: run: gitlab-kas: (pid 352866) 0s
ok: run: gitlab-workhorse: (pid 352872) 1s
ok: run: grafana: (pid 352884) 1s
ok: run: logrotate: (pid 352893) 0s
ok: run: nginx: (pid 352899) 0s
ok: run: node-exporter: (pid 352901) 0s
ok: run: postgres-exporter: (pid 352910) 0s
ok: run: postgresql: (pid 352921) 0s
ok: run: prometheus: (pid 352926) 0s
ok: run: puma: (pid 352928) 1s
ok: run: redis: (pid 352946) 1s
ok: run: redis-exporter: (pid 352952) 0s
ok: run: sidekiq: (pid 352958) 0

        7:通过清理数据库来检查GitLab组件是否都正常          

 [root@localhost backups]# gitlab-rake gitlab:check SANITIZE=true

        8:验证数据是否恢复
 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2224504.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

使用FRP搭建内网穿透服务(新版toml配置文件,搭配反向代理方便内网网站访问)【使用frp搭建内网穿透】

FRP(Fast Reverse Proxy)是一个高性能的反向代理应用程序,主要用于内网穿透。它允许用户将内部网络服务暴露到外部网络,适用于 NAT 或防火墙环境下的服务访问。 他是一个开源的 服务 如果大家不想用 花生壳 软件,可以尝…

遗传算法(Genetic Algorithm)理论详解

遗传算法(Genetic Algorithm,GA)是一种模拟自然界生物进化过程与机制的随机搜索与优化算法,被广泛应用于计算机科学、工程技术、经济学等众多领域。 1. 基本原理 1.1 生物遗传学类比 遗传算法的灵感来源于达尔文的进化论。在自然…

订购 Claude AI 的第二天 它独自完成 文字转语音 flask应用

图二里,删除几个无关的 chats 全程我做的工作:向 AI 提要求,copy / paste 代码,在venv验证运行,向 AI 反馈,总共用了3个 chats.(图中的只有一个 Chat, 删掉的另外两个: Python 库安…

背包问题(位运算优化、bitset)

3180. 执行操作可获得的最大总奖励| . - 力扣(LeetCode) 给你一个整数数组 rewardValues,长度为 n,代表奖励的值。 最初,你的总奖励 x 为 0,所有下标都是 未标记 的。你可以执行以下操作 任意次 &#xf…

数字IC后端实现 | Innovus各个阶段常用命令汇总

应各位读者要求,小编最近按照Innovus流程顺序整理出数字IC后端项目中常用的命令汇总。限于篇幅,这次只更新到powerplan阶段。有了这份Innovus常用命令汇总,学习数字IC后端从此不再迷路!如果大家觉得这个专题还不错,想继…

Linux 字符设备驱动 之 无法归类的《杂项设备驱动》

学习目标: 了解 杂项设备驱动 和普通字符设备的异同,及杂项设备驱动程序的写法 学习内容: 一、杂项设备驱动的特别之处 杂项设备(Miscellaneous Devices)是一种通用的设备类型,用于表示那些不适合其他设备…

LeetCode 热题 100之普通数组

1.最大子数组和 思路分析:这个问题可以通过动态规划来解决,我们可以使用Kadane’s Algorithm(卡登算法)来找到具有最大和的连续子数组。 Kadane’s Algorithm 的核心思想是利用一个变量存储当前的累加和 currentSum,并…

Prometheus自定义PostgreSQL监控指标

本文我们将介绍如何在Prometheus中创建自定义PostgreSQL指标。默认情况下由postgres_export运行的查询可能不能满足用户需求,但我们可以创建自定义查询,并要求postgres_exporter公开自定义查询的结果。postgres_exporter最近被移到了Prometheus Communit…

acwing排列数字

排列数字 给定一个整数 n,将数字 1∼n排成一排,将会有很多种排列方法。 现在,请你按照字典序将所有的排列方法输出。 输入格式 共一行,包含一个整数 n。 输出格式 按字典序输出所有排列方案,每个方案占一行。 数…

lvs知识点归纳

LVS(Linux Virtual Server)是 Linux 内核的一种负载均衡技术,主要用于实现高可用性和高性能的服务器集群。以下是一些关键知识点的归纳: 基本概念 虚拟服务器:将多台物理服务器(真实服务器)抽象…

论文速读 - Cleaner Pretraining Corpus Curation with Neural Web Scraping

这是论文 Cleaner Pretraining Corpus Curation with Neural Web Scraping 的速读笔记,同时简要分析这篇论文作者的实现代码. 论文的主要工作是提出了基于神经网络的高效crawler. 这里先澄清scraper和crawler的区别,一图胜千言. Abstract The web conta…

openpnp - bug - 散料飞达至少定义2个物料

文章目录 openpnp - bug - 散料飞达至少定义2个物料笔记END openpnp - bug - 散料飞达至少定义2个物料 笔记 散料飞达上定义的物料个数用完了,现在只需要一个料就可以。 用顶部相机去找编带上是否还有一个单独的料,找到了。 定义散料飞达的料为1个&…

springboot使用attachment方式下载文件损坏问题解决

文章目录 场景解决方式全部代码 场景 之前使用springboot下载文件一直正常&#xff0c;今天新对接一个接口出现文件破损&#xff0c;无法下载。 之前的代码: Overridepublic ResponseEntity<ByteArrayResource> resultExcel(ExcelResultDTO excelResultDTO) {log.info(…

CentOS7系统内核升级

1. 安装新内核 采用离线方式升级 去到下面网站中下载rpm安装包 https://mirrors.coreix.net/elrepo-archive-archive/kernel/el7/x86_64/RPMS/下载 wget https://mirrors.coreix.net/elrepo-archive-archive/kernel/el7/x86_64/RPMS/kernel-lt-5.4.278-1.el7.elrepo.x86_64…

探寻闲鱼libsgmain加解密算法(4) ——JNI入口跳转

关注我的人都知道我一直在学习阿里的加密和算法&#xff0c;除了研究逆向问题&#xff0c;还会把学来的阿里技术用在自己的应用上。 为什么&#xff1f;因为学习大厂的应用&#xff0c;是进步最快的方法。而大厂在安全和加密方面的技术&#xff0c;个人觉得阿里做的是最好的。 …

Maven项目管理工具-初始+环境配置

1. Maven的概念 1.1. 什么是Maven Maven是跨平台的项目管理工具。主要服务于基于Java平台的项目构建&#xff0c;依赖管理和项目信息管理。 理想的项目构建&#xff1a;高度自动化&#xff0c;跨平台&#xff0c;可重用的组件&#xff0c;标准化的流程 maven能够自动下载依…

Maven 不同环境灵活构建

需求: 使用 Maven根据不同的构建环境&#xff08;如开发、测试、生产&#xff09;来定义不同的配置&#xff0c;实现灵活的构建管理。 需要Demo项目的可以参考&#xff1a;我的demo项目 一、项目分层 一般的初创项目不会有特别多的配置文件&#xff0c;所以使用 spring.profile…

Android调用系统相机录像并设置参数

最近要做一个 Android上的录像功能&#xff0c;由于之前做拍照功能完全是用自定义方式&#xff0c;太麻烦。故这次决定直接调用系统相机来录像。 一、添加权限 首先&#xff0c;添加必要的权限 <!-- 授予该程序使用摄像头的权限 --><uses-permission android:name&q…

K8s中TSL证书如何续期

TSL是什么 K8s中的作用是什么&#xff1f; 在 Kubernetes&#xff08;K8s&#xff09;中&#xff0c;TSL 指的是 Transport Layer Security&#xff0c;也就是传输层安全协议。它是用来保护在网络上传输的数据的安全性和隐私性。 TSL 在 Kubernetes 中的作用包括&#xff1a;…

B+树(B树的改进)

目录 一、什么是B树&#xff1f; 二、B树的性质 1.B树被广泛作为数据库索引的索引结构 2.m个分支的结点有m个元素 3.每个元素对应子结点最大值 4.多级索引结构 5.叶子结点层包含所有元素 三、B树和B树的区别 四、B树的查找 1.顺序查找 2.随机查找 3.范围查找 一、什…