一、問題描述
今天在測試加密GitLab備份文件之后,進(jìn)行解密,然后再恢復(fù)GitLab的時候,恢復(fù)失敗,報了如下的錯誤:
tar: db:無法 mkdir: 權(quán)限不夠
tar: db:無法 mkdir: 權(quán)限不夠
tar: db/database.sql.gz:無法 open: 沒有那個文件或目錄
tar: uploads.tar.gz:無法 open: 權(quán)限不夠
tar: builds.tar.gz:無法 open: 權(quán)限不夠
tar: artifacts.tar.gz:無法 open: 權(quán)限不夠
tar: pages.tar.gz:無法 open: 權(quán)限不夠
tar: lfs.tar.gz:無法 open: 權(quán)限不夠
tar: backup_information.yml:無法 open: 權(quán)限不夠
tar: 由于前次錯誤,將以上次的錯誤狀態(tài)退出
unpacking backup failed
詳細(xì)錯誤如下:
tar: repositories:無法 mkdir: 權(quán)限不夠
tar: repositories/caokuishun:無法 mkdir: 沒有那個文件或目錄
tar: repositories:無法 mkdir: 權(quán)限不夠
tar: repositories/caokuishun/EKOCelluarViewMod.bundle:無法 open: 沒有那個文件或目錄
tar: repositories:無法 mkdir: 權(quán)限不夠
tar: repositories/caokuishun/SDKTest.bundle:無法 open: 沒有那個文件或目錄
tar: repositories:無法 mkdir: 權(quán)限不夠
tar: repositories/ReactNative:無法 mkdir: 沒有那個文件或目錄
tar: repositories:無法 mkdir: 權(quán)限不夠
tar: repositories/ReactNative/Binding.bundle:無法 open: 沒有那個文件或目錄
tar: db:無法 mkdir: 權(quán)限不夠
tar: db:無法 mkdir: 權(quán)限不夠
tar: db/database.sql.gz:無法 open: 沒有那個文件或目錄
tar: uploads.tar.gz:無法 open: 權(quán)限不夠
tar: builds.tar.gz:無法 open: 權(quán)限不夠
tar: artifacts.tar.gz:無法 open: 權(quán)限不夠
tar: pages.tar.gz:無法 open: 權(quán)限不夠
tar: lfs.tar.gz:無法 open: 權(quán)限不夠
tar: backup_information.yml:無法 open: 權(quán)限不夠
tar: 由于前次錯誤,將以上次的錯誤狀態(tài)退出
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
文件系統(tǒng) 容量 已用 可用 已用% 掛載點(diǎn)
/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]#
從什么的命令執(zhí)行查看,空間還是充足的,還有265G可用。
2.2 猜測GitLab備份包,解壓之后損壞了
將解密之后的Gitlab備份包和原始的Gitlab備份包對比,字節(jié)數(shù)都是125403678720個字節(jié),文件應(yīng)該是沒有損壞。
2.3 猜測是不是 /var/opt/gitlab/backups 目錄的權(quán)限不對勁?
查看下/var/opt/gitlab/backups目錄的權(quán)限和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目錄權(quán)限和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]#
我才反應(yīng)起來,之前我將/var/opt/gitlab目錄刪除了,然后用了root用戶新建了/var/opt/gitlab目錄,所以導(dǎo)致不一致。而Gitlab恢復(fù)操作使用的用戶是git,所以沒有權(quán)限去操作root用戶新建的目錄。
修改好權(quán)限和所屬用戶之后,再執(zhí)行命令就正常進(jìn)行了!
作者:歐陽鵬 歡迎轉(zhuǎn)載,與人分享是進(jìn)步的源泉!
轉(zhuǎn)載請保留原文地址:https://blog.csdn.net/qq446282412/article/details/83310185
如果本文對您有所幫助,歡迎您掃碼下圖所示的支付寶和微信支付二維碼對本文進(jìn)行打賞。