Gitlab 备份与恢复

备份

1、备份数据(手动备份)

复制代码
gitlab-rake gitlab:backup:create

2、备份数据(定时任务备份)

复制代码
[root@localhost ]# crontab -l
00 1 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create
说明:每天凌晨1点备份数据
数据默认保存路径:/var/opt/gitlab/backups/

还原

1、还原数据

1.1、复制数据到新Gitlab默认备份目录

复制代码
cp 备份文件_gitlab_backup.tar /var/opt/gitlab/backups/

1.2、设置备份文件权限

复制代码
chown git.git 备份文件_gitlab_backup.tar

1.3、使用如下命令恢复数据

1.3.1、停止 Gitlab

复制代码
gitlab-ctl stop unicorn
gitlab-ctl stop sideki

1.3.2、还原数据

复制代码
[root@localhost ]# gitlab-rake gitlab:backup:restore BACKUP=1690391227_2023_07_27_12.3.4-ee
Unpacking backup ... done
Before restoring the database, we will remove all existing
tables to avoid future upgrade problems. Be aware that if you have
custom tables in the GitLab database these tables and all data will be
removed.

Do you want to continue (yes/no)? yes   # 输入yes
Removing all tables. Press `Ctrl-C` within 5 seconds to abort
2023-07-27 16:07:36 +0800 -- Cleaning the database ... 
2023-07-27 16:07:46 +0800 -- done
2023-07-27 16:07:46 +0800 -- Restoring database ... 
Restoring PostgreSQL database gitlabhq_production ... SET

1.3.3、重启 Gitlab

复制代码
[root@localhost ]# gitlab-ctl restart
ok: run: alertmanager: (pid 19043) 0s
ok: run: gitaly: (pid 19067) 0s
ok: run: gitlab-exporter: (pid 19087) 1s
ok: run: gitlab-workhorse: (pid 19089) 0s
ok: run: grafana: (pid 19093) 0s
ok: run: logrotate: (pid 19120) 0s
ok: run: nginx: (pid 19133) 0s
ok: run: node-exporter: (pid 19289) 0s
ok: run: postgres-exporter: (pid 19300) 1s
ok: run: postgresql: (pid 19318) 0s
ok: run: prometheus: (pid 19320) 0s
ok: run: redis: (pid 19338) 0s
ok: run: redis-exporter: (pid 19343) 0s
ok: run: sidekiq: (pid 19358) 0s

1.4、打开web页面,查看数据是否正常

说明:输入账号密码,查看数据是否已恢复完成

相关推荐
YuSun_WK2 小时前
程序&进程&多任务&线程
linux·运维·服务器
安顾里8 小时前
Linux命令-iostat
linux·运维·服务器
100编程朱老师8 小时前
面试:什么叫Linux多路复用 ?
linux·运维·服务器
群联云防护小杜8 小时前
云服务器主动防御策略与自动化防护(下)
运维·服务器·分布式·安全·自动化·音视频
PPIO派欧云8 小时前
PPIO X OWL:一键开启任务自动化的高效革命
运维·人工智能·自动化·github·api·教程·ppio派欧云
struggle20259 小时前
LinuxAgent开源程序是一款智能运维助手,通过接入 DeepSeek API 实现对 Linux 终端的自然语言控制,帮助用户更高效地进行系统运维工作
linux·运维·服务器·人工智能·自动化·deepseek
不知名。。。。。。。。12 小时前
Linux—— 版本控制器Git
linux·运维·git
遇到我又惊又喜12 小时前
佛山大旺高新区3650 M5 ERP服务器维修案例
运维·服务器
安全系统学习13 小时前
网络安全之红队LLM的大模型自动化越狱
运维·人工智能·安全·web安全·机器学习·php
2302_7995257413 小时前
【Linux】第十二章 安装和更新软件包
linux·运维·服务器