Linux Learning packaging compression and backup production ISO command

Source: Internet
Author: User
Tags bz2

gzip [options] File name

The default is compressed files that form. GZ after compression, and the source files no longer exist
gzip [Options]-C file name > ZIP file name. gz <== compress files and keep source files
Zcat compressed file name. GZ <== Read plain text document compressed files

bzip2 [Options] File name

The

Default is a compressed file that forms. bz2 after compression, and the source file no longer exists, similar to gzip
bzip2 [options]-C file name > compressed file name .gz    <== compressed files and preserves source files
Bzcat Compressed file name .bz2    <== read plain text document compressed Files

Package Command tar
tar    [options] [CV]-F [ Created file name] [packaged directory or file]    <== packaged with compression
tar    [optinos] [TV]-F [file name created]        <== View file name
tar    [optinos] [XV]-F [created filename] [-C directory]         <== Extract
Package compression/view/Unzip common
tar    -jcvf [file name created. bz2] [packaged directory or file]
tar    &NBSP;-JTVF [established filename .bz2]    
tar    -jxvf [file name established. bz2] [-C directory]
Gzip, Change the J option to Z

Other important options:
-P: Retain the original permissions and properties of the backup data, often used to back up important configuration files
- P : retains absolute path, that is, allows the backup data to have the root directory exists meaning;
--exclude=file: During compression, do not package FILE

Unzip only one document in a compressed package
#tar-jxv-f. tar.bz2 to unlock file name

The practice of packaging a directory, but not including some files in that directory
#tar-jcv-f/root/system.tar.bz2--exclude=/root/etc.tar.bz2/root

Just back up a new file than at some point (you'll see a lot of time before you see it, but that's the catalog!). )
#find/ETC-NEWER/ETC/PASSWD <== will now show a new file name than the mtime of/etc/passwd.
#tar-jcvf/root/etc.newer.then.passwd.tar.bz2--newer-mtime= "2008/09/29"/etc/*

Dump and restore backup/restore

Although dump supports the entire file system or a single individual directory, the support for the directory is less
When the data to be backed up is a single file system:
If it is a single file system (filesystem), then the file system can use the full dump function, including the use of
0~9 a number of level to backup, while the backup can use the mount point or the device file name (for example,/DEV/SDA5
such as the device file name) for backup

The data to be backed up is only a directory, not a single file system:
For example, you only want to back up/home/someone/, but the directory is not a standalone file system. There is a limit to backup at this time
! include:
o All backup data must be under this directory (in this case:/home/someone/);
O and can only use level 0, i.e. only full backup is supported;
o the-u option is not supported, that is, the time log file for the individual level backup of/etc/dumpdates cannot be established;

#dump [-SUVJ] [-level] [-f backup file] data to be backed up
#dump-W
/etc/dumpdates

Options and Parameters:
-S: Lists only how much disk space is needed to back up the data to be backed up;
-U: Log the time of this dump to the/etc/dumpdates file;
-V: Displays the file process of the dump;
-J: Join BZIP2 support! Compress the data and the default bzip2 compression level is 2
-level: That's the level we're talking about, from 0 ~ 9 to a total of 10 levels;
-F: It's a bit like tar! The resulting file is also followed by, for example, the/DEV/ST0 device file name, etc.
-W: List partition with dump set in/etc/fstab is there a backup?
More options for self-use man

Restore
#restore-T [-f DumpFile] [-h] <== to view the dump file
#restore-C [-F dumpfile] [-D mount Point] <== compare dump and actual file
#restore-I [-f dumpfile] <== Enter interactive mode
#restore-R [-F DumpFile] <== restore entire file system

Options and Parameters:
Various modes can not be mixed, such as cannot write-TC
-T: This mode is used to look up the dump of the backup file contains what important data, similar to the TAR-T function;
C: This mode can take the data in the dump to compare with the actual file system, will eventually list "in the dump file is recorded, and the current file system is not the same" file;
-I: Enter the interactive mode, you can restore only some files, used in the dump directory when the restore
-R: A mode to restore the entire filesystem, used to restore the dump backup for the file system;
Other more commonly used options feature:
-H: View Inode and file system label information in full backup data
-F: The dump file you're going to handle is on the back!
-D: And-C to match, you can find the next mount point and dump has a different file

View Backup data content after dump with restore
#restore-T-f/root/boot.dump
Compare differences and restore the entire file system
#restore-C-f/root/boot.dump
Since dump is recording the entire file system, you should also give a new file system when you restore it.
Create a new file system/dev/sda3, mounted under/mnt
#cd/mnt
#restore-R-f/root/boot.dump
/ROOT/BOOT.DUMP.1 that file content also restore, then continue to use "restore-r-F/ROOT/BOOT.DUMP.1 to restore

