Docker版Gitlab迁移及升级教程

190 阅读1分钟

迁移

先在GitLab的关于中查看版本号,以确定GitLab版本

使用 docker exec -it gitlab bash进入GitLab容器

使用gitlab-rake gitlab:backup:create备份GitLab 完成后 会在/var/opt/gitlab/backups/文件夹下生成 时间戳_日期_版本号_gitlab_backup.tar文件

完成备份后退出容器 将文件复制出来留作备份 docker cp gitlab:/var/opt/gitlab/backups/*.tar ./

在新服务器中拉取相同版本号的GitLab

使用docker-compose.yml启动

version: '3'
services:
  gitlab:
    image: 'gitlab/gitlab-ce:11.1.4-ce.0'
    restart: always
    container_name: gitlab
    hostname: '192.168.3.171:8001'
    environment:
      TZ: 'Asia/Shanghai'
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://192.168.2.171:8001'
        gitlab_rails['gitlab_shell_ssh_port'] = 2222
        # unicorn['port'] = 8888
        nginx['listen_port'] = 80
    ports:
      - '8001:80'
      - '8443:443'
      - '2222:22'
    volumes:
      - /etc/localtime:/etc/localtime
      - ./config:/etc/gitlab
      - ./data:/var/opt/gitlab
      - ./logs:/var/log/gitlab

将备份文件复制到./data/backups目录

进入GitLab容器 使用gitlab-rake gitlab:backup:restore BACKUP=1600850168_2020_09_23_11.1.4恢复备份

恢复完大功告成

跨大版本升级

官方的升级路线指南 docs.gitlab.com/ee/policy/m…

升级路线

8.13.48.17.79.5.1010.8.711.3.411.11.812.0.1212.10.1413.0.1213版最新

预先拉取好需要的版本

docker pull gitlab/gitlab-ce:11.3.4-ce.0
docker pull gitlab/gitlab-ce:11.11.8-ce.0
docker pull gitlab/gitlab-ce:12.0.2-ce.0
docker pull gitlab/gitlab-ce:12.10.14-ce.0
docker pull gitlab/gitlab-ce:13.0.12-ce.0

使用docker-compose down停止容器

修改docker-compose.yml文件的gitlab版本号

启动docker-compose up -d