{"id":108060,"date":"2024-10-28T06:36:15","date_gmt":"2024-10-27T22:36:15","guid":{"rendered":"https:\/\/gulass.cn\/?p=108060"},"modified":"2024-10-28T06:36:15","modified_gmt":"2024-10-27T22:36:15","slug":"gitlab-bak-update","status":"publish","type":"post","link":"https:\/\/gulass.cn\/gitlab-bak-update.html","title":{"rendered":"\u4ecb\u7ecdgitlab\u7684\u5907\u4efd\u6062\u590d\u4e0e\u5347\u7ea7"},"content":{"rendered":"
\u51e0\u4e4e\u4efb\u4f55\u5e94\u7528\u7cfb\u7edf\u90fd\u89c4\u907f\u4e0d\u5f00\u7684\u4e09\u4e2a\u95ee\u9898\uff1a\u5907\u4efd\u3001\u6062\u590d\u548c\u5347\u7ea7\u3002\u76f8\u5bf9\u800c\u8a00\u6765\u8bf4\uff0cgitlab-ce\u867d\u7136\u662f\u4e00\u4e2a\u5f00\u6e90\u514d\u8d39\u4ea7\u54c1\uff0c\u4f46\u5728\u8fd9\u4e09\u65b9\u9762\u505a\u7684\u8fd8\u662f\u6bd4\u8f83\u4eba\u6027\u5316\u7684\u3002\u4e0b\u9762\u9010\u4e2a\u4ecb\u7ecd\u3002<\/p>\n
\u5148\u6253\u5f00\/etc\/gitlab\/gitlab.rb\u914d\u7f6e\u6587\u4ef6\uff0c\u67e5\u770b\u4e00\u4e2a\u548c\u5907\u4efd\u76f8\u5173\u7684\u914d\u7f6e\u9879\uff1a<\/p>\n
gitlab_rails['backup_path'] = \"\/var\/opt\/gitlab\/backups\"\r\n<\/pre>\n\u8be5\u9879\u5b9a\u4e49\u4e86\u9ed8\u8ba4\u5907\u4efd\u51fa\u6587\u4ef6\u7684\u8def\u5f84\uff0c\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u8be5\u914d\u7f6e\uff0c\u5e76\u6267\u884cgitlab-ctl restart \u91cd\u542f\u670d\u52a1\u751f\u6548\u3002\u5907\u4efd\u6267\u884c\u4e00\u6761\u547d\u4ee4\u5c31\u641e\u5b9a\uff1a\/opt\/gitlab\/bin\/gitlab-rake gitlab:backup:create \uff0c\u4e5f\u53ef\u4ee5\u52a0\u5230crontab\u4e2d\u5b9a\u65f6\u6267\u884c\uff1a<\/p>\n
0 2 * * * \/opt\/gitlab\/bin\/gitlab-rake gitlab:backup:create\r\n<\/pre>\n\u53ef\u4ee5\u5230\/var\/opt\/gitlab\/backups\u627e\u5230\u5907\u4efd\u5305\uff0c\u89e3\u538b\u67e5\u770b\uff0c\u4f1a\u53d1\u73b0\u5907\u4efd\u7684\u8fd8\u662f\u6bd4\u8f83\u5168\u9762\u7684\uff0c\u6570\u636e\u5e93\u3001repositories\u3001build\u3001upload\u7b49\u5206\u7c7b\u8fd8\u662f\u6bd4\u8f83\u6e05\u6670\u7684\u3002<\/p>\n
\u6bcf\u5929\u6267\u884c\u5907\u4efd\uff0c\u80af\u5b9a\u6709\u76ee\u5f55\u88ab\u7206\u6ee1\u7684\u98ce\u9669\uff0c\u6211\u4eec\u53ef\u4ee5\u7acb\u9a6c\u60f3\u5230\u7684\u53ef\u4ee5\u901a\u8fc7find \u67e5\u627e\u4e00\u5b9a\u7684\u65f6\u95f4\u524d\u7684\u6587\u4ef6\uff0c\u914d\u5408rm\u8fdb\u884c\u5220\u9664\u3002\u4e0d\u8fc7\u4e0d\u9700\u8981\u8fd9\u4e48\u9ebb\u70e6\uff0cgitlab-ce\u81ea\u8eab\u96c6\u6210\u7684\u6709\u81ea\u52a8\u5220\u9664\u914d\u7f6e\u3002\u540c\u6837\u6253\u5f00\/etc\/gitlab\/gitlab.rb\u914d\u7f6e\u6587\u4ef6\uff0c\u53ef\u4ee5\u627e\u5230\u5982\u4e0b\u914d\u7f6e\uff1a<\/p>\n
gitlab_rails['backup_keep_time'] = 604800\r\n<\/pre>\n\u8fd9\u91cc\u662f\u8bbe\u7f6e\u5907\u4efd\u4fdd\u75597\u5929\uff087*3600*24=604800\uff09\uff0c\u79d2\u4e3a\u5355\u4f4d\uff0c\u5982\u679c\u60f3\u589e\u5927\u6216\u51cf\u5c0f\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728\u8be5\u5904\u914d\u7f6e\uff0c\u5e76\u901a\u8fc7gitlab-ctl restart \u91cd\u542f\u670d\u52a1\u751f\u6548\u3002<\/p>\n
\u4e8c\u3001\u6570\u636e\u6062\u590d<\/strong><\/div>\n\u6062\u590d\u524d\u9700\u8981\u5148\u505c\u6389\u6570\u636e\u8fde\u63a5\u670d\u52a1\uff1a<\/p>\n
gitlab-ctl stop unicorn\r\ngitlab-ctl stop sidekiq\r\n<\/pre>\n\u5982\u679c\u662f\u53f0\u7a7a\u4e3b\u673a\uff0c\u6ca1\u6709\u4efb\u4f55\u64cd\u4f5c\uff0c\u7406\u8bba\u4e0a\u4e0d\u505c\u8fd9\u4e24\u4e2a\u670d\u52a1\u4e5f\u53ef\u4ee5\u3002\u505c\u8fd9\u4e24\u4e2a\u670d\u52a1\u662f\u4e3a\u4e86\u4fdd\u8bc1\u6570\u636e\u4e00\u81f4\u6027\u3002\u5982\u679c\u4f60\u6ca1\u4fee\u6539\u8fc7\u9ed8\u8ba4\u5907\u4efd\u76ee\u5f55\u7684\u8bdd\uff0c\u5c06\u8001\u670d\u52a1\u5668\/var\/opt\/gitlab\/backups\u76ee\u5f55\u4e0b\u7684\u5907\u4efd\u6587\u4ef6\u62f7\u8d1d\u5230\u65b0\u670d\u52a1\u5668\u4e0a\u7684\/var\/opt\/gitlab\/backups\uff0c\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u8fdb\u884c\u6062\u590d\uff1a<\/p>\n
gitlab-rake gitlab:backup:restore BACKUP=\u5907\u4efd\u7f16\u53f7\r\n<\/pre>\n\u4e0a\u4e2a\u56fe\uff0c\u770b\u7684\u66f4\u76f4\u89c2\uff1a<\/p>\n
<\/a><\/p>\n
\u4e0a\u9762\u7684\u64cd\u4f5c\u4e2d\uff0c\u6709\u4e24\u4e2a\u6ce8\u610f\u70b9\uff1a<\/p>\n
1\u3001\u5230\u5e95\u90a3\u4e2a\u662f\u5907\u4efd\u7f16\u53f7\uff1f\u00a0 --- _gitlab\u4e4b\u524d\u7684\u90e8\u5206\u90fd\u662f\uff1b<\/p>\n
2\u3001600\u6743\u9650\u662f\u65e0\u6743\u6062\u590d\u7684\u3002 --- \u8fd9\u91cc\u6539\u6210\u4e86777\uff1b<\/p>\n
\u540e\u9762\u518d\u8f93\u5165\u4e24\u6b21yes\u5c31\u5b8c\u6210\u6062\u590d\u4e86\u3002<\/p>\n
\u6062\u590d\u5b8c\u6210\u540e\uff0c\u542f\u52a8\u521a\u521a\u7684\u4e24\u4e2a\u670d\u52a1\uff0c\u6216\u8005\u91cd\u542f\u6240\u6709\u670d\u52a1\uff0c\u518d\u6253\u5f00\u6d4f\u89c8\u5668\u8fdb\u884c\u8bbf\u95ee\uff0c\u53d1\u73b0\u6570\u636e\u548c\u4e4b\u524d\u7684\u4e00\u81f4\uff1a<\/p>\n
gitlab-ctl start unicorn\r\ngitlab-ctl start sidekiq\r\n\u6216\r\ngitlab-ctl restart\r\n<\/pre>\n\u8fd8\u6709\u4e00\u70b9\u8981\u522b\u6ce8\u6ce8\u610f\uff0c\u6839\u636e\u4ee5\u5f80\u7684\u7ecf\u9a8c\uff0c\u901a\u8fc7\u5907\u4efd\u6587\u4ef6\u6062\u590dgitlab\u5fc5\u987b\u4fdd\u8bc1\u4e24\u53f0\u4e3b\u673a\u7684gitlab\u7248\u672c\u4e00\u81f4\uff0c\u5426\u5219\u4f1a\u63d0\u793a\u7248\u672c\u4e0d\u5339\u914d<\/strong>\u3002<\/p>\n
\u4e09\u3001gitlab-ce\u5347\u7ea7<\/strong><\/div>\n\u5347\u7ea7\u6bd4\u8f83\u7b80\u5355\uff0c\u4f46\u6700\u597d\u4e0d\u8981\u8de8\u8d8a\u592a\u5927\u7684\u7248\u672c\uff0c\u7248\u672c\u5dee\u522b\u6bd4\u8f83\u5927\u65f6\uff0c\u6700\u597d\u9010\u4e2a\u7248\u672c\u5f80\u4e0a\u5347\u3002<\/p>\n
# \u5173\u95edgitlab\u670d\u52a1\r\ngitlab-ctl stop unicorn\r\ngitlab-ctl stop sidekiq\r\ngitlab-ctl stop nginx\r\n# \u5907\u4efdgitlab\r\ngitlab-rake gitlab:backup:create\r\n# \u5347\u7ea7rpm\u5305\r\nrpm -Uvh gitlab-ce-xxx.rpm\r\n# \u542f\u52a8\u5e76\u67e5\u770bgitlab\u7248\u672c\u4fe1\u606f\r\ngitlab-ctl reconfigure\r\ngitlab-ctl restart\r\nhead -1 \/opt\/gitlab\/version-manifest.txt\r\n<\/pre>\n\u53ef\u80fd\u9047\u5230\u7684\u62a5\u9519\uff0c<\/p>\n
Error executing action `run` on resource 'ruby_block[directory resource: \/var\/opt\/gitlab\/git-data\/repositories]'\r\n\u89e3\u51b3\u65b9\u6cd5:\r\nsudo chmod 2770 \/var\/opt\/gitlab\/git-data\/repositories\r\n<\/pre>\n\n\u539f\u6587\u6765\u81ea\uff1ahttp:\/\/www.361way.com\/gitlabce-backup-restore-update\/5713.html<\/a><\/p>\n