备份Gitlab
虽然不停止gitlab链接也能够正常备份,但最好关闭gitlab(主要保持postgresql、redis运行状态)之后再进行备份,以防备份迁移期间有同事或其他人提交了代码;
查看版本
1 | [root@localhost /]# head -1 /opt/gitlab/version-manifest.txt |
停止gitlab部分进程
1 | gitlab-ctl stop unicorn |
备份
1 | [root@localhost wwwroot]# gitlab-rake gitlab:backup:create |
打包配置文件
1 | [root@localhost /]# zip -r gitlab_config.zip /etc/gitlab |
配置新服务器
安装Gitlab
安装与旧服务器同一版本的Gitlab,具体参考 GitLab安装
将备份与配置文件复制到新服务器上
解压之前备份的配置文件压缩包,将gitlab.rb还原到
/etc/gitlab/gitlab.rb
后,运行配置命令
1 gitlab-ctl reconfigure
将tar备份文件复制到新服务器备份目录/var/opt/gitlab/backups/
1 | mv 1519617101_2018_02_26_gitlab_backup.tar /var/opt/gitlab/backups/1519617101_2018_02_26_gitlab_backup.tar |
如果提示tar文件权限不足,可以设置为777
开始还原
1 | gitlab-rake gitlab:backup:restore BACKUP=1519617101_2018_02_26 |
注意:‘BACKUP=’后面的标签内容,即为
1519617101_2018_02_26_gitlab_backup.tar
文件名的前半部分时间戳名称,根据备份文件名称自行定义,并且还原会清空原有的Gitlab数据库、仓库代码、以及授权key,过程会有交互提示需要输入yes/no。
1 | [root@localhost /]# gitlab-rake gitlab:backup:restore BACKUP=1519617101_2018_02_26 |
运行Gitlab
1 | [root@localhost /]# gitlab-ctl start |
如果使用了非绑定的Nginx,还需要配置vhost等
其他问题
Gitlab迁移之后鉴权失败
提示1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: POSSIBLE DNS SPOOFING DETECTED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The ECDSA host key for gitlab.test.com has changed,
and the key for the corresponding IP address 192.168.3.100
is unknown. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:1wbCn2WwirSciFlc/1EVuN669qselyrBa+bqiNqjvRY.
Please contact your system administrator.
Add correct host key in /Users/Admin/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/Admin/.ssh/known_hosts:19
ECDSA host key for gitlab.test.com has changed and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: POSSIBLE DNS SPOOFING DETECTED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The ECDSA host key for gitlab.test.com has changed,
and the key for the corresponding IP address 192.168.3.100
is unknown. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:1wbCn2WwirSciFlc/1EVuN669qselyrBa+bqiNqjvRY.
Please contact your system administrator.
Add correct host key in /Users/Admin/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/Admin/.ssh/known_hosts:19
ECDSA host key for gitlab.test.com has changed and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: POSSIBLE DNS SPOOFING DETECTED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The ECDSA host key for gitlab.test.com has changed,
and the key for the corresponding IP address 192.168.3.100
is unknown. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:1wbCn2WwirSciFlc/1EVuN669qselyrBa+bqiNqjvRY.
Please contact your system administrator.
Add correct host key in /Users/Admin/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/Admin/.ssh/known_hosts:19
ECDSA host key for gitlab.test.com has changed and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
因为
/Users/Admin/.ssh/known_hosts
文件中绑定了gitlab.test.com域名ip与ECDSA key,移除gitlab.test.com
对应的key之后,再次请求git操作即可
可以使用命令删除:1
ssh-keygen -R 域名或IP
或直接编辑文件,手动删除1
vim /Users/Admin/.ssh/known_hosts