Gitlab日常备份和恢复

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

时间: 2024-08-07 17:18:35

Gitlab日常备份和恢复的相关文章

GitLab 数据备份和恢复

GitLab 备份 /opt/gitlab/bin/gitlab-rake gitlab:backup:create //只是备份各项目的数据 完成后会在默认路径下多出来备份的tar包! /var/opt/gitlab/backups/XXXXXX.tar GitLab 恢复 # 停止相关数据连接服务 gitlab-ctl stop unicorn gitlab-ctl stop sidekiq # 从1393513186编号备份中恢复 gitlab-rake gitlab:backup:res

gitlab的备份、恢复

数据备份 : /etc/gitlab/gitlab.rb配置文件,查看一个和备份相关的配置项: gitlab_rails['backup_path'] = "/var/opt/gitlab/backups" #备份目录可以修改 默认备份出文件的路径,可以通过修改该配置,并执行gitlab-ctl restart重启服务生效 gitlab-rake gitlab:backup:create #备份 加到crontab中定时执行: 0 2 * * * /opt/gitlab/bin/git

GitLab数据备份:恢复

backbspvar是安装Reactor GitLab的另一种方法.码头工人: GitLab版本:gitlab / gitlab-ce. 12.9.2-ce.0 1.复制命令 创建1个gitlab备份 同时,您必须手动复制/etc/gitlab/gitlab-secrets.json,/etc/gitlab/gitlab.rb 2.恢复数据 创建的数据包位于gitlab服务器的初始目录/ var / opt / gitlab / backup中,例如: 1586312717_2020_04_08

Gitlab备份和恢复操作记录

前面已经介绍了Gitlab环境部署记录,这里简单说下Gitlab的备份和恢复操作记录: 1)Gitlab的备份目录路径设置 [[email protected] ~]# vim /etc/gitlab/gitlab.rb gitlab_rails['backup_path'] = "/data/gitlab/backups" [[email protected] ~]# mkdir -p /data/gitlab/backups [[email protected] ~]# chown

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

Gitlab 创建备份 使用Gitlab一键安装包安装Gitlab非常简单, 同样的备份恢复与迁移也非常简单. 使用一条命令即可创建完整的Gitlab备份: gitlab-rake gitlab:backup:create 使用以上命令会在/var/opt/gitlab/backups目录下创建一个名称类似为1393513186_gitlab_backup.tar的压缩包, 这个压缩包就是Gitlab整个的完整部分, 其中开头的1393513186是备份创建的日期. Gitlab 修改备份文件默

gitlab部署、配置更改、备份及恢复

1.gitlab部署 官网 gitlab.com Ubuntu14.04安装 1.Install and configure the necessary dependencies sudoapt-get install postfix 2. Download the Omnibus package and install everything wgethttps://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.9.4-omn

gitlab安装,使用,备份,恢复

gitlab安装,使用,备份,恢复 git是一个版本控制器在分布式版本控制系统里,客户端并不只提取最新版本的文件快照,而是把代码仓库完整地镜像下来. 这么一来,任何一处协同工作用的服务器发生故障,事后都可以用任何一个镜像出来的本地仓库恢复.因为每一次的提取操作,实际上都是一次对代码仓库的完整备份. 1.gitlab介绍 GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务,操作起来特别方便. 2.Gitlab安装与配置 2.1yum安装软件

Gitlab备份、恢复与迁移

Gitlab 创建备份 使用Gitlab一键安装包安装Gitlab非常简单, 同样的备份恢复与迁移也非常简单. 使用一条命令即可创建完整的Gitlab备份: gitlab-rake gitlab:backup:create 使用以上命令会在/var/opt/gitlab/backups目录下创建一个名称类似为1393513186_gitlab_backup.tar的压缩包, 这个压缩包就是Gitlab整个的完整部分, 其中开头的1393513186是备份创建的日期. Gitlab 修改备份文件默

gitlab备份、恢复、升级

1.备份 gitlab的备份很简单,只要使用命令: gitlab-rake gitlab:backup:create 即可将当前的数据库.代码全部备份到/var/opt/gitlab/backups 注意:这备份过程中,gitlab会将所有信息都拷贝到该文件夹下,然后压缩为tar文件,所以需要有一定的磁盘空间 2.恢复 使用命令 gitlab-rake gitlab:backup:restore BACKUP=xxxxxxx 即可恢复gitlab备份 注意:xxxxxxx为tar文件名除“_gi