Linux/Synology/群晖gitlab:修订间差异
来自康健生活
创建页面,内容为“=== Docker gitlab === 在 GitHub 上选择 gitlab-cc 社区版 创建容器,配置参数:在高级选项上点击“卷”,用来映射路径 {| class="wikit…” |
|||
| (未显示同一用户的1个中间版本) | |||
| 第115行: | 第115行: | ||
cd "$backdir" | cd "$backdir" | ||
sshpass -p [passwd] scp "$latestFileName" root@[hostID]</syntaxhighlight> | sshpass -p [passwd] scp "$latestFileName" root@[hostID]</syntaxhighlight> | ||
== 使用方法 == | |||
{{shc|<syntaxhighlight lang="bash"> | |||
git clone ssh://git@718.kang.com:30011/root/basemvc.git</syntaxhighlight>|$}} | |||
== 备注 == | == 备注 == | ||
2020年3月29日 (日) 09:21的最新版本
Docker gitlab
在 GitHub 上选择 gitlab-cc 社区版
创建容器,配置参数:在高级选项上点击“卷”,用来映射路径
| 文件/文件夹 | 装载路径 |
|---|---|
| docker/gitlab-ce/data | /var/opt/gitlab |
| docker/gitlab-ce/config | /etc/gitlab |
| docker/gitlab-ce/log | /var/log/gitlab |
gitlab-rake gitlab:backup:create 命令只能在gitlab容器内使用,所以在手动备份时,需要进入容器。使用命令行进入容器
docker exec -it gitlab-gitlab-ce1 bash
修改gitlab.rb文件,更换备份路径:
gitlab_rails['backup_path']='/volume1/web/GITLABbackup' gitlab_rails['backup_keep_time']=604800
修改完成之后使用gitlab-ctl reconfigure命令重载配置文件。
gitlab-ctl restart
使用gitlab-ctl diff-config可查看修改的选项 重启服务。 可以在容器命令行手动备份
gitlab-rake gitlab:backup:create
备份结束会提示:
2019-12-28 07:17:03 +0000 -- Dumping database ... Dumping PostgreSQL database gitlabhq_production ... [DONE] 2019-12-28 07:17:05 +0000 -- done 2019-12-28 07:17:05 +0000 -- Dumping repositories ... * root/node-fetch (@hashed/6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b) ... [DONE] [SKIPPED] Wiki 2019-12-28 07:17:06 +0000 -- done 2019-12-28 07:17:06 +0000 -- Dumping uploads ... 2019-12-28 07:17:06 +0000 -- done 2019-12-28 07:17:06 +0000 -- Dumping builds ... 2019-12-28 07:17:06 +0000 -- done 2019-12-28 07:17:06 +0000 -- Dumping artifacts ... 2019-12-28 07:17:06 +0000 -- done 2019-12-28 07:17:06 +0000 -- Dumping pages ... 2019-12-28 07:17:06 +0000 -- done 2019-12-28 07:17:06 +0000 -- Dumping lfs objects ... 2019-12-28 07:17:06 +0000 -- done 2019-12-28 07:17:06 +0000 -- Dumping container registry images ... 2019-12-28 07:17:06 +0000 -- [DISABLED] Creating backup archive: 1577517426_2019_12_28_12.6.1_gitlab_backup.tar ... done Uploading backup archive to remote storage ... skipped Deleting tmp directories ... done done done done done done done done Deleting old backups ... skipping Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data and are not included in this backup. You will need these files to restore a backup. Please back them up manually. Backup task is done.
其中
Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data and are not included in this backup. You will need these files to restore a backup. Please back them up manually.
在gitlab.rb和gitlab-secrets.json文件中包含敏感数据,在备份中并没有包含这两个文件,需要手动保存一下,在恢复备份的时候会需要这两个文件。 备份完成后发现目标文件夹没有文件,在容器内发现新创建文件夹,并有备份文件,把文件夹映射出来
| 文件/文件夹 | 装载路径 |
|---|---|
| docker/gitlab-ce/data | /var/opt/gitlab |
| docker/gitlab-ce/config | /etc/gitlab |
| docker/gitlab-ce/log | /var/log/gitlab |
| DATABACKUP/Gitlab | /volume1/DATABACKUP/Gitlab |
crontab
设置备份:
crontab -e
# 每天02:00执行备份.注意刚才我们已经设置了同步备份文件到 Mac 上的共享文件夹.
# 这样我们就可以直接利用时间机器备份到群晖了.
0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
执行脚本
gitlab_backup.sh 文件
#! /bin/bash
case "$1" in
start)
docker exec gitlab-gitlab-ce1 gitlab-rake gitlab:backup:create
;;
esac
SSHpass
SSHpass 可以将文件同步到其他服务器。
#! /bin/bash
backdir='/srv/gitlab/data/backups'
latestFileName=`ls $backdir -t|head -n 1`
cd "$backdir"
sshpass -p [passwd] scp "$latestFileName" root@[hostID]
使用方法
git clone ssh://git@718.kang.com:30011/root/basemvc.git
备注
备份时还需要几个文件一起备份,还原会用到。
/etc/gitlab/gitlab.rb 配置文件须备份 /var/opt/gitlab/nginx/conf nginx配置文件 /etc/postfix/main.cfpostfix 邮件配置备份
容器参数
仅供参考
# docker run -d --hostname gitlab.example.com\
-p 443:443 -p 8181:80 -p 2222:22 \
--name gitlab \
--restart always \
-v docker/gitlab-ce/config:/etc/gitlab \
-v docker/gitlab-ce/log:/var/log/gitlab \
-v docker/gitlab-ce/data:/var/opt/gitlab \
-v /etc/localtime:/etc/localtime
gitlab/gitlab-ce:latest
No categories