首页
首页 » 备份压缩 » cpio(copy in/out)

cpio(copy in/out)

cpio(copy in/out)
功能说明:备份文件。
语  法:cpio [-0aABckLovV][-C <输入/输出大小>][-F <备份档>][-H <备份格式>][-O <备份档>][--block-size=<区块大小>][--force-local][--help][--quiet][--version] 或 cpio [-bBcdfikmnrsStuvV][-C <输入/输出大小>][-E <范本文件>][-F <备份档>][-H <备份格式>][-I <备份档>][-M <回传信息>][-R <拥有者><:/.><所属群组>][--block-size=<区块大小>][--force-local][--help][--no-absolute-filenames][--no-preserve-owner][--only-verify-crc][--quiet][--sparse][--version][范本样式...] 或 cpio [-0adkiLmpuvV][-R <拥有者><:/.><所属群组>][--help][--no-preserve-owner][--quiet][--sparse][--version][目的目]
补充说明:cpio是用来建立,还原备份档的工具程序,它可以加入,解开cpio或tra备份档内的文件。
参  数:
 -0或--null  接受新增列控制字符,通常配合find指令的"-print0"参数使用。 
 -a或--reset-access-time  重新设置文件的存取时间。 
 -A或--append  附加到已存在的备份档中,且这个备份档必须存放在磁盘上,而不能放置于磁带机里。 
 -b或--swap  此参数的效果和同时指定"-sS"参数相同。 
 -B  将输入/输出的区块大小改成5210 Bytes。 
 -c  使用旧ASCII备份格式。 
 -C<区块大小>或--io-size=<区块大小>  设置输入/输出的区块大小,单位是Byte。 
 -d或--make-directories  如有需要cpio会自行建立目录。 
 -E<范本文件>或--pattern-file=<范本文件>  指定范本文件,其内含有一个或多个范本样式,让cpio解开符合范本条件的文件,格式为每列一个范本样式。 
 -f或--nonmatching  让cpio解开所有不符合范本条件的文件。 
 -F<备份档>或--file=<备份档>  指定备份档的名称,用来取代标准输入或输出,也能借此通过网络使用另一台主机的保存设备存取备份档。 
 -H<备份格式>  指定备份时欲使用的文件格式。 
 -i或--extract  执行copy-in模式,还原备份档。 
 -l<备份档>  指定备份档的名称,用来取代标准输入,也能借此通过网络使用另一台主机的保存设备读取备份档。 
 -k  此参数将忽略不予处理,仅负责解决cpio不同版本间的兼容性问题。 
 -l或--link  以硬连接的方式取代复制文件,可在copy-pass模式下运用。 
 -L或--dereference  不建立符号连接,直接复制该连接所指向的原始文件。 
 -m或preserve-modification-time  不去更换文件的更改时间。 
 -M<回传信息>或--message=<回传信息>  设置更换保存媒体的信息。 
 -n或--numeric-uid-gid  使用"-tv"参数列出备份档的内容时,若再加上参数"-n",则会以用户识别码和群组识别码替代拥有者和群组名称列出文件清单。 
 -o或--create  执行copy-out模式,建立备份档。 
 -O<备份档>  指定备份档的名称,用来取代标准输出,也能借此通过网络 使用另一台主机的保存设备存放备份档。 
 -p或--pass-through  执行copy-pass模式,略过备份步骤,直接将文件复制到目的目录。 
 -r或--rename  当有文件名称需要更动时,采用互动模式。 
 -R<拥有者><:/.><所属群组>或
 ----owner<拥有者><:/.><所属群组>  在copy-in模式还原备份档,或copy-pass模式复制文件时,可指定这些备份,复制的文件的拥有者与所属群组。 
 -s或--swap-bytes  交换每对字节的内容。 
 -S或--swap-halfwords  交换每半个字节的内容。 
 -t或--list  将输入的内容呈现出来。 
 -u或--unconditional  置换所有文件,不论日期时间的新旧与否,皆不予询问而直接覆盖。 
 -v或--verbose  详细显示指令的执行过程。 
 -V或--dot  执行指令时,在每个文件的执行程序前面加上"."号 
 --block-size=<区块大小>  设置输入/输出的区块大小,假如设置数值为5,则区块大小为2500,若设置成10,则区块大小为5120,依次类推。 
 --force-local  强制将备份档存放在本地主机。 
 --help  在线帮助。 
 --no-absolute-filenames  使用相对路径建立文件名称。 
 --no-preserve-owner  不保留文件的拥有者,谁解开了备份档,那些文件就归谁所有。 
 -only-verify-crc  当备份档采用CRC备份格式时,可使用这项参数检查备份档内的每个文件是否正确无误。 
 --quiet  不显示复制了多少区块。 
 --sparse  倘若一个文件内含大量的连续0字节,则将此文件存成稀疏文件。 
 --version  显示版本信息。

