gitlab备份与恢复

╰+攻爆jí腚メ 2022-06-07 22:24 351阅读 0赞

1、gitlab备份与恢复

参考:https://docs.gitlab.com/ce/raketasks/backup_restore.html

  1. 创建系统备份
  2. sudo gitlab-rake gitlab:backup:create 备份文件存在/var/opt/gitlab/backups,可编辑/etc/gitlab/gitlab.rb修改 源码安装使用下面命令备份 sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production docker安装使用下面命令备份 docker exec -t <container namegitlab> gitlab-rake gitlab:backup:create 将备份上传到远程存储(暂无) 将备份文件存储到本地 gitlab_rails['backup_upload_connection'] = { :provider => 'Local', :local_root => '/mnt/backups' }

The directory inside the mounted folder to copy backups to
Use ‘.’ to store them in the root directory
gitlab_rails[‘backup_upload_remote_directory’] = ‘gitlab_backups’

备份档案权限

  1. # In /etc/gitlab/gitlab.rb, for omnibus packages
  2. gitlab_rails['backup_archive_permissions'] = 0644 # Makes the backup archives world-readable
  3. 备份配置文件
  4. 针对(Omnibus)备份:/etc/gitlab/gitlab.rb 、/etc/gitlab/gitlab-secrets.json
  5. 添加定时备份
  6. 每天凌晨两点备份
  7. 0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
  8. 保留备份30天,单位秒
  9. gitlab_rails['backup_keep_time'] = 2592000

2、Omnibus安装恢复

  1. 确认备份档案放到gitlab.rb定义的备份目录(默认/var/opt/gitlab/backups
  2. sudo cp 1504793137_2017_09_07_9.5.3_gitlab_backup.tar /var/opt/gitlab/backups/
  3. 停止连接数据库的进程
  4. sudo gitlab-ctl stop unicorn
  5. sudo gitlab-ctl stop sidekiq
  6. # Verify
  7. sudo gitlab-ctl status
  8. 恢复备份档案,指定时间戳
  9. sudo gitlab-rake gitlab:backup:restore BACKUP=1504793137_2017_09_07_9.5.3
  10. > Unpacking backup ... tar: 1504796591_2017_09_07_9.5.3_gitlab_backup.tar: Cannot open: Permission denied
  11. chown git:git 1504796591_2017_09_07_9.5.3_gitlab_backup.tar
  12. 重启并检查恢复情况
  13. sudo gitlab-ctl restart
  14. sudo gitlab-rake gitlab:check SANITIZE=true

发表评论

表情:
评论列表 (有 0 条评论,351人围观)

还没有评论,来说两句吧...

相关阅读

    相关 gitlab备份恢复

    因为公司代码仓库是用gitlab,最近一直在想数据丢失了如何处理,硬盘坏了如何处理,今天好好研究了下,发现gitlab备份还是挺简单的。 首先设定备份目录我设置的本地目录是/