起因
由于服务器到期需要迁移git服务器到另外的一台上。
方案
使用官方迁移方案解决(一个很深的坑,网上有写方案是只是用低版本的,大家最好去官方获取最新的迁移方式。)
步骤(我用的是docker)
迁移文档在gitlab地址https://..**/help/raketasks/backup_restore.md
1. 备份
代码语言:javascript复制docker exec -t <container name> gitlab-backup create
输出样例
代码语言:javascript复制2020-10-15 07:23:04 0000 -- Dumping database ...
Dumping PostgreSQL database gitlabhq_production ... [DONE]
2020-10-15 07:23:08 0000 -- done
2020-10-15 07:23:08 0000 -- Dumping repositories ...
* yihao-server/yihao (@hashed/4b/22/4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a) ... [DONE]
[SKIPPED] Wiki
* yihao-server/yihao-consult (@hashed/ef/2d/ef2d127de37b942baad06145e54b0c619a1f22327b2ebbcfbec78f5564afe39d) ... [DONE]
[SKIPPED] Wiki
* yihao-server/yihao-health (@hashed/e7/f6/e7f6c011776e8db7cd330b54174fd76f7d0216b612387a5ffcfb81e6f0919683) ... [DONE]
[SKIPPED] Wiki
* yihao-server/yihao-iot (@hashed/79/02/7902699be42c8a8e46fbbb4501726517e86b22c56a189f7625a6da49081b2451) ... [DONE]
[SKIPPED] Wiki
* front-end/mp-health-service (@hashed/2c/62/2c624232cdd221771294dfbb310aca000a0df6ac8b66b696d90ef06fdefb64a3) ... [DONE]
[SKIPPED] Wiki
* front-end/web-health-doctor (@hashed/19/58/19581e27de7ced00ff1ce50b2047e7a567c76b1cbaebabe5ef03f7c3017bb5b7) ... [DONE]
[SKIPPED] Wiki
* front-end/mp-health-doctor (@hashed/4a/44/4a44dc15364204a80fe80e9039455cc1608281820fe2b24f1e5233ade6af1dd5) ... [DONE]
[SKIPPED] Wiki
* yihao-server/yihao-fadada (@hashed/4f/c8/4fc82b26aecb47d2868c4efbe3581732a3e7cbcc6c2efb32062c08170a05eeb8) ... [DONE]
[SKIPPED] Wiki
* front-end/mp-health-patient (@hashed/6b/51/6b51d431df5d7f141cbececcf79edf3dd861c3b4069f0b11661a3eefacbba918) ... [DONE]
[SKIPPED] Wiki
* front-end/mp-health-pharmacy (@hashed/3f/db/3fdba35f04dc8c462986c992bcf875546257113072a909c162f7e470e581e278) ... [DONE]
[SKIPPED] Wiki
* front-end/web-website (@hashed/85/27/8527a891e224136950ff32ca212b45bc93f69fbb801c3b1ebedac52775f99e61) ... [DONE]
[SKIPPED] Wiki
* yihao-server/yihao-system (@hashed/e6/29/e629fa6598d732768f7c726b4b621285f9c3b85303900aa912017db7617d8bdb) ... [DONE]
[SKIPPED] Wiki
* front-end/admin-platform (@hashed/b1/7e/b17ef6d19c7a5b1ee83b907c595526dcb1eb06db8227d650d5dda0a9f4ce8cd9) ... [DONE]
[SKIPPED] Wiki
* yihao-server/yihao-center (@hashed/45/23/4523540f1504cd17100c4835e85b7eefd49911580f8efff0599a8f283be6b9e3) ... [DONE]
[SKIPPED] Wiki
* yihao-server/yihao-filesystem (@hashed/4e/c9/4ec9599fc203d176a301536c2e091a19bc852759b255bd6818810a42c5fed14a) ... [DONE]
[SKIPPED] Wiki
* yihao-server/yihao-im (@hashed/94/00/9400f1b21cb527d7fa3d3eabba93557a18ebe7a2ca4e471cfe5e4c5b4ca7f767) ... [DONE]
[SKIPPED] Wiki
2020-10-15 07:23:12 0000 -- done
2020-10-15 07:23:12 0000 -- Dumping uploads ...
2020-10-15 07:23:12 0000 -- done
2020-10-15 07:23:12 0000 -- Dumping builds ...
2020-10-15 07:23:12 0000 -- done
2020-10-15 07:23:12 0000 -- Dumping artifacts ...
2020-10-15 07:23:12 0000 -- done
2020-10-15 07:23:12 0000 -- Dumping pages ...
2020-10-15 07:23:12 0000 -- done
2020-10-15 07:23:12 0000 -- Dumping lfs objects ...
2020-10-15 07:23:12 0000 -- done
2020-10-15 07:23:12 0000 -- Dumping container registry images ...
2020-10-15 07:23:12 0000 -- [DISABLED]
Creating backup archive: 1602746592_2020_10_15_13.2.6_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.
导出备份会存储在/home/gitlab/data/backups目录下 将文件拷贝到新的服务器上/home/gitlab/data/backups目录下
代码语言:javascript复制修改权限
chmod 755 1602316095_2020_10_10_13.2.6_gitlab_backup.tar
# Stop the processes that are connected to the database
docker exec -it <name of container> gitlab-ctl stop unicorn
docker exec -it <name of container> gitlab-ctl stop puma
docker exec -it <name of container> gitlab-ctl stop sidekiq
# Verify that the processes are all down before continuing
docker exec -it <name of container> gitlab-ctl status
# Run the restore
docker exec -it <name of container> gitlab-backup restore BACKUP=1602316095_2020_10_10_13.2.6
# Restart the GitLab container
docker restart <name of container>
# Check GitLab
docker exec -it <name of container> gitlab-rake gitlab:check SANITIZE=true
然后静静等待就可以了。我在10月10日的时候有用就的方式恢复是可以的。但是不知道为什么,15日正式操作的时候一直报异常,折腾了几个小时候后用官方的终于恢复成功了。