注意新建备份目录是:/usr/local/src/repositories 属主和属组:

# ll -d repositories/
drwx------ git root Feb : repositories/

修改配置文件:

vim /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
 ## Backup settings
backup:
#path: "/var/opt/gitlab/backups" # Relative paths are relative to Rails.root (default: tmp/backups/)
path: "/usr/local/src/repositories" # Relative paths are relative to Rails.root (default: tmp/backups/)

有些linux系统是需要改此文件:/etc/gitlab/gitlab.rb

重启# gitlab-ctl restart

备份git:

# gitlab-rake gitlab:backup:create

恢复备份:

# gitlab-ctl stop unicorn
# gitlab-ctl stop sidekiq
# ls /usr/local/src/repositories/
1484140459_gitlab_backup.tar
# gitlab-rake gitlab:backup:restore BACKUP=
Unpacking backup ...
#如果数据迁移的话一定要保持gitlab的版本是一至,不然会报错!!!
# gitlab-ctl start

亲测:

# grep 'backup' -C  /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml

  ## Backup settings
backup:
path: "/var/opt/gitlab/backups" # Relative paths are relative to Rails.root (default: tmp/backups/)
keep_time: # default: (forever) (in seconds)
#可以看到备份后的数据路径为:/var/opt/gitlab/backups
[root@GitLab backups]# pwd
/var/opt/gitlab/backups
[root@GitLab backups]# ls
[root@GitLab backups]# gitlab-rake gitlab:backup:create
Dumping database ...
Dumping PostgreSQL database gitlabhq_production ... [DONE]
done
Dumping repositories ...
* root/document ... [DONE]
* root/document.wiki ... [SKIPPED]
* ok/hx-it-doc ... [DONE]
* ok/hx-it-doc.wiki ... [SKIPPED]
done
Dumping uploads ...
done
Creating backup archive: 1486695836_gitlab_backup.tar ... done
Deleting tmp directories ... done
Deleting old backups ... skipping
[root@GitLab backups]# ls
1486695836_gitlab_backup.tar
数据还原:
把数据1486695836_gitlab_backup.tar 放到/var/opt/gitlab/backups中
[root@GitLab src]# gitlab-ctl stop unicorn
ok: down: unicorn: 1s, normally up
[root@GitLab src]# gitlab-ctl stop sidekiq
ok: down: sidekiq: 0s, normally up
[root@GitLab backups]# pwd
/var/opt/gitlab/backups
[root@GitLab backups]# ls
1486695836_gitlab_backup.tar#注意这个文件的名子是在备份的时修生成的不能改变!!!!
[root@GitLab backups]# gitlab-rake gitlab:backup:restore BACKUP= #数据版号1486695836_gitlab_backup.tar
下现在为止git数据恢复完成!!

最新文章

  1. CSS HTML元素布局及Display属性
  2. C# 读取app.config配置文件节点键值,提示"配置系统未能初始化" 错误的解决方案
  3. hive操作语句使用详解
  4. 自定义View等待旋转
  5. 【转】YUV值对应的颜色
  6. Hibernate防止SQL注入
  7. UiAutomator源码分析之获取控件信息
  8. Quartus14.1中Qsys无法更新custom component的问题
  9. FormData+Ajax 实现多文件上传 学习使用FormData对象
  10. JavaScript的基本规范
  11. Spring LocalVariableTableParameterNameDiscoverer获取方法的参数名
  12. C语言整理——文件系统和文件访问
  13. 使用Win PE修改其他硬盘中的系统注册表
  14. 2017/2/13:springMVC拦截器的使用
  15. angularjs -- 页面模板清除
  16. TOMCAT Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
  17. php之快速入门学习-6(字符串变量)
  18. katalon系列十四:执行Windows命令&获取项目路径
  19. 团队Alpha冲刺(五)
  20. poj2362 Square(DFS)

热门文章

  1. uni - 介绍
  2. iOS——Quartz2D
  3. SQL入门教程
  4. java面试第十七天
  5. reset.css 和 flexible.js
  6. nexus 批量导入本地库
  7. Ubuntu解压缩zip,tar,tar.gz,tar.bz2
  8. OpenERP7.0安装后提示“not supported" ,如何去掉此提示
  9. oracle 多字段去重查询
  10. ORACLE-SQL(二)