Gitlab日常备份和恢复

摘要:
根据官方安装文档完成安装后的/home/git目录结构如下。在这里,我大致翻译了官方内容,并添加了我的一些文字。我的英语技能非常迫切。请原谅我|--home||--git||--。ssh | |--gitlab | |--gitlab类别| |--gitlab shell | |--存储库*`/home/git/。ssh`-由设置的目录。gitlab shell管理作者

按照官方安装文档安装完成之后的/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 
```

免责声明:文章转载自《Gitlab日常备份和恢复》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Jmail问题集锦IIS7.5 伪静态 脚本映射 配置方法下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

gitlab环境部署

一:配置主机名 [root@localhost ~]# hostname gitlab[root@localhost ~]# bash 二:安装依赖包 [root@gitlab ~]# yum -y install curl openssh-server openssh-clients postfix cronie policycoreutils-pyth...

二、Git

1.Git Git 是一个开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目。Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而是一个开放源码的版本控制软件。Git 与常用的版本控制工具 CVS, Subversion 等不同,它采用了分布式版本库的方式,不必有服务器端软件支持。 2.安装 [root@jenkins...

Jenkins 配置git

点击"新建任务"创建一个自用风格的项目 点击"源码管理",选择 git  系统管理 --> Global Tool Configuration<为访问git服务添加认证-----------------上图 Credential 中的 add> 配置deploy-key 如下配置,jenkins服务器上root用户生成密钥对...

element table显示滚动条

1 /* .tableX为要显示滚动条的类名 */ 2 /* 显示横向滚动条 */ 3 .tableX .el-table--scrollable-x .el-table__body-wrapper { 4 padding: 0 0 5px 0; 5 margin: 0 0 5px 0; 6 overflow-x: auto; 7...

Git过滤文件和文夹

第一步:添加".gitignore"文件 往项目根目录添加一个文件".gitignore"。这文件和".git"文件夹同级。 但是在windows下无法创建".gitignore"文件名,必须把文件名改成这样".gitignore.", 在文件名最后加一个英文句号就可以了。 第二步:设置过滤条件 bin/过滤所有bin文件夹 obj/过滤所有obj文件夹...

Jenkins代码自动部署相关文档

环境 centos 7.0+ Java JDK 1.8+ jenkins 2.220 maven 3.0+ git 1.8+ 注意事项 一. linux 安装 JDK (jdk-8u201-linux-x64.tar.gz) 1.下载jdk 2.在/usr 目录下,新建 /java 目录, 3.在/java 目录下,新建/jdk目录, 4.把jdk-...