gitlab 备份与恢复


Warning: Use of undefined constant gad_content_tag_filter_replace - assumed 'gad_content_tag_filter_replace' (this will throw an Error in a future version of PHP) in /usr/local/lighthouse/softwares/btpanel/wwwroot/www.mybacc.com/wp-content/plugins/web-ninja-google-analytics/webninja_ga.php on line 1813

gitlab 安装于黑群晖,是群晖自有版本。

第一次升级手动下载12.10.6,安装失败,提示redis下载失败显示已经安装了12.10.6,需要修复

卸载群晖gitlab,直接搜索安装docker版的gitlab ce 11.11.8
安装还算顺利,配置目录映射和端口,其他基本没动
然后开bash,进入终端,rake gitlab:backup:restore RAILS_ENV=production BACKUP=1625992100_2021_07_11_11.11.8一直报错,找不到rakefile
搜索了一下,才发现应该使用gitlab-rake恢复OK
gitlab-ctl reconfiguregitlab-ctl restart

  • 还是报500错误,无法登录

log中发现:{ “method”: “POST”, “path”: “/users/sign_in”, “format”: “html”, “controller”: “SessionsController”, “action”: “create”, “status”: 500, “error”: “ActiveRecord::NotNullViolation: PG::NotNullViolation: ERROR: null value in column \”id\” violates not-null constraint\nDETAIL: Failing row contains (null, 2, SecurityEvent, 2, User, —\n:with: standard\n:target_id: 2\n:target_type: User\n:target_det…, 2021-07-12 03:52:35.682732, 2021-07-12 03:52:35.682732).\n: INSERT INTO \”audit_events\” (\”author_id\”, \”type\”, \”entity_id\”, \”entity_type\”, \”details\”, \”created_at\”, \”updated_at\”) VALUES (2, ‘SecurityEvent’, 2, ‘User’, ‘—\n:with: standard\n:target_id: 2\n:target_type: User\n:target_details: mingyang wu\n’, ‘2021-07-12 03:52:35.682732’, ‘2021-07-12 03:52:35.682732’) RETURNING \”id\””, “duration”: 2954.65, “view”: 0.0, “db”: 158.04, “time”: “2021-07-12T03:52:32.741Z”, “params”: [  {   “key”: “utf8”,   “value”: “✓”  },  {   “key”: “authenticity_token”,   “value”: “[FILTERED]”  },  {   “key”: “user”,   “value”: {    “login”: “minyoad@gmail.com”,    “password”: “[FILTERED]”,    “remember_me”: “0”   }  } ], “remote_ip”: “59.60.10.194”, “user_id”: 2, “username”: “wmingyang”, “ua”: “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.64”, “queue_duration”: 13.01, “correlation_id”: “zBrUR6Nkap5”}
audit_events 的sequence 丢失解决办法:
gitlab-rails dbconsole
create SEQUENCE audit_events_id_seq OWNED BY audit_events.id;ALTER TABLE ONLY audit_events ALTER COLUMN id SET DEFAULT nextval(‘audit_events_id_seq’::regclass);

  • merge request 500

“error”: “ActiveRecord::NotNullViolation: PG::NotNullViolation: ERROR:  null value in column \”id\” violates not-null constraint\nDETAIL:  Failing row contains (null, 2, 79).\n: INSERT INTO \”merge_request_assignees\” (\”user_id\”, \”merge_request_id\”) VALUES (2, 79) RETURNING \”id\””,

create SEQUENCE merge_request_assignees_id_seq OWNED BY merge_request_assignees.id;ALTER TABLE ONLY merge_request_assignees ALTER COLUMN id SET DEFAULT nextval(‘merge_request_assignees_id_seq’::regclass);

SELECT setval('merge_request_assignees_id_seq', 62, true); 

