Linux cpio Backup command

Source: Internet
Author: User
Tags unpack

cpio Command

[[email protected] ~]# CPIO-COVB > [file|device] <== Backup
[[email protected] ~]# Cpio-icduv < [file|device] <== Restore
Parameters
-o: Data copy output to a file or device
-I: Copy data from file or device to system
-T: View the contents of a file or device created by Cpio
-C: A newer portable format mode storage
-V: Allows the file name to be displayed on the screen during storage
-B: Let the preset Blocks be added to 5120 bytes, the preset is bytes!
The benefit is that large files can be stored faster (refer to the I-nodes concept)
-D: Automatically create a directory! Because the content of cpio may not be in the same directory,
In this case, there will be a problem with the anti-backup process! Add-D to this time,
You can automatically set up the required directories!
-U: Automatically overwrites newer files with older ones!
Example

Example one: Write all the data on the system to the tape drive!
[[email protected] ~]# Find/-print | Cpio-covb >/dev/st0
# in general, use a SCSI interface tape drive, code is/DEV/ST0 Oh!

Example two: Check what files are on the tape drive?
[Email protected] ~]# CPIO-ICDVT </dev/st0
[Email protected] ~]# CPIO-ICDVT </dev/st0 >/tmp/content
# in the first action, the files in the tape drive will be listed on the screen, and we can go through the second action,
# Record all the file names to the/tmp/content files!

Example three: Restore the data on the tape back ~
[Email protected] ~]# Cpio-icduv </dev/st0
# in general, use a SCSI interface tape drive, code is/DEV/ST0 Oh!

Example four: Back up all "files" under/etc to/root/etc.cpio!
[Email protected] ~]# Find/etc-type F | Cpio-o >/root/etc.cpio
# so you can back it up ~ You may also be able to cpio-i </root/etc.cpio
# to catch the data!!!!

This Linux compression command series is here, and if possible, I would like to share some Linux commands with you.

System backup Command Cpio

Another complex backup command,

There are three modes of the CPIO command:
Copy-out to generate a Cpio format package for the system files
Copy-in to unpack a cpio-formatted package
Copy-pass is equivalent to a CP command, does not carry out any pressure package and package work, often used to re-
The corresponding parameters of the system are-o,-i,,-p so that the memory is more convenient, the parameters of the Linux command, although very
More, but there are rules that you can look for.

Create:
Primitive form:
[Email protected] tmp]# Cpio-o-o Photo.cpio
Press ENTER to manually type in the file name you need to package. Ends with the Ctrl+d key combination.

[[email protected] tmp]# ls
Dcp_0803.jpg dcp_0810.jpg dcp_0815.jpg dcp_0820.jpg dcp_0827.jpg
Dcp_0804.jpg dcp_0811.jpg dcp_0816.jpg dcp_0821.jpg dcp_0828.jpg
Dcp_0805.jpg dcp_0812.jpg dcp_0817.jpg dcp_0822.jpg
Dcp_0808.jpg dcp_0813.jpg dcp_0818.jpg dcp_0825.jpg
Dcp_0809.jpg dcp_0814.jpg dcp_0819.jpg dcp_0826.jpg

[[email protected] tmp]# ls | Cpio-o > Photo.cpio
cpio:Dcp_0803.jpg:truncating inode Number
cpio:Dcp_0804.jpg:truncating inode Number
cpio:Dcp_0805.jpg:truncating inode Number
cpio:Dcp_0808.jpg:truncating inode Number
cpio:Dcp_0809.jpg:truncating inode Number
cpio:Dcp_0810.jpg:truncating inode Number
cpio:Dcp_0811.jpg:truncating inode Number
cpio:Dcp_0812.jpg:truncating inode Number
cpio:Dcp_0813.jpg:truncating inode Number
cpio:Dcp_0814.jpg:truncating inode Number
cpio:Dcp_0815.jpg:truncating inode Number
cpio:Dcp_0816.jpg:truncating inode Number
cpio:Dcp_0817.jpg:truncating inode Number
cpio:Dcp_0818.jpg:truncating inode Number
cpio:Dcp_0819.jpg:truncating inode Number
cpio:Dcp_0820.jpg:truncating inode Number
cpio:Dcp_0821.jpg:truncating inode Number
cpio:Dcp_0822.jpg:truncating inode Number
cpio:Dcp_0825.jpg:truncating inode Number
cpio:Dcp_0826.jpg:truncating inode Number
cpio:Dcp_0827.jpg:truncating inode Number
cpio:Dcp_0828.jpg:truncating inode Number
2792 Blocks

