在以下命令序列中,为什么cpio
无法提取先前归档的文件?
/home/pkara/Desktop/temp
$ ls
eBooks myfile.tar
/home/pkara/Desktop/temp
$ find . -depth -print | cpio -ov > backup.cpio
./backup.cpio
./myfile.tar
./eBooks/logstash_atlantis/03_output.conf
./eBooks/logstash_atlantis/02_01_filter_paloalto.conf
./eBooks/logstash_atlantis/02_02_filter_squid.conf
./eBooks/logstash_atlantis/02_99_metrics_filter.conf
./eBooks/logstash_atlantis/01_input.conf
./eBooks/logstash_atlantis
./eBooks/Container-Networking-Docker-Kubernetes.pdf
./eBooks/lpic-1_2013.pdf
./eBooks/linux-bible-by-christopher-negus.pdf
./eBooks/PythonNotesForProfessionals.pdf
./eBooks/lpic1-notes
./eBooks
.
129731 blocks
/home/pkara/Desktop/temp
$ mkdir -p foo
/home/pkara/Desktop/temp
$ mv backup.cpio foo && cd $_
/home/pkara/Desktop/temp/foo
$ cpio -iv < backup.cpio
cpio: backup.cpio not created: newer or same age version exists
backup.cpio
myfile.tar
cpio: eBooks/logstash_atlantis/03_output.conf: Cannot open: No such file or directory
eBooks/logstash_atlantis/03_output.conf
cpio: eBooks/logstash_atlantis/02_01_filter_paloalto.conf: Cannot open: No such file or directory
eBooks/logstash_atlantis/02_01_filter_paloalto.conf
cpio: eBooks/logstash_atlantis/02_02_filter_squid.conf: Cannot open: No such file or directory
eBooks/logstash_atlantis/02_02_filter_squid.conf
cpio: eBooks/logstash_atlantis/02_99_metrics_filter.conf: Cannot open: No such file or directory
eBooks/logstash_atlantis/02_99_metrics_filter.conf
cpio: eBooks/logstash_atlantis/01_input.conf: Cannot open: No such file or directory
eBooks/logstash_atlantis/01_input.conf
cpio: eBooks/logstash_atlantis: Cannot mkdir: No such file or directory
eBooks/logstash_atlantis
cpio: eBooks/Container-Networking-Docker-Kubernetes.pdf: Cannot open: No such file or directory
eBooks/Container-Networking-Docker-Kubernetes.pdf
cpio: eBooks/lpic-1_2013.pdf: Cannot open: No such file or directory
eBooks/lpic-1_2013.pdf
cpio: eBooks/linux-bible-by-christopher-negus.pdf: Cannot open: No such file or directory
eBooks/linux-bible-by-christopher-negus.pdf
cpio: eBooks/PythonNotesForProfessionals.pdf: Cannot open: No such file or directory
eBooks/PythonNotesForProfessionals.pdf
cpio: eBooks/lpic1-notes: Cannot open: No such file or directory
eBooks/lpic1-notes
eBooks
.
129731 blocks
这里的问题是您
-depth
使用find
. 这告诉find
在目录本身之前处理目录内容。正如您在以下输出中看到的
find . -depth -print | cpio -ov > backup.cpio
:./eBooks/logstash_atlantis/03_output.conf
在目录之前处理./eBooks/logstash_atlantis
./eBooks/Container-Networking-Docker-Kubernetes.pdf
之前处理过./eBooks
。当您尝试提取存档时,子目录中的所有文件都会失败,因为目录还不存在(“无法打开:没有这样的文件或目录”)。
它也失败了
./backup.cpio
,因为它已经存在于这个目录中。解决方案:不要将 的
-depth
选项与find
结合使用cpio
。