安装和restore gitlab 12.0.2

下载和安装gitlab

  1. docker hub下载指定版本的itlab ce镜像

  2. 创建GITLAB_HOME的环境变量.

    sudo vim .bashrc
    export GITLAB_HOME=/srv/gitlab
    source .bashrc
    
    root@DESKTOP-1T50PP8:~# cat .bashrc| grep GITLAB
    export GITLAB_HOME=/srv/gitlab
    
    root@DESKTOP-1T50PP8:~# echo $GITLAB_HOME
    /srv/gitlab
    
  3. 照着gitlab官网准备一个docker-compose.yml

    version: '1.0'
    services:
      web:
    	image: 'gitlab/gitlab-ce:12.0.2-ce.0'
    	restart: always
       # hostname: 'gitlab.example.com'
       # environment:
       #   GITLAB_OMNIBUS_CONFIG: |
    	   # external_url 'https://gitlab.example.com'
    		# Add any other gitlab.rb configuration here, each on its own line
    	ports:
    	  - '80:80'
    	  - '443:443'
    	  - '22:22'
    	volumes:
    	  - '$GITLAB_HOME/config:/etc/gitlab'
    	  - '$GITLAB_HOME/logs:/var/log/gitlab'
    	  - '$GITLAB_HOME/data:/var/opt/gitlab'
    	shm_size: '256m'
    
  4. 在docker-compose.yml目录执行 docker compose up -d启动gitlab

restore gitlab

  1. 进入gitlab容器,查看备份文件需在的位置

    docker exec -it gitlab-web-1 /bin/sh
    # cat /etc/gitlab/gitlab.rb | grep backup_path
    # gitlab_rails['manage_backup_path'] = true
    # gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"
    # exit
    
  2. 把备份文件拷贝到 $GITLAB_HOME/data/backup后,执行 docker exec -it gitlab-web-1 gitlab-rake gitlab:backup:restore BACKUP=1619799951_2021_04_30_12.0.2,由于gitlab版本太低只能用这个命令。
    image

    Unpacking backup ... done
    Before restoring the database, we will remove all existing
    tables to avoid future upgrade problems. Be aware that if you have
    custom tables in the GitLab database these tables and all data will be
    removed.
    Do you want to continue (yes/no)? y
    Do you want to continue (yes/no)? yes
    Removing all tables. Press `Ctrl-C` within 5 seconds to abort
    2023-02-21 03:05:40 +0000 -- Cleaning the database ...
    2023-02-21 03:05:52 +0000 -- done
    2023-02-21 03:05:52 +0000 -- Restoring database ...
    Restoring PostgreSQL database gitlabhq_production ... SET
    SET
    SET
    SET
    SET
     set_config
     ....
    WARNING:  no privileges were granted for "public"
    GRANT
    [DONE]
    2023-02-21 03:09:00 +0000 -- done
    2023-02-21 03:09:00 +0000 -- Restoring repositories ...
     * Ops/work-log ... [DONE]
     * az/lg-szit ... [DONE]
     ...
    2023-02-21 03:17:27 +0000 -- done
    2023-02-21 03:17:27 +0000 -- Restoring uploads ...
    2023-02-21 03:17:27 +0000 -- done
    2023-02-21 03:17:27 +0000 -- Restoring builds ...
    2023-02-21 03:17:27 +0000 -- done
    2023-02-21 03:17:27 +0000 -- Restoring artifacts ...
    2023-02-21 03:17:28 +0000 -- done
    2023-02-21 03:17:28 +0000 -- Restoring pages ...
    2023-02-21 03:17:28 +0000 -- done
    2023-02-21 03:17:28 +0000 -- Restoring lfs objects ...
    2023-02-21 03:17:28 +0000 -- done
    This task will now rebuild the authorized_keys file.
    You will lose any data stored in the authorized_keys file.
    Do you want to continue (yes/no)? yes
    
    Deleting tmp directories ... done
    done
    done
    done
    done
    done
    done
    done
    Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data
    and are not included in this backup. You will need to restore these files manually.
    Restore task is done.
    
posted @ 2023-02-21 12:08  水天需  阅读(18)  评论(0编辑  收藏  举报