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 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