【git学习】在CenterOS系统上恢复GitLab时出现错误:tar: 由于前次错误,将以上次的错误状态退出 unpacking backup failed - Go语言中文社区

【git学习】在CenterOS系统上恢复GitLab时出现错误:tar: 由于前次错误,将以上次的错误状态退出 unpacking backup failed


一、问题描述

今天在测试加密GitLab备份文件之后,进行解密,然后再恢复GitLab的时候,恢复失败,报了如下的错误:

tar: db:无法 mkdir: 权限不够
tar: db:无法 mkdir: 权限不够
tar: db/database.sql.gz:无法 open: 没有那个文件或目录
tar: uploads.tar.gz:无法 open: 权限不够
tar: builds.tar.gz:无法 open: 权限不够
tar: artifacts.tar.gz:无法 open: 权限不够
tar: pages.tar.gz:无法 open: 权限不够
tar: lfs.tar.gz:无法 open: 权限不够
tar: backup_information.yml:无法 open: 权限不够
tar: 由于前次错误,将以上次的错误状态退出
unpacking backup failed

在这里插入图片描述

详细错误如下:

tar: repositories:无法 mkdir: 权限不够
tar: repositories/caokuishun:无法 mkdir: 没有那个文件或目录
tar: repositories:无法 mkdir: 权限不够
tar: repositories/caokuishun/EKOCelluarViewMod.bundle:无法 open: 没有那个文件或目录
tar: repositories:无法 mkdir: 权限不够
tar: repositories/caokuishun/SDKTest.bundle:无法 open: 没有那个文件或目录
tar: repositories:无法 mkdir: 权限不够
tar: repositories/ReactNative:无法 mkdir: 没有那个文件或目录
tar: repositories:无法 mkdir: 权限不够
tar: repositories/ReactNative/Binding.bundle:无法 open: 没有那个文件或目录
tar: db:无法 mkdir: 权限不够
tar: db:无法 mkdir: 权限不够
tar: db/database.sql.gz:无法 open: 没有那个文件或目录
tar: uploads.tar.gz:无法 open: 权限不够
tar: builds.tar.gz:无法 open: 权限不够
tar: artifacts.tar.gz:无法 open: 权限不够
tar: pages.tar.gz:无法 open: 权限不够
tar: lfs.tar.gz:无法 open: 权限不够
tar: backup_information.yml:无法 open: 权限不够
tar: 由于前次错误,将以上次的错误状态退出
unpacking backup failed
[root@localhost backups]# cd ../
[root@localhost gitlab]# ll
总用量 16
drwxr-xr-x. 2 root              root         58 10月 23 16:25 backups
-rw-------. 1 root              root         38 10月 20 18:07 bootstrapped
drwx------. 2 git               root         44 10月 23 16:00 gitaly
drwx------. 3 git               root         25 10月 23 16:47 git-data
drwxr-xr-x. 3 git               root         19 10月 20 17:18 gitlab-ci
drwxr-xr-x. 2 git               root         31 10月 20 18:08 gitlab-monitor
drwxr-xr-x. 9 git               root       4096 10月 20 18:07 gitlab-rails
drwx------. 2 git               root         23 10月 20 18:06 gitlab-shell
drwxr-x---. 2 git               gitlab-www   51 10月 23 16:00 gitlab-workhorse
drwx------. 3 root              root         68 10月 23 16:10 logrotate
drwxr-x---. 9 root              gitlab-www 4096 10月 23 16:00 nginx
drwxr-xr-x. 3 root              root         31 10月 20 18:07 node-exporter
drwx------. 2 gitlab-psql       root         25 10月 20 18:08 postgres-exporter
drwxr-xr-x. 3 gitlab-psql       root         77 10月 23 16:00 postgresql
drwxr-x---. 3 gitlab-prometheus root         38 10月 20 18:07 prometheus
drwxr-x---. 2 gitlab-redis      git          57 10月 23 16:47 redis
-rw-r--r--. 1 root              root         40 10月 20 17:18 trusted-certs-directory-hash

