Dd and cpio commands are used to back up the linux system-general Linux technology-Linux technology and application information. The following is a detailed description. Dd command
[Root @ linux ~] # Dd if = "input_file" of = "output_file" bs = "block_size" count = "number"
If: input file ??? Department tip Yun, parent dad, Mian FU
Of: output file ~ It can also be a device;
Bs: the size of a planned block. If no value is set, the default value is 512 bytes.
Count: the number of bs.
Example 1: back up/etc/passwd to/tmp/passwd. back
[Root @ linux ~] # Dd if =/etc/passwd of =/tmp/passwd. back
3 + 1 records in
3 + 1 records out
[Root @ linux ~] # Ll/etc/passwd/tmp/passwd. back
-Rw-r -- 1 root 1746 Aug 25 14:16/etc/passwd
-Rw-r -- 1 root 1746 Aug 29 16:57/tmp/passwd. back
Take a closer look, my/etc/passwd file size is 1746 bytes, because I have not set bs,
Therefore, the default value is 512 bytes. Therefore, the above 3 + 1 indicates three complete 512 bytes,
And the meaning of another block with less than 512 bytes. Actually, it seems like the cp command ~
Example 2: backup/dev/hda MBR
[Root @ linux ~] # Dd if =/dev/hda of =/tmp/mbr. back bs = 512 count = 1
1 + 0 records in
1 + 0 records out
So you have to do it well? How can this problem be solved ??? Yi invasion? Le? The MBR is 512 bytes, which is the first sector on the hard disk,
Therefore, I can use this method to record all the data in the MBR. It's really amazing! Pai_^
Example 3: Back up the entire/dev/hda1 partition.
[Root @ linux ~] # Dd if =/dev/hda1 of =/some/path/filenaem
This command is amazing! Back up all the content of the entire partition ~ The following of must not be in the/dev/hda1 directory ~
Otherwise, you cannot finish reading ~ This action is very useful. If you need to complete the content of the entire partition in the next day,
You can use dd if =/some/file of =/dev/hda1 to write data to the hard disk. If you want to back up the entire hard disk,
It is similar to Norton's ghost Software, from disk to disk ~ You can use dd ~ Amazing!
CPIO
[Root @ linux ~] # Cpio-covB> [file | device] <= backup
[Root @ linux ~] # Cpio-icduv <[file | device] <= restore
Parameters
-O: copy the data to a file or device.
-I: copy the data from a file or device to the system.
-T: view the files or device content created by cpio
-C: A new portable format Storage Method
-V: enables the file name to be displayed on the screen during storage.
-B: Increase the preset Blocks size to 5120 bytes. The default value is 512 bytes! This improves the storage speed of large files (refer to the I-nodes concept)
-D: automatically create a directory! The contents of cpio may not be in the same directory, so there will be problems in the anti-backup process! When-d is added, the desired directory can be automatically created!
-U: automatically overwrites older files!
Example
Example 1: Write all information on the system to the tape drive! [Root @ linux ~] # Find/-print | cpio-covB>/dev/st0
Generally, the serial number of a tape drive using the SCSI interface is/dev/st0!
Example 2: Check what files exist on the tape drive?
[Root @ linux ~] # Cpio-icdeep </dev/st0
[Root @ linux ~] # Cpio-icvt </dev/st0>/tmp/content
In the first action, the files in the tape drive are listed on the screen. In the second action, we can record all file names to the/tmp/content file!
Example 3: Restore the information on the tape ~
[Root @ linux ~] # Cpio-icduv </dev/st0
Generally, the serial number of a tape drive using the SCSI interface is/dev/st0!
Example 4: Back up all the "Files" under/etc to/root/etc. cpio!
[Root @ linux ~] # Find/etc-type f | cpio-o>/root/etc. cpio
In this way, you can back up ???? ? Persimmon string cpio-I </root/etc. cpio to capture the information!
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.