按照官方安装文档安装完成之后的/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日常备份和恢复的更多相关文章

  1. GitLab 数据备份和恢复

    GitLab 备份 /opt/gitlab/bin/gitlab-rake gitlab:backup:create //只是备份各项目的数据 完成后会在默认路径下多出来备份的tar包! /var/o ...

  2. Gitlab备份和恢复操作记录

    前面已经介绍了Gitlab环境部署记录,这里简单说下Gitlab的备份和恢复操作记录: 1)Gitlab的备份目录路径设置 [root@code-server ~]# vim /etc/gitlab/ ...

  3. 转载:Gitlab备份和恢复操作记录

    转载:Gitlab备份和恢复操作记录 包含了备份和数据恢复的操作记录,实验可行 前面已经介绍了Gitlab环境部署记录,这里简单说下Gitlab的备份和恢复操作记录: 1)Gitlab的备份目录路径设 ...

  4. Gitlab+Jenkins学习之路(四)之gitlab备份和恢复

    gitlab的备份和恢复 (1)创建备份目录,并授权 [root@linux-node1 ~]# mkdir /data/backups/gitlab -p [root@linux-node1 ~]# ...

  5. 使用Gitlab一键安装包后的日常备份恢复与迁移

    Gitlab 创建备份 使用Gitlab一键安装包安装Gitlab非常简单, 同样的备份恢复与迁移也非常简单. 使用一条命令即可创建完整的Gitlab备份: gitlab-rake gitlab:ba ...

  6. gitlab备份和恢复

    备份 生产环境下,备份是必需的.需要备份的文件有:配置文件和数据文件. 备份配置文件 配置文件包含密码等敏感信息,不要和数据文件放在一起. sh -c 'umask 0077; tar -cf $(d ...

  7. gitlab备份、恢复、升级

    1.备份 gitlab的备份很简单,只要使用命令: gitlab-rake gitlab:backup:create 即可将当前的数据库.代码全部备份到/var/opt/gitlab/backups ...

  8. 【linux】【gitlab】gitlab安装、备份、恢复、升级、内存消耗问题

    前言 GitLab:GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务.功能:Gitlab 是一个提供代码托管.提交审核和问题跟踪的代码管理平 ...

  9. gitlab 备份和恢复

    前言 gitlab这个代码托管工具真是强大,很多东西都是做好了直接用的. 这里就包括备份和恢复功能. 正文 备份 我们可以直接运行此命令,来进行备份. sudo gitlab-rake gitlab: ...

随机推荐

  1. ios中asihttprequest 下载缓存

    asi中下载缓存第一种方法 #import <UIKit/UIKit.h> #import "ASIHTTPRequest.h" #import "ASIDo ...

  2. 【LeetCode】3. Longest Substring Without Repeating Characters (2 solutions)

    Longest Substring Without Repeating Characters Given a string, find the length of the longest substr ...

  3. 【Redis】Redis的常规操作命令

    NoSQL是一种非关系型数据库,非关系型数据库库和传统的关系型数据库不同,非关系性体现在不需要依赖表进行数据存储.常见的非关系型数据库有Redis.MonoDB.HBase等,这些是基于key-val ...

  4. Windows ElasticSearch中文分词配置

    elasticsearch官方只提供smartcn这个中文分词插件,效果不是很好,好在国内有medcl大神(国内最早研究es的人之一)写的两个中文分词插件,一个是ik的,一个是mmseg的,下面分别介 ...

  5. ASP.NET Core Linux环境安装并运行项目

    原文地址:https://blog.csdn.net/u014368040/article/details/79192622 一 安装环境 1.  从微软官网下载 Linux版本的.NetCoreSd ...

  6. 高并发分布式系统中生成全局唯一(订单号)Id js返回上一页并刷新、返回上一页、自动刷新页面 父页面操作嵌套iframe子页面的HTML标签元素 .net判断System.Data.DataRow中是否包含某列 .Net使用system.Security.Cryptography.RNGCryptoServiceProvider类与System.Random类生成随机数

    高并发分布式系统中生成全局唯一(订单号)Id   1.GUID数据因毫无规律可言造成索引效率低下,影响了系统的性能,那么通过组合的方式,保留GUID的10个字节,用另6个字节表示GUID生成的时间(D ...

  7. Android水波纹特效的简单实现

    我的开源页面指示器框架 MagicIndicator,各位一定不要错过哦. 水波纹特效,想必大家或多或少见过,在我的印象中,大致有如下几种: 支付宝 "咻咻咻" 式 流量球 &qu ...

  8. mongodb及mongoclient在win7下的编译和使用

    1.导言 折腾mongodb几个小时最终有结果了.呃.如今就简单总结一下. 事实上我的需求非常easy,就是在C++代码中调用mongodb的库函数.也就是要得到mongoclient.lib.本来想 ...

  9. cassandra运行出现了Unable to gossip with any seeds,cqlsh链接不上,提示connection refused处理办法

    cassandra运行出现了Unable to gossip with any seeds,cqlsh链接不上,提示connection refused处理办法 问题描述 当启动了cassandra之 ...

  10. Markdown 使用教程

    前言 以前经常在 github 中看到 .md 格式的文件,一直没有注意,也不明白为什么文本文档的后缀不是 .txt ,后来无意中看到了 Markdown,看到了用这个东西写得一些web界面等特别的规 ...