gitlab的數據庫磁盤壞了已經沒有辦法恢復情況下如何恢復git上的代碼


gitlab的數據庫磁盤壞了,沒有備份。gitlab啟動后,什么項目都沒有了!!!

恢復過程:

  1. 將git的repositories備份
# cd /data/gitlab-gitlab/
# cp repositories /data/bak -rf
刪除repositories下面的項目
# cd /data/gitlab-gitlab/repositories/vonechain-tenant
# rm vonedao-tenant-message* -rf

在頁面新建剛剛刪除的項目,一模一樣的項目名稱

將備份的repositories下面對於項目的git下內容,同步到新項目下
# cd /data/bak/repositories/vonechain-tenant/vonedao-tenant-message.git
# rsync -avz config  description  HEAD  hooks  hooks.old.1586364917  info  objects  refs /data/gitlab-gitlab/repositories/vonechain-tenant/vonedao-tenant-message.git/

克隆剛剛建好的項目,並且新增加一個空txt,然后提交

# git clone ssh://git@gitlab.vonedao.com:30022/vonechain-tenant/vonedao-tenant-message.git
# cd vonedao-tenant-message/
# touch txt
# git add .
# git commit -m "txt"
# git push -u origin master

修改權限可以解決

# chmod 777 /data/gitlab-gitlab/repositories -R
# git push -u origin master

提交成功:

到頁面可以看到已經恢復的代碼:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM