測試環境為 CentOS 8 x86_64 (虛擬機)
Gitlab 的備份與還原參考官方網站說明:
- Backup – https://docs.gitlab.com/ee/administration/backup_restore/backup_gitlab.html
- Restore – https://docs.gitlab.com/ee/administration/backup_restore/restore_gitlab.html
Gitlab 有提供指令就可以把所有資料(包含資料庫) 做備份與還原.
- Backup
以下兩個檔案因為包含一些密碼等資料所以需要手動備份起來./etc/gitlab/gitlab-secrets.json /etc/gitlab/gitlab.rb
以下指令可以把所有資料(包含資料庫)備份起來.
[root@localhost ~]# gitlab-backup create
備份檔案置於 /var/opt/gitlab/backups/
[root@localhost ~]# ll /var/opt/gitlab/backups/ total 253632 -rw------- 1 git git 450560 Nov 5 23:00 1699254029_2023_11_06_16.5.1_gitlab_backup.tar
這樣就備份完成.
- Restore
如果是全新的系統,需先安裝好 Gitlab – https://benjr.tw/105652需先將前面備份好了的 3個檔案複製到以下路徑.
/etc/gitlab/gitlab-secrets.json /etc/gitlab/gitlab.rb /var/opt/gitlab/backups/1699254029_2023_11_06_16.5.1_gitlab_backup.tar
停止服務.
[root@localhost ~]# gitlab-ctl stop puma [root@localhost ~]# gitlab-ctl stop sidekiq
檢視
[root@localhost ~]# gitlab-ctl status
還原資料,指定的名稱不包含 _gitlab_backup.tar
[root@localhost ~]# gitlab-backup restore BACKUP=1699254029_2023_11_06_16.5.1
重啟 Gitlab 並檢查.
[root@localhost ~]# gitlab-ctl restart [root@localhost ~]# gitlab-rake gitlab:check SANITIZE=true
還原完成.
沒有解決問題,試試搜尋本站其他內容