docker部署gitlab-ce以及gitlab的备份与恢复

1、使用docker-compose的方式

docker-compose.yml


version: '3.1'

services:
  gitlab-ce:
    image: registry.cn-hangzhou.aliyuncs.com/qfz9527/gitlab-ce-zh:11.1
    container_name: gitlab-ce
    ports:
      - 80:80
      - 443:443
      - 222:22
    volumes:
      - /root/gitlab-ce/home/data:/var/opt/gitlab
      - /root/gitlab-ce/home/logs:/var/log/gitlab
      - /root/gitlab-ce/home/config:/etc/gitlab
    restart: always
    cap_add:
      - ALL
    environment:
      GITLAB_OMNIBUS_CONFIG: |
#配置此参数,可以解决在创建项目时,gitlab以容器ID为域名的问题
        external_url 'http://192.168.31.109'
        gitlab_rails['gitlab_shell_ssh_port'] = 222

2、启动容器

docker-compose up -d -f ./docker-compose.yml

3、访问gitlab

http://192.168.31.109
会提示输入密码,和注册用户,按照要求注册即可

4、创建组、项目

docker部署gitlab-ce以及gitlab的备份与恢复
docker部署gitlab-ce以及gitlab的备份与恢复

5、备份docker

docker-ce:容器名称

docker exec -t gitlab-ce gitlab-rake gitlab:backup:create CRON=1

6、测试恢复

使用docker-compose stop -f ./docker-compose.yml停止gitlab-ce
将备份文件拷贝到其他地方删除如下文件夹data、logs、config目录下的所有文件

  - /root/gitlab-ce/home/data:/var/opt/gitlab
  - /root/gitlab-ce/home/logs:/var/log/gitlab
  - /root/gitlab-ce/home/config:/etc/gitlab

使用docker-compose -f ./docker-compose.yml up -d 启动docker

恢复操作

cp 1564063737_2019_07_25_11.1.4_gitlab_backup.tar /root/gitlab-ce/home/data/backups/
chmod 777 /root/gitlab-ce/home/data/backups/1564063737_2019_07_25_11.1.4_gitlab_backup.tar 
#恢复gitlab
docker exec -it gitlab-ce  gitlab-rake gitlab:backup:restore

gitlab_rails['manage_backup_path'] = true

备份路径

gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"

备份文件权限

gitlab_rails['backup_archive_permissions'] = 0644

备份保留时间 604800 = 7天

gitlab_rails['backup_keep_time'] = 604800

添加备份后的docker-compose.yml


version: '3.1'

services:
  gitlab-ce:
    image: registry.cn-hangzhou.aliyuncs.com/qfz9527/gitlab-ce-zh:11.1
    container_name: gitlab-ce
    ports:
      - 80:80
      - 443:443
      - 222:22
    volumes:
      - /root/gitlab-ce/home/data:/var/opt/gitlab
      - /root/gitlab-ce/home/logs:/var/log/gitlab
      - /root/gitlab-ce/home/config:/etc/gitlab
    restart: always
    cap_add:
      - ALL
    environment:
      GITLAB_OMNIBUS_CONFIG: |
#配置此参数,可以解决在创建项目时,gitlab以容器ID为域名的问题
        external_url 'http://192.168.31.109'
        gitlab_rails['gitlab_shell_ssh_port'] = 222

        gitlab_rails['manage_backup_path'] = true
# 备份路径
        gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"
# 备份文件权限
        gitlab_rails['backup_archive_permissions'] = 0644
# 备份保留时间 604800 = 7天
        gitlab_rails['backup_keep_time'] = 604800

7、配置文件

见附件

上一篇:Android中Handler Runnable与Thread的区别详解


下一篇:【Python】字符串的换行 和 引入其他py文件