Restore interactive mode for restoring only partial files
#restore-I.-f/root/etc.dump
Restore>
#此时你就已经进入 Restore's interactive mode screen, note that:
#你目前已经在 etc.dump This file, all the moves are within the etc.dump.
Restore>help <== View available directives
............
Restore>extract
<== starting to decompress
You haven't read any volumes yet. <== here will ask you for the volume you need.
Unless you know which volume your file (s) is on you should start
With the last volume and work towards the first.
Specify next Volume # (None if no more volumes): 1 <== only one volume
Set owner/mode for '. '? [yn] n <== no need to modify permissions
Restore > Quit <== the ability to leave restore

Disc Write Tool
The usual way to burn a text pattern is this:
The data that needs to be backed up is built into an image file (ISO), which is processed by mkisofs instruction;
Burn the image file to a disc or DVD and use the Cdrecord directive to process it.
Mkisofs: Creating an image File
The Linux image file (CD or DVD) that we get down from the FTP station has to continue to be burned as a solid disc/DVD
To be able to use it further, including installing or updating your Linux! The same thing, you want to use a recorder to put your data
When you burn to a DVD, you have to report your data as an image file before you can write to the DVD. And your data is reported
into an image file by mkisofs this command.
#mkisofs [-o image] [-RV] [-m file] files to be backed up. [-V vol]-graft-point isodir=systemdir ...
Options and Parameters:
-O: Follow the file name of the image you want to generate.
-R: Through Rock Ridge generate supporting Unix/linux file data, can record more information;
-V: Displays the process of building the ISO file
-M file:-M is meant to exclude files (exclude), and subsequent files are not backed up in the image file
-V Vol: Build Volume, sort of something like the CD title that Windows sees in the file manager
-graft-point:graft the meaning of transfer or transplant, the relevant information in the article below to explain
The format of the disc is generally called iso9660, which generally only supports the old version of the DOS file name, i.e. the file name can only be 8.3
(file name 8 characters, extension 3 characters) exists if the option to add-R, then the file information can be recorded
More complete, can include Uid/gid and permissions and so on, so remember to add this-r option.

In addition, in the case of general presets, all files to be added to the image will be placed in the root directory of the mapping file, so as to
May cause the file classification after burning is not easy. So, you can use-graft-point this option when you use this selection
, you can use the following methods to define the directories that are located in the image file, for example:
The directory in the image file = the directory where the actual Linux file system is located
/movies/=/srv/movies/(Files within Linux/srv/movies, add to the/movies/directory in the image file)
/linux/etc=/etc (Back up all data in/etc/in Linux to the/linux/etc/directory in the image file)
Let's illustrate it in a simple example. If you want to/root,/home, etc in the directory of the data to burn up, first have to deal with the image file, we first do not use the-graft-point option to process this image file try to see:

#mkisofs-R-v-o/tmp/system.img/root/home/etc

#mount-O loop/tmp/system.img/mnt <== mount, and then view the results

As we can see from the above example, the data for three directories (/root,/home,/etc) are all placed in the top level of the image file.
Record, especially because of the existence of/ROOT/ETC, the data of the/etc does not seem to be included, and there is a lost+found directory exists, we can use-graft-point to handle
# mkisofs-r-V ' linux_file '-o/tmp/system.img-m/home/lost+found-graft-point \
>/root=/root/home=/home/etc=/etc

Cdrecord: Disc Burning tool
#cdrecord-scanbus dev=ata <== Query Burner location
#cdrecord-v dev=ata:x,y,z blank=[fast|all] <== Erase Duplicate read-write tablets
#cdrecord-v Dev=ata:x,y,z-format <== formatting dvd+rw
#cdrecord-v Dev=ata:x,y,z [available options feature] File.iso
Options and Parameters:
-scanbus: Used to scan the disk bus and find the available burner, the subsequent device is the ATA interface
-V: During the Cdrecord operation, the process is displayed.
Dev=ata:x,y,z: The next x, Y, Z is the location of the recorder on your system, very important!
Blank=[fast|all]:blank to erase repeatable write CD/DVD-RW, use fast faster, all is more complete
-format: Only DVDs for DVD+RW in this format;
The available options feature is primarily the option to write to the CD/DVD, and common options include:
-data: Specifies that subsequent files are written in data format, not in CD tracks (-audio)
Speed=x: Specifies the burning speed, for example, the CD is available with a speed=40 of 40 times times, and the DVD is available speed=4
-eject: Specifies that the disc is automatically exited when burning is complete
Fs=ym: Specifies how much buffer memory is available for staging the image file to the buffer memory first. Preset to 4m, general recommendations can be increased to 8m,
However, it depends on your recorder.
Option features for DVD:
Driveropts=burnfree: Open the Write function of Buffer underrun free mode
-sao: Support for DVD-RW format
More options for Self man