cpio

cpio flags [options]

Copy file archives from or to tape or disk, or to another location on the local machine. Each of the three flags -i, -o, or -p accepts different options.

Flags

-i, --extract [options] [patterns]

Copy in (extract) from an archive files whose names match selected patterns. Each pattern can include Bourne shell filename metacharacters. (Patterns should be quoted or escaped so that they are interpreted by cpio, not by the shell.) If pattern is omitted, all files are copied in. Existing files are not overwritten by older versions from the archive unless -u is specified.

-o, --create [options]

Copy out to an archive a list of files whose names are given on the standard input.

-p, --pass-through [options] directory

Copy (pass) files to another directory on the same system. Destination pathnames are interpreted relative to the named directory.

Comparison of valid options

Options available to the -i, -o, and -p flags are shown here (the - is omitted for clarity):

i: bcdf mnrtsuv B SVCEHMR IF o: 0a c vABL VC HM O F p: 0a d lm uv L V R

Options

-0, --null

Expect list of filenames to be terminated with null, not newline. This allows files with a newline in their names to be included.

-a, --reset-access-time

Reset access times of input files after reading them.

-A, --append

Append files to an existing archive, which must be a disk file. Specify this archive with -O or -F.

-b, --swap

Swap bytes and half-words to convert between big-endian and little-endian 32-bit integers.

-B

Block input or output using 5120 bytes per record (default is 512 bytes per record).

--blocksize=size

Set input or output block size to size × 512 bytes.

-c

Read or write header information as ASCII characters; useful when source and destination machines are different types.

-C n, --io-size=n

Like -B, but block size can be any positive integer n.

-d, --make-directories

Create directories as needed.

-E file, --pattern-file=file

Extract from the archives filenames that match patterns in file.

-f, --nonmatching

Reverse the sense of copying; copy all files except those that match patterns.

-F file, --file=file

Use file as the archive, not stdin or stdout. file can reside on another machine, if given in the form user@hostname:file (where user@ is optional).

--force-local

Assume that file (provided by -F, -I, or -O) is a local file, even if it contains a colon (:) indicating a remote file.

-H type, --format=type

Use type format. Default for copy-out is bin; default for copy-in is autodetection of the format. Valid formats (all caps also accepted) are:

bin

Binary.

odc

Old (POSIX.1) portable format.

newc

New (SVR4) portable format.

crc

New (SVR4) portable format with checksum added.

tar

Tar.

ustar

POSIX.1 tar (also recognizes GNU tar archives).

hpbin

HP-UX's binary (obsolete).

hpodc

HP-UX's portable format.

-I file

Read file as an input archive. May be on a remote machine (see -F).

-k

Ignored. For backward compatibility.

-l, --link

Link files instead of copying.

-L, --dereference

Follow symbolic links.

-m, --preserve-modification-time

Retain previous file modification time.

-M msg, --message=msg

Print msg when switching media, as a prompt before switching to new media. Use variable %d in the message as a numeric ID for the next medium. -M is valid only with -I or -O.

-n, --numeric-uid-gid

When verbosely listing contents, show user ID and group ID numerically.

--no-absolute-filenames

Create all copied-in files relative to the current directory.

--no-preserve-owner

Make all copied files owned by yourself, instead of the owner of the original. Can be used only if you are a privileged user.

-O file

Archive the output to file, which may be a file on another machine (see -F).

--only-verify-crc

For a CRC-format archive, verify the CRC of each file; don't actually copy the files in.

--quiet

Don't print the number of blocks copied.

-r

Rename files interactively.

-R [user] [:group] , --owner [user] [:group]

Reassign file ownership and group information to the user's login ID (privileged users only).

-s, --swap-bytes

Swap bytes of each two-byte half-word.

-S, --swap-half-words

Swap half-words of each four-byte word.

--sparse

For copy-out and copy-pass, write files that have large blocks of zeros as sparse files.

-t, --list

Print a table of contents of the input (create no files). When used with the -v option, resembles output of ls -l.

-u, --unconditional

Unconditional copy; old files can overwrite new ones.

-v, --verbose

Print a list of filenames processed.

-V, --dot

Print a dot for each file read or written (this shows cpio at work without cluttering the screen).

--version

Print version number and then exit.

Examples

Generate a list of files whose names end in .old using find; use the list as input to cpio:

find . -name "*.old" | cpio -ocBv > /dev/rst8

Restore from a tape drive all files whose names contain save (subdirectories are created if needed):

cpio -icdv "*save*" < /dev/rst8

Move a directory tree:

find . -depth | cpio -padm /mydir