备份1 sudo gitlab-rake gitlab:backup:create
GAUSS
修改默认备份目录: 修改文件/etc/gitlab/gitlab.rb
, 把gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"
改成自己要备份的目录就可以了
详见Backups | GitLab
修改之后运行sudo gitlab-ctl reconfigure
才能生效
如果备份到samba上,要把用户权限设置正确,
1 sudo mount -t cifs // 192.168 .2.2 /FF /m nt/samba -o username=ff,rw,uid=998 ,gid=0
AWK
(uid=998为git用户,是它的默认备份用户,别的用户会出现权限问题,https://gitlab.com/gitlab-org/omnibus-gitlab/issues/644 )
否则会出现
1 Error executing action `create` on resource 'directory[/mnt/samba/backup/gitlab]'
SUBUNIT
这样的错误
如果像上面这样保存到外部磁盘,记得要每次启动的要挂载。 写成脚本,放rc.local
修改要gitlab.rb 需要生效,需要运行
1 sudo gitlab-ctl reconfigure
EBNF
设置只保存最近7天的备份修改配置文件/etc/gitlab/gitlab.rb
,
1 gitlab_rails['backup_keep_time' ] = 604800
PROLOG
设置为定时任务1 2 sudo crontab -e0 2 * * * /opt/gi tlab/bin/gi tlab-rake gitlab:backup:create CRON=1
AWK
/opt/gitlab/bin/gitlab-rake /usr/bin/gitlab-rake gitlab:backup:create
备份的恢复
安装与备份文件的版本需要相同,如果不相同,需要降级,再还原备份,再升级,再做新备份。
gitlab降级参考
先删除当前版本
1 2 3 4 5 sudo gitlab-ctl stop sudo gitlab-ctl uninstall sudo yum remove gitlab-ce sudo gitlab-ctl cleanse sudo rm -rf /opt/gi tlab
AWK
到该网址选择指定版本
https://packages.gitlab.com/gitlab/gitlab-ce
1 2 3 4 curl -s https:// packages.gitlab.com/install/ repositories/gitlab/gi tlab-ce/script.deb.sh | sudo bash sudo apt-get install gitlab-ce=xx.xx.xx
AWK
恢复打开/etc/gitlab/gitlab.rb中backup路径的注释
1 gitlab_rails['backup_path' ] = "/var/opt/gitlab/backups"
PROLOG
拷贝配备文件到备份目录 再执行恢复
1 gitlab-rake gitlab:backup:restore BACKUP =备份文件编号
ROUTEROS
文件编号为_gitlab_backup.tar
前面的一串数字日期及版本的字符串
gitlab的升级1 2 3 sudo apt-get update && sudo apt-get install gitlab-ce gitlab-ctl reconfigure gitlab-ctl restart
PGSQL
后续如果换了机器,当备份恢复后,机器的指纹会发生变化。 可能会出现
1 2 3 4 5 6 WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed.
GAUSS
需要到用户目录下的.ssh
下的known_hosts,删除原来的key的指纹。 再次pull,会出现添加到已host的提示。
参考