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页面,查看数据是否正常
在这里插入图片描述
说明:输入账号密码,查看数据是否已恢复完成

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

运维那些事~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值