For Intranet development, the team needs to go to Party A for development. We hope to transfer the whole GITLab to Party A

Here’s how it works

Create an experimental environment

  1. Configuration docker docker – compose
 sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo  http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum install -y docker-ce docker-ce-cli containerd.io
sudo curl -L "Https://get.daocloud.io/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s) - $(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
Copy the code
sudo mkdir -p /etc/docker 
sudo tee /etc/docker/daemon.json <<-'EOF' 
{ 
"registry-mirrors": ["https://7clusxie.mirror.aliyuncs.com"] 
} 
EOF 
sudo systemctl daemon-reload 
sudo systemctl restart docker
Copy the code
  1. Install gitlab

Note: Gitlab version is consistent, direct Docker Save saves Gitlab to destination Docker load

version: '3.5'
services:
  gitlab:
    image: 'gitlab/gitlab-ce:latest'
    container_name: gitlab
    restart: always
    hostname: '192.168.247.226'
    environment:
        GITLAB_OMNIBUS_CONFIG: | external_url 'http://192.168.247.226:8929' gitlab_rails [' gitlab_shell_ssh_port] = 2224 gitlab_rails = [' time_zone '] 'Asia/Shanghai'    ports:
        - '8929:8929'
        - '2224:22'
        - '5005:5005'
    volumes:
        - '$GITLAB_HOME/config:/etc/gitlab'
        - '$GITLAB_HOME/logs:/var/log/gitlab'
        - '$GITLAB_HOME/data:/var/opt/gitlab'

Copy the code

Docker-compose up -D starts Gitlab

The backup

Example Migrate data from 192.168.247.191 to 192.168.247.226

  1. in192.168.247.191The backup
  2. Enter gitLab for executiongitlab-rake gitlab:backup:createUsing the above command will be in/var/opt/gitlab/backupsOr $GITLAB_HOME/data/backups to create a directory with a name similar to1633136858 _2021_10_02_14. 3.1 _gitlab_backup. TarThe package is the complete part of Gitlab, which begins1633136858 _2021_10_02_14. 3.1Is the identifier of recovery

restore

Enter the GitLab container,

  1. cd /var/opt/gitlab/backups
  2. gitlab-ctl stop unicorn
  3. gitlab-ctl stop sidekiq
  4. Chmod 777 1633136858 _2021_10_02_14. 3.1 _gitlab_backup. Tar
  5. Gitlab - rake gitlab: backup, restore backup = 1633136858 _2021_10_02_14. 3.1
  6. gitlab-ctl start

The effect after migration

reference

  • Cloud.tencent.com/developer/a…
  • Docs.gitlab.com/ee/raketask…