“error”: “ActiveRecord::NotNullViolation: PG::NotNullViolation: ERROR:  null value in column \”id\” violates not-null constraint\nDETAIL:  Failing row contains (null, empty, 80, 2021-07-16 16:49:45.504076, 2021-07-16 16:49:45.504076, null, null, null, null, null, diff-, null, null).\n: INSERT INTO \”merge_request_diffs\” (\”state\”, \”merge_request_id\”, \”created_at\”, \”updated_at\”, \”external_diff\”) VALUES (’empty’, 80, ‘2021-07-16 16:49:45.504076’, ‘2021-07-16 16:49:45.504076’, ‘diff-‘) RETURNING \”id\””, create SEQUENCE merge_request_diffs_id_seq OWNED BY merge_request_diffs.id;ALTER TABLE ONLY merge_request_diffs ALTER COLUMN id SET DEFAULT nextval(‘merge_request_diffs_id_seq’::regclass);SELECT setval(‘merge_request_diffs_id_seq’, (select max(id) from merge_request_diffs), true); 

参考:gitlab迁移及迁移后500问题 – SegmentFault 思否

Update migration procedure (#2827) · Issues · GitLab.org / GitLab FOSS · GitLab

  • docker版

进入bash,bin目录下

rake gitlab:backup:create RAILS_ENV=production  
# 你会找到一个类似 /home/git/data/backups/1531046569_2018_07_14_10.6.4_gitlab_backup.tar 的文件 rake gitlab:backup:restore RAILS_ENV=production BACKUP=1625992100_2021_07_11_11.11.8

参考:
GitLab升级维护及升级后报500错误_周二也被占用-CSDN博客

  • 外部URL设置

external_url ‘https://gitlab.example.com:9443’
nginx[‘listen_port’] = 80   #如果不设置,默认与external_url的端口一致nginx[‘listen_https’] = false
参考:GitLab on Synology: set ‘external_url’ – mixable Blog

  • merge request 500错误

postgresql – Postgres manually alter sequence – Stack OverflowSELECT 'SELECT SETVAL(' || quote_literal(quote_ident(PGT.schemaname) || '.' || quote_ident(S.relname)) || ', COALESCE(MAX(' ||quote_ident(C.attname)|| '), 1) ) FROM ' || quote_ident(PGT.schemaname)|| '.'||quote_ident(T.relname)|| ';' FROM pg_class AS S, pg_depend AS D, pg_class AS T, pg_attribute AS C, pg_tables AS PGT WHERE S.relkind = 'S' AND S.oid = D.objid AND D.refobjid = T.oid AND D.refobjid = C.attrelid AND D.refobjsubid = C.attnum AND T.relname = PGT.tablename ORDER BY S.relname;

  • 升级到12.0.12

docker升级后,ci-cd配置的500 错误竟然消失了再次升级后,cicd 500 问题依旧参考:Project CI/CD-Settings broken – How to Use GitLab – GitLab ForumGitLab 迁移之后的事情 – 苏洋博客 (soulteary.com)
works fine without restarting or reconfiguring gitlabhq_production=> update Projects set runners_token_encrypted = null;全部设置为null即可。

问题原因

再次查看备份与恢复 的文档,发现 GitLab 在恢复备份过程中,对于下面的文件是不会进行备份和恢复操作的。 /etc/gitlab/gitlab-secrets.json /etc/gitlab/gitlab.rb /home/git/gitlab/config/secrets.yml

而被恢复的数据库中包含双因子加密验证的数据,其中的一个解密因子被保存在了 gitlab-secrets.json 中,如果你不进行手动合并操作,那么你的新 GitLab 应用中涉及到需要双因子解密的数据将都不可用,而 GitLab 在代码中也没有对这类情况作一些额外操作,就导致页面报 500 错误,显示不可访问。

  • 升级路径

 11.11.8 -> 12.0.12 -> 12.1.17 -> 12.10.14 -> 13.0.14 -> 13.1.11 -> latest 13.12.Z -> latest 14.0.Z -> 14.1.Z -> latest 14.Y.Z经过了几天的折腾,终于到了13.12了,真是不容易啊

发表评论

您的电子邮箱地址不会被公开。

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据