设为首页 收藏本站
查看: 836|回复: 0

[经验分享] Gitlab日常备份和恢复

[复制链接]

尚未签到

发表于 2018-1-10 16:35:38 | 显示全部楼层 |阅读模式
  按照官方安装文档安装完成之后的/home/git目录结构如下,这里我大致翻译官方的内容,部分加上自己的话,英语功力捉急,请见谅
  |-- home
  | |-- git
  | |-- .ssh
  | |-- gitlab
  | |-- gitlab-satellites
  | |-- gitlab-shell
  | |-- repositories
  * `/home/git/.ssh` - ssh设定的目录. gitlab-shell管理着其中的 `authorized_keys`.
  * `/home/git/gitlab` - GitLab核心部分
  * `/home/git/gitlab-satellites` - 可以视为临时目录,通过web ui的提交请求文件以及检出版本库都会存放在这个位置
  * `/home/git/gitlab-shell` - gitlab的核心插件组件. 包括ssh协议克隆和其他一些功能.
  * `/home/git/repositories` - 原始版本库的所有项目组织的名称空间,也就是所有仓库的存储位置,所以这个目录里的数据非常重要,注意备份 **这是项目的关键数据. Keep a backup**
  *Note: gitlab-satellites 和 repositories的路径都被定义在gitlab中的 `config/gitlab.yml` 和 gitlab-shell.* 中的`config.yml`
  创建为所有版本库的存档,就是备份啦. 存储路径在gitlab中的 `config/gitlab.yml`
  文件命名 `[TIMESTAMP]_gitlab_backup.tar`.
  ```
  bundle exec rake gitlab:backup:create RAILS_ENV=production
  ```
  类似如下:
  ```
  Dumping database tables:
  - Dumping table events... [DONE]
  - Dumping table issues... [DONE]
  - Dumping table keys... [DONE]
  - Dumping table merge_requests... [DONE]
  - Dumping table milestones... [DONE]
  - Dumping table namespaces... [DONE]
  - Dumping table notes... [DONE]
  - Dumping table projects... [DONE]
  - Dumping table protected_branches... [DONE]
  - Dumping table schema_migrations... [DONE]
  - Dumping table services... [DONE]
  - Dumping table snippets... [DONE]
  - Dumping table taggings... [DONE]
  - Dumping table tags... [DONE]
  - Dumping table users... [DONE]
  - Dumping table users_projects... [DONE]
  - Dumping table web_hooks... [DONE]
  - Dumping table wikis... [DONE]
  Dumping repositories:
  - Dumping repository abcd... [DONE]
  Creating backup archive: $TIMESTAMP_gitlab_backup.tar [DONE]
  Deleting tmp directories...[DONE]
  Deleting old backups... [SKIPPING]
  ```
  ### 利用备份文件恢复
  ```
  bundle exec rake gitlab:backup:restore RAILS_ENV=production
  ```
  选项:
  ```
  BACKUP=timestamp_of_backup (required if more than one backup exists)
  ```
  类似这样:
  ```
  Unpacking backup... [DONE]
  Restoring database tables:
  -- create_table("events", {:force=>true})
  -> 0.2231s
[...]

  - Loading fixture events...[DONE]
  - Loading fixture issues...[DONE]
  - Loading fixture keys...[SKIPPING]
  - Loading fixture merge_requests...[DONE]
  - Loading fixture milestones...[DONE]
  - Loading fixture namespaces...[DONE]
  - Loading fixture notes...[DONE]
  - Loading fixture projects...[DONE]
  - Loading fixture protected_branches...[SKIPPING]
  - Loading fixture schema_migrations...[DONE]
  - Loading fixture services...[SKIPPING]
  - Loading fixture snippets...[SKIPPING]
  - Loading fixture taggings...[SKIPPING]
  - Loading fixture tags...[SKIPPING]
  - Loading fixture users...[DONE]
  - Loading fixture users_projects...[DONE]
  - Loading fixture web_hooks...[SKIPPING]
  - Loading fixture wikis...[SKIPPING]
  Restoring repositories:
  - Restoring repository abcd... [DONE]
  Deleting tmp directories...[DONE]
  ```
  ### 配置计划任务
  ```
  cd /home/git/gitlab
  sudo -u git -H editor config/gitlab.yml # 开启多久自动备份的时间
  sudo -u git crontab -e # git用户的计划任务
  ```
  增加如下的条目:
  ```
  # 每天凌晨2点进行一次全备份
  0 2 * * * cd /home/git/gitlab && PATH=/usr/local/bin:/usr/bin:/bin bundle exec rake gitlab:backup:create RAILS_ENV=production
  ```

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-433619-1-1.html 上篇帖子: gitlab 的使用策略和简单介绍 下篇帖子: Gitlab可视化代码树插件
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表