二、解决问题

2.1 猜测是可能磁盘空间不足,使用df -h 查看磁盘空间

[root@localhost ~]# cd /var/opt/gitlab/
[root@localhost gitlab]# ll
总用量 16
drwx------. 3 git               root         77 10月 23 17:03 backups
-rw-------. 1 root              root         38 10月 20 18:07 bootstrapped
drwx------. 2 git               root         44 10月 23 16:00 gitaly
drwx------. 3 git               root         25 10月 23 16:47 git-data
drwxr-xr-x. 3 git               root         19 10月 20 17:18 gitlab-ci
drwxr-xr-x. 2 git               root         31 10月 20 18:08 gitlab-monitor
drwxr-xr-x. 9 git               root       4096 10月 20 18:07 gitlab-rails
drwx------. 2 git               root         23 10月 20 18:06 gitlab-shell
drwxr-x---. 2 git               gitlab-www   51 10月 23 16:00 gitlab-workhorse
drwx------. 3 root              root         68 10月 23 17:10 logrotate
drwxr-x---. 9 root              gitlab-www 4096 10月 23 16:00 nginx
drwxr-xr-x. 3 root              root         31 10月 20 18:07 node-exporter
drwx------. 2 gitlab-psql       root         25 10月 20 18:08 postgres-exporter
drwxr-xr-x. 3 gitlab-psql       root         77 10月 23 16:00 postgresql
drwxr-x---. 3 gitlab-prometheus root         38 10月 20 18:07 prometheus
drwxr-x---. 2 gitlab-redis      git          57 10月 23 17:02 redis
-rw-r--r--. 1 root              root         40 10月 20 17:18 trusted-certs-directory-hash
[root@localhost gitlab]# df -h 
文件系统        容量  已用  可用 已用% 挂载点
/dev/sda2       462G  197G  265G   43% /
devtmpfs        3.8G     0  3.8G    0% /dev
tmpfs           3.8G   88K  3.8G    1% /dev/shm
tmpfs           3.8G  9.0M  3.8G    1% /run
tmpfs           3.8G     0  3.8G    0% /sys/fs/cgroup
tmpfs           775M   16K  775M    1% /run/user/42
tmpfs           775M     0  775M    0% /run/user/0
[root@localhost gitlab]# 

在这里插入图片描述

从什么的命令执行查看,空间还是充足的,还有265G可用。

2.2 猜测GitLab备份包,解压之后损坏了

在这里插入图片描述

将解密之后的Gitlab备份包和原始的Gitlab备份包对比,字节数都是125403678720个字节,文件应该是没有损坏。

2.3 猜测是不是 /var/opt/gitlab/backups 目录的权限不对劲?

查看下/var/opt/gitlab/backups目录的权限和owner,如下所示:
在这里插入图片描述

