Linux运维-陈雷雷


持续集成教程09_gitlab备份与恢复

admin 2019-12-24 178浏览 0条评论
首页/正文
分享到: / / / /

gitlab备份

#1. 创建添加配置文件
vim /etc/gitlab/gitlab.rb
文件尾添加:
gitlab_reils['backup_path'] = '/data/backup/gitlab'
gitlab_rails['backup_keep_time'] = 604800

#2. 创建 /data/backup 目录和权限配置
mkdir /data/backup/gitlab
chwon -R git.git /data/backup/git.lab

#3. 备份命令
/usr/bin/gitlab-rake gitlab:backup:create 

#4. 将备份命令添加到定时任务,每周或者每天进行备份
crontab -e
0 2 * * * /usr/bin/gitlab-rake gitlab:backup:create

手动备份gitlab

默认备份文件夹: /var/opt/gitlab/backups/
备份命令:  gitlab-rake gitlab:backuo:create

定时任务备份gitlab

crontab -l
0 2 * * * /usr/bin/gitlab-rake gitlab:backup:create 

gitlab数据恢复步骤

gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
gitlab-rake gitlab:backup:restore BACKUP=1577142190_2019_12_24_10.2.2_gitlab_backup.tar
gitlab-ctl restart

告知你相关风险,提示是否恢复:

选择yes即可恢复

这里继续提醒: 选择yes

恢复完毕后重启相关服务

[root@master git_test]# gitlab-ctl restart
ok: run: gitaly: (pid 115728) 0s
ok: run: gitlab-monitor: (pid 115740) 1s
ok: run: gitlab-workhorse: (pid 115748) 0s
ok: run: logrotate: (pid 115758) 0s
ok: run: nginx: (pid 115765) 1s
ok: run: node-exporter: (pid 115771) 0s
ok: run: postgres-exporter: (pid 115776) 1s
ok: run: postgresql: (pid 115820) 0s
ok: run: prometheus: (pid 115828) 1s
ok: run: redis: (pid 115837) 0s
ok: run: redis-exporter: (pid 115842) 0s
ok: run: sidekiq: (pid 115847) 1s
ok: run: unicorn: (pid 115849) 0s

检查状态:
[root@master git_test]# gitlab-ctl status
run: gitaly: (pid 115728) 48s; run: log: (pid 25672) 710356s
run: gitlab-monitor: (pid 115740) 48s; run: log: (pid 25775) 710349s
run: gitlab-workhorse: (pid 115748) 47s; run: log: (pid 25571) 710375s
run: logrotate: (pid 115758) 47s; run: log: (pid 25608) 710362s
run: nginx: (pid 115765) 47s; run: log: (pid 25590) 710368s
run: node-exporter: (pid 115771) 46s; run: log: (pid 25719) 710355s
run: postgres-exporter: (pid 115776) 46s; run: log: (pid 25829) 710341s
run: postgresql: (pid 115820) 45s; run: log: (pid 25350) 710419s
run: prometheus: (pid 115828) 45s; run: log: (pid 25810) 710342s
run: redis: (pid 115837) 45s; run: log: (pid 25278) 710426s
run: redis-exporter: (pid 115842) 45s; run: log: (pid 25789) 710349s
run: sidekiq: (pid 115847) 45s; run: log: (pid 25553) 710382s
run: unicorn: (pid 115849) 44s; run: log: (pid 25515) 710384s

到这里,所以备份之前删除的库表都会被恢复
最后修改:2019-12-24 07:21:31 © 著作权归作者所有
如果觉得我的文章对你有用,请随意赞赏
扫一扫支付

上一篇

发表评论

评论列表

还没有人评论哦~赶快抢占沙发吧~

博客信息

  • 文章数目 123
  • 标签数目 333
  • 运行天数
  • 最后活动

广告



文章目录