gitlab Docker容器创建命令以及从容器中备份gitlab仓库示例

Gitlab容器启动命令:

docker run -d     --name gitlab     --publish 80:80 --publish 2222:22     --hostname gitlab-server     --volume /etc/localtime:/etc/localtime:ro     --volume /volume-data/gitlab/config:/etc/gitlab     --volume /volume-data/gitlab/logs:/var/log/gitlab     --volume /volume-data/gitlab/data:/var/opt/gitlab     -e TZ="Asia/Shanghai"     -e GITLAB_OMNIBUS_CONFIG=" \
    external_url 'http://xxx.xxx.xxx.xxx:80/'; \
    gitlab_rails['gitlab_shell_ssh_port']=2222; \
    gitlab_rails['time_zone'] = 'Asia/Shanghai'; \
    gitlab_rails['gitlab_email_enabled']=false; \
    gitlab_rails['backup_keep_time']=604800; \
    user['git_user_email']='hello@qq.com'"   --restart always gitlab/gitlab-ce:10.7.3-ce.0

 

修改端口版命令:

#如果修改端口,命令格式示例如下
docker run -d --name gitlab --publish 8090:80 --publish 2222:22 --hostname gitlab-server --env' GITLAB_PORT=8090'   --volume /etc/localtime:/etc/localtime:ro --volume /volume-data/gitlab/config:/etc/gitlab     --volume /volume-data/gitlab/logs:/var/log/gitlab     --volume /volume-data/gitlab/data:/var/opt/gitlab     -e TZ="Asia/Shanghai"     -e GITLAB_OMNIBUS_CONFIG=" \
    gitlab_rails['gitlab_shell_ssh_port']=2222; \
    gitlab_rails['time_zone'] = 'Asia/Shanghai'; \
    gitlab_rails['gitlab_email_enabled']=false; \
    unicorn['worker_processes']=2 \
    gitlab_rails['backup_keep_time']=604800"   --restart always gitlab/gitlab-ce:10.7.3-ce.0

 

 

 

带邮箱配置版:

docker run -d     --name gitlab     --publish 80:80 --publish 2222:22     --hostname gitlab-server     --volume /etc/localtime:/etc/localtime:ro     --volume /volume-data/gitlab/config:/etc/gitlab     --volume /volume-data/gitlab/logs:/var/log/gitlab     --volume /volume-data/gitlab/data:/var/opt/gitlab     -e TZ="Asia/Shanghai"     -e GITLAB_OMNIBUS_CONFIG=" \
    external_url 'http://xxx.xxx.xxx.xxx:80/'; \
    gitlab_rails['gitlab_shell_ssh_port']=2222; \
    gitlab_rails['time_zone'] = 'Asia/Shanghai'; \
    gitlab_rails['gitlab_email_enabled']=true; \
    gitlab_rails['gitlab_email_from']='hello@qq.com'; \
    gitlab_rails['gitlab_email_display_name']='My GitLab'; \
    gitlab_rails['gitlab_email_reply_to']='noreply@example.com'; \
    gitlab_rails['gitlab_email_subject_suffix']='My GitLab'; \
    gitlab_rails['smtp_enable']=true; \
    gitlab_rails['smtp_address']='smtp.qq.com'; \
    gitlab_rails['smtp_port']=25; \
    gitlab_rails['smtp_user_name']='hello@qq.com'; \
    gitlab_rails['smtp_password']='hguqvkefriovciic'; \
    gitlab_rails['smtp_domain']='qq.com'; \
    gitlab_rails['smtp_authentication']='login'; \
    gitlab_rails['smtp_enable_starttls_auto']=true; \
    gitlab_rails['smtp_tls']=false; \
    gitlab_rails['backup_keep_time']=604800; \
    user['git_user_email']='hello@qq.com'"   --restart always gitlab/gitlab-ce:10.7.3-ce.0

 

在容器中备份代码:

进入容器,执行命令:

gitlab-rake gitlab:backup:create

完成后从宿主机的以下目录可以找到备份文件(前提是做了像上文一样的目录映射)

cd /volume-data/gitlab/data/backups

 

备份内容恢复:

第一步,将备份文件权限修改为777,不然可能恢复的时候会出现权限不够,不能解压的问题

chmod 777 1502357536_2017_08_10_9.4.3_gitlab_backup.tar 1

第二步,执行命令停止相关数据连接服务

# 停止相关数据连接服务
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq123

第三步,执行命令从备份文件中恢复Gitlab

gitlab-rake gitlab:backup:restore BACKUP=备份文件编号1
例如我们的备份文件的编号是1502357536_2017_08_10_9.4.3,因此执行下面的命令即可恢复gitlab
gitlab-rake gitlab:backup:restore BACKUP=1502357536_2017_08_10_9.4.3

sudo gitlab-ctl start

 

posted @ 2019-01-16 10:52  剑握在手  阅读(1115)  评论(0编辑  收藏  举报
返回顶部↑