[CLI]压缩备份相关命令汇总

//
Create Time: 201707092356
Update Time: 201707120653
//

1. ar

2. tar

##解压到指定目录下,并只保留部分路径名
% tar xf mysql.tar.gz -C /usr/local --strip-component N

3. compress

4. cpio

与tar相似cpio将文件归档到硬盘或磁带等存储设备中。在所处理的文件类型方面,它比tar更全面,但也更复杂。cpio在tar更为可靠,因为如果一个tar文件中某处有一个坏块,就不能对备份文件的其它部分进行访问,而使用cpio则只有坏块不能被访问,其他部分照样可以被访问。

4.1 Copy-Out Mode Syntax:
In copy-out mode, cpio copies files into an archive. It reads a list of filenames, one per line, on the standard input and writes the archive onto the standard output. A typical way to generate the list of filenames is with the find command;
4.2 Copy-In Mode Syntax:
In copy-in mode, cpio copies files out of an archive or lists the archive contents. It reads the archive from the standard input. Any non-option command line arguments are shell globbing patterns; only files in the archive whose names match one or more of those patterns are copied from the archive.
4.3 Copy-Pass Mode Syntax:
In copy-pass mode, cpio copies files from one directory tree to another, combining the copy-out and copy-in steps without actually using an archive. It reads the list of files to copy from the standard input; the directory into which it will copy them is given as a non-option argument.

### 当创建归档文件时,cpio从标准输入读取要备份的文件列表,
### 然后把生成的归档文件到标准输出,文件列表一般使用find或ls生成.
### cpio默认不会创建目录(-d),而且默认不会覆盖已有文件(-u)

### 备份整个目录树
% find . -print -depth | cpio -ov > tree.cpio
### 备份当前目录
% ls | cpio -ov > directory.cpio

5. dd

6. gzip/bzip2

默认不保留源文件,可使用gzip -c file > file.gz保留源文件

7. zcat/bzcat

可查看.gz文件内容

Reference:

  1. [cpio zh]http://onlyzq.blog.51cto.com/1228/517896
  2. [cpio en]https://www.computerhope.com/unix/ucpio.htm
  3. 3.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值