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

提交成功:

到页面可以看到已经恢复的代码:

原文地址:https://www.cnblogs.com/zoujiaojiao/p/13062365.html