Note: the-o parameter can also be--create substituted, indicating that the copy-out mode is being used,
The-o parameter can only be used with-O, indicating that the generated file is specified for out mode.

[email protected] tmp]# ls | Cpio-o-O Photo.cpio
This command is equivalent, except that the former is implemented with the redirect symbol. This can embody the Linux command
Complex and varied, so think more.

To view, unpack:

Unpack

[Email protected] tmp]# cpio-i-I Photo.cpio
2792 Blocks

Note: The-i parameter indicates the use of the copy-in mode
Looking at the list of files in a Cpio package is a bit like the parameters of the tar, all with the-t parameter,
You can also use--list instead.
The-I parameter is only in conjunction with-T,-I two parameters, indicating that a CPIO package is specified in copy-in mode.
A bit like the-f parameter in the TAR package, whether it's a tar package or a tar package or a view of tar content
, you have to add the-f argument, here, Cpio is only divided into copy-in and copy-out
two parts only.

[Email protected] tmp]# cpio-t-I Photo.cpio
Dcp_0803.jpg
Dcp_0804.jpg
Dcp_0805.jpg
Dcp_0808.jpg
Dcp_0809.jpg
Dcp_0810.jpg
Dcp_0811.jpg
Dcp_0812.jpg
Dcp_0813.jpg
Dcp_0814.jpg
Dcp_0815.jpg
Dcp_0816.jpg
Dcp_0817.jpg
Dcp_0818.jpg
Dcp_0819.jpg
Dcp_0820.jpg
Dcp_0821.jpg
Dcp_0822.jpg
Dcp_0825.jpg
Dcp_0826.jpg
Dcp_0827.jpg
Dcp_0828.jpg
2792 Blocks

Looking at a list of the files in a Cpio package is a bit like the parameters of the tar, all with the-t parameter, which can be
Replace with--list.

There are some advanced application parameters:
-U
If the file is already forcibly overwritten when unpacking
[Email protected] tmp]# cpio-i-I Test.cpio-u
[Email protected] tmp]# cpio-i-u-i Test.cpio

-F
The file matches the parameter, but is a reverse one, which conforms to the specified file and does not understand the package
[Email protected] tmp]# cpio-i-I test.cpio-f *.rpm
The result of this command is that Test.cpio in addition to the *.rpm file will be unpacked.

-L
This parameter is used when packaging, if the file is packaged in a signed connection, this parameter will be connected to the target file into the package, rather than just the symbolic link packaging.
[[email protected] tmp]# ls | Cpio-o-O newtest.cpio-l

-R
This parameter is used only when unpacking, to set the owner and the owning group for the unpacked file. However, the relationship between the user and the group must already exist in Passwd,group two files!!!
[Email protected] tmp]# cpio-i-I test.cpio-r Yue.pye
[Email protected] tmp]# cpio-i-I test.cpio-r Yueye
Here are two ways to represent the relationship between groups of users one is. Another is:

-R
This parameter is only useful in unpacking, and can not be used in conjunction with the-u parameter, otherwise, his role is to automatically prompt for renaming when a file name is in the same directory as the file and package in the package.
[Email protected] tmp]# cpio-i-I Test.cpio-r
Rename 12.1 A
Rename Backgroud C
Rename Bin--Bindir
Rename Crystal

-A
This parameter is used only when the package is pressed to add files to the existing Cpio package.
[Email protected] tmp]# Cpio-o-o test.cpio-a
[Email protected] tmp]# Cpio-o-a-o Test.cpio

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.