cpio

1.cpio

这个命令可以备份任何文件包含设备文件。

以下为cpio参数组合的三种方式:

-o:将数据Copy输出到文件或设备上。

-B:让默认的Blocks可以增加至5120 bytes,默认是512 bytes。

       这样的好处是可以让大文件的存储速度加快。

-i:将数据自文件或设备复制到系统中。

-d:自动新建目录,使用cpio所备份的目录不一定会在同一层目录,因此必须要让cpio在还原时可以创建目录。

-u:自动将较新的文件覆盖较旧的文件。

-t:需要配合-l参数,可用在查看以cpio新建的文件或者设备的内容。

-v:让存储的过程中文件名可以在屏幕中显示。

-c:一种较新的portable format方式存储。
【1】cpio   -ovcB   >    [file|device]     <==备份

root@random:/mnt/cpio_test# touch file{1..10}
root@random:/mnt/cpio_test# ls
file1  file10  file2  file3  file4  file5  file6  file7  file8  file9
root@random:/mnt/cpio_test# find /mnt/cpio_test/ | cpio -ovcB > cpio_test.cpio
/mnt/cpio_test/
/mnt/cpio_test/file10
/mnt/cpio_test/file8
/mnt/cpio_test/file7
/mnt/cpio_test/cpio_test.cpio
/mnt/cpio_test/file5
/mnt/cpio_test/file6
/mnt/cpio_test/file1
/mnt/cpio_test/file4
/mnt/cpio_test/file3
/mnt/cpio_test/file2
/mnt/cpio_test/file9
1 块
root@random:/mnt/cpio_test# ls
cpio_test.cpio  file10  file3  file5  file7  file9
file1           file2   file4  file6  file8
root@random:/mnt/cpio_test# file cpio_test.cpio 
cpio_test.cpio: ASCII cpio archive (pre-SVR4 or odc)

【2】cpio   -ivcdu  <     [file|device]    <==还原

【3】cpio   -ivct     <     [file|device]    <==查看

root@random:/mnt/cpio_test# cpio -ivct < cpio_test.cpio 
drwxr-xr-x   2 root     root            0 Jan 20 16:06 /mnt/cpio_test/
-rw-r--r--   1 root     root            0 Jan 20 16:05 /mnt/cpio_test/file10
-rw-r--r--   1 root     root            0 Jan 20 16:05 /mnt/cpio_test/file8
-rw-r--r--   1 root     root            0 Jan 20 16:05 /mnt/cpio_test/file7
-rw-r--r--   1 root     root            0 Jan 20 16:06 /mnt/cpio_test/cpio_test.cpio
-rw-r--r--   1 root     root            0 Jan 20 16:05 /mnt/cpio_test/file5
-rw-r--r--   1 root     root            0 Jan 20 16:05 /mnt/cpio_test/file6
-rw-r--r--   1 root     root            0 Jan 20 16:05 /mnt/cpio_test/file1
-rw-r--r--   1 root     root            0 Jan 20 16:05 /mnt/cpio_test/file4
-rw-r--r--   1 root     root            0 Jan 20 16:05 /mnt/cpio_test/file3
-rw-r--r--   1 root     root            0 Jan 20 16:05 /mnt/cpio_test/file2
-rw-r--r--   1 root     root            0 Jan 20 16:05 /mnt/cpio_test/file9
3 块

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值