Detect where your recorder is located:
Text mode burning is really troublesome, because there is no WYSIWYG environment, to burn first to find the burner,
Since the early recorders are all using SCSI interfaces, the method of querying the burner must be handled with the identification of the SCSI interface.
The way to query a burner is:
#cdrecord-scanbus
In the query results can be found that there is a recorder, which also shows the model of this burner, and most importantly, the above table has the bottom line of the three numbers, the three numbers is the location of this burner! In the example above, this burner is located in the "ata:1,1,0" place. So now how to burn/tmp/system.img to CD/DVD? Bird Brother here first to CD, for example, Brother Bird with a CD-RW (Repeatable Read and write) disc, say the truth, although CD-RW or DVD-RW more expensive, but at least can be reused, The impact on the environment is relatively small, we recommend that you use repeatable read and write films. Since the CD-RW may have to be erased first (delete the original data) before writing, so let's take a look at the bottom.
How to erase a piece of CD/DVD, then write directly to the disc
Tips: Since CD/DVD is used with the Cdrecord directive, the instructions are almost always given in both CDs and DVDs. However, the writing of the DVD requires additional driveropts=burnfree or-dao options such as support. In addition, CDs have CD-R (one-time write) and a CD-RW (repeated write), as for the DVD is mainly in two formats, namely, DVD+R and two different formats. If it is repeatable read and write:
DVD-RW, DVD+RW. Other than DVD+RW's erase method may be different, the other way of writing is the same.

1. Erase the original contents of the disc first: (Repeatable read and write discs)
#cdrecord-V dev=ata:1,1,0 blank=fast
2. Start Burning
#cdrecord-V dev=ata:1,1,0 fs=8m-dummy-data/tmp/system.img
[-data option is the default, do not have to be able to, self-man]
3. After burning, test mount, check the contents:
#mount-T Iso9660/dev/cdrom/mnt
#df-H/mnt

To perform a DVD-RW burn action:
1. Erase
#cdrecord-V dev=ata:1,1,0 blank=fast
2. Start writing DVDs, note that some options or CDs are not the same
#cdrecord-V dev=ata:1,1,0 Fs=8m-data-sao driveropts=burnfree/tmp/system.img
3. After burning, test mount, check the contents:
#mount-T Iso9660/dev/cdrom/mnt
#df-H/mnt

Other common compression and backup tools
Dd
The maximum effect of this DD instruction should be "backup", because DD can read the contents of the disk device (almost directly read the sector "sector"), and then back up the entire device into a file, dd some of the more important options, as follows:
#dd if= "Input_file" of= "output_file" bs= "block_size" count= "number"
Options and Parameters:
If: is the input file, or it can be a device
Of: Is the output file, or it can be a device
BS: The size of a block planned, if not specified, the preset is 512bytes (the size of a sector)
Count: How many BS means.

Back up the/etc/passwd to/tmp/passwd.back
#dd if=/etc/passwd Of=/tmp/passwd.back
Back up the first sector of your own disk
#dd if=/dev/hdc of=/tmp/mbr.back bs=512 count=1
The first sector contains MBR and partition table, through which you can back up the MBR and partition table of this disk in one breath!
Find the smallest partition slot in the system and back it up:


Cpio
This makes a lot of fun, because Cpio can back up anything, including device files. However, Cpio has a big problem, that is, Cpio will not take the initiative to find files to back up, so cpio have to cooperate with similar to find the file name can be found instructions to tell Cpio where the data is backed up
#cpio-OVCB > [file|device] <== Backup
#cpio-IVCDU < [file|device] <== Restore


#cpio-IVCT < [File|device] <==

Options and parameters to be used for backup:

-o: Data copy output to a file or appliance
-B: Let the preset blocks can be added to 5120 bytes, the preset is the bytes, this is the advantage of allowing large files to store the speed
Speed up (refer to I-nodes's concept)

The options and parameters that are used by the restore:
-I: Copy data from file or device to system
-D: Automatically create a directory! The data backed up using CPIO is not necessarily in the same directory, so we
You have to let Cpio create a new directory at restore time, you have to have the-D option Help
-U: Automatically overwrite newer files with older files
-T: With the-i option, which can be used to "view" the contents of a file or device created by Cpio
Some shareable options and parameters:
-V: Allows the file name to be displayed on the screen during storage
-C: A newer portable format mode storage
More detailed explanation for self man

Find all the files under/boot and then back him up to/tmp/boot.cpio.
#find/boot | CPIO-OCVB >/tmp/boot.cpio
#cpio-IDVC </tmp/boot.cpio

Linux Learning packaging compression and backup production ISO command

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.