[root@localhost gitlab-rails]# cd /var/opt/gitlab/backups/
[root@localhost backups]# ll
总用量 122464536
-rwxrwxrwx. 1 root root 125403678720 10月 23 15:33 1540263550_2018_10_23_9.4.3_gitlab_backup.tar
[root@localhost backups]# tar xf uploads.tar.gz -C /var/opt/gitlab/gitlab-rails/uploads
tar: uploads.tar.gz:无法 open: 没有那个文件或目录
tar: Error is not recoverable: exiting now
[root@localhost backups]# cd ../
[root@localhost gitlab]# ll
总用量 16
drwxr-xr-x. 2 root              root         58 10月 23 16:25 backups
-rw-------. 1 root              root         38 10月 20 18:07 bootstrapped
drwx------. 2 git               root         44 10月 23 16:00 gitaly
drwx------. 3 git               root         25 10月 23 16:47 git-data
drwxr-xr-x. 3 git               root         19 10月 20 17:18 gitlab-ci
drwxr-xr-x. 2 git               root         31 10月 20 18:08 gitlab-monitor
drwxr-xr-x. 9 git               root       4096 10月 20 18:07 gitlab-rails
drwx------. 2 git               root         23 10月 20 18:06 gitlab-shell
drwxr-x---. 2 git               gitlab-www   51 10月 23 16:00 gitlab-workhorse
drwx------. 3 root              root         68 10月 23 16:10 logrotate
drwxr-x---. 9 root              gitlab-www 4096 10月 23 16:00 nginx
drwxr-xr-x. 3 root              root         31 10月 20 18:07 node-exporter
drwx------. 2 gitlab-psql       root         25 10月 20 18:08 postgres-exporter
drwxr-xr-x. 3 gitlab-psql       root         77 10月 23 16:00 postgresql
drwxr-x---. 3 gitlab-prometheus root         38 10月 20 18:07 prometheus
drwxr-x---. 2 gitlab-redis      git          57 10月 23 16:47 redis
-rw-r--r--. 1 root              root         40 10月 20 17:18 trusted-certs-directory-hash
[root@localhost gitlab]# chown git backups/
[root@localhost gitlab]# chmod 700 backups/
[root@localhost gitlab]# cd backups/
[root@localhost backups]# sudo gitlab-rake gitlab:backup:restore BACKUP=1540263550_2018_10_23_9.4.3
Unpacking backup ... 

修改后的/var/opt/gitlab/backups目录权限和owner,如下所示:

在这里插入图片描述

[root@localhost gitlab]# 
[root@localhost gitlab]# 
[root@localhost gitlab]# pwd 
/var/opt/gitlab
[root@localhost gitlab]# ll
总用量 16
drwx------. 3 git               root         77 10月 23 17:03 backups
-rw-------. 1 root              root         38 10月 20 18:07 bootstrapped
drwx------. 2 git               root         44 10月 23 16:00 gitaly
drwx------. 3 git               root         25 10月 23 16:47 git-data
drwxr-xr-x. 3 git               root         19 10月 20 17:18 gitlab-ci
drwxr-xr-x. 2 git               root         31 10月 20 18:08 gitlab-monitor
drwxr-xr-x. 9 git               root       4096 10月 20 18:07 gitlab-rails
drwx------. 2 git               root         23 10月 20 18:06 gitlab-shell
drwxr-x---. 2 git               gitlab-www   51 10月 23 16:00 gitlab-workhorse
drwx------. 3 root              root         68 10月 23 17:10 logrotate
drwxr-x---. 9 root              gitlab-www 4096 10月 23 16:00 nginx
drwxr-xr-x. 3 root              root         31 10月 20 18:07 node-exporter
drwx------. 2 gitlab-psql       root         25 10月 20 18:08 postgres-exporter
drwxr-xr-x. 3 gitlab-psql       root         77 10月 23 16:00 postgresql
drwxr-x---. 3 gitlab-prometheus root         38 10月 20 18:07 prometheus
drwxr-x---. 2 gitlab-redis      git          57 10月 23 17:17 redis
-rw-r--r--. 1 root              root         40 10月 20 17:18 trusted-certs-directory-hash
[root@localhost gitlab]# 

我才反应起来,之前我将/var/opt/gitlab目录删除了,然后用了root用户新建了/var/opt/gitlab目录,所以导致不一致。而Gitlab恢复操作使用的用户是git,所以没有权限去操作root用户新建的目录。

修改好权限和所属用户之后,再执行命令就正常进行了!

在这里插入图片描述


作者:欧阳鹏 欢迎转载,与人分享是进步的源泉!
转载请保留原文地址:
https://blog.csdn.net/qq446282412/article/details/83310185
如果本文对您有所帮助,欢迎您扫码下图所示的支付宝和微信支付二维码对本文进行打赏。

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/qq446282412/article/details/83310185
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2020-03-07 08:48:33
  • 阅读 ( 1235 )
  • 分类:

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