Use dump for backup and restore under Linux

Source: Internet
Author: User
Tags rewind

For the system, we can have a lot of ways to back up (restore) the system or file, the reason is to do the backup, is to be in the system or file damage, the timely recovery, reduce the loss to a minimum. Of course, the importance of backup is important for enterprise servers. Let's discuss in detail today how to use dump and restore for backup and restoration in Linux.

One, the principle of dump, advantages and limitations

The dump and restore defaults are already installed in RHEL5, and if you're not using Linux, you can go to Google and download the installation yourself.

When you use the dump command, it creates a list of files that have been modified since the last backup operation, and then packages the files into a separate file. When doing a backup, you need to specify a backup level, which is an integer between 0-9. A dump of level n backs up all files that have been modified since the last dump operation with a level less than N, and level 0 is a full backup. In this way, you can easily implement incremental backups, differential backups, and even daily backups. For example, you can select level 0 for the first backup (see later), and you can use level 1, Level 2, Level 3, and so on every day to make incremental backups every day ... When you need to do a differential backup every day, you can choose level 0 to do a full backup, and then every day use the same level greater than 0, such as the next day with 5, the third day with 5, the fourth day is also the same.

Advantages of using Dump:

1, backups can span multiple volumes of tape

2, can back up any type of file, even the device

3, Backup, file permissions, hosts, host groups, modification time, etc. will be saved

4, the ability to correctly handle file blocks (hole files) that never contain any data

5, can do incremental, differential backup

It also has deficiencies:

1, each file system must be separately transferred to the reserve part

2, only the local computer's file system can be transferred to the reserve (Rdump,rrestore can be used to compensate for this deficiency)

Of course, using tar can also be used for backup and restore, but tar can only be used in Linux or UNIX environments, and for cross-platform environments, dump is more comfortable to use personally.

If there is a condition, dump can also store the backup on tape. Linux typically uses/DEV/ST0 to represent a rewind device, while a/dev/nst0 represents a non-rewind device that, when used with a rewind device, is automatically rewind and then stored when the tape is exhausted, overwriting the previous data so that there is a risk of previous data loss. We will not discuss this place in detail.

Two, dump format, common parameters and use

Format: Dump [-level#] [-ACMMNQSUV] [-A file] [-B Records] [-B blocksize]

[-D density] [-D file] [-e inode#,inode#,...] [-E File]

[-F file] [-H level] [-I NR errors] [-j Zlevel] [-Q file]

[-S feet] [-T Date] [-y] [-Z Zlevel] FileSystem

Common parameters Level: backup Levels 0-9

-B: Specifies the length of the tape to be backed up, in kilobytes (some tapes do not support the use of this parameter when judging by the end flag

-B: Specifies the block size, which defaults to 10

-D: Specify density, default is 1600BPI

-D: Sets the name and path of the storage database, default is/etc/dumpdates file

(-e,-e: Parameters related to the number of inodes of the backup file)

-F: Specify the path and name of the backup file

-U: Update database file/etc/dumpdates

-S: Statistics the space required for backups, typically done before backup, in case of insufficient tape or disk space

Example:

Dump–0s/dev/sda1

Full backup before/dev/sda1 count how much capacity you need

Dump-0u–f/tmp/boot.dump/boot

650) this.width=650; "title=" 1 "height=" 338 "alt=" 1 "src=" http://img1.51cto.com/attachment/200902/16/339062_ 1234788856nkb0.jpg "border=" 0 "width=" 650 "style=" margin:0px;padding:0px;border:0px;vertical-align:top; "/>

Back up the/boot partition to file/tmp/boot.dump as a full backup, and update the/etc/dumpdates database file. "0" represents the backup level as a full backup. "U" updates the database, which records information such as the date, storage level, file system, and so on. If you never use the-u parameter, all storage becomes level 0. Because the system does not have a record that previously backed up the current file system.

When you change the/boot later, such as after the kernel upgrade, if you want to back up again, you can do the following:

Dump-1u–f/tmp/boot1.dump/boot

This will only back up files that have changed after a full backup (level 1 is greater than 0).

If you want to do an incremental backup later, then use the level 2,3,4 ...

If you want to make a differential backup, always use Level 1. The difference between incremental and differential backups look, not in detail:

650) this.width=650; "title=" 2 "height=" 238 "alt=" 2 "src=" http://img1.51cto.com/attachment/200902/16/339062_ 1234788857gmam.jpg "border=" 0 "width=" 650 "style=" margin:0px;padding:0px;border:0px;vertical-align:top; "/>

650) this.width=650; "title=" 3 "height=" 237 "alt=" 3 "src=" http://img1.51cto.com/attachment/200902/16/339062_ 1234788859zx1w.jpg "border=" 0 "width=" 650 "style=" margin:0px;padding:0px;border:0px;vertical-align:top; "/>

Third, view the files in the backup document and restore

Viewing files and restores in a backup document requires another tool, restore.

1. View the files in the backup document

650) this.width=650; "title=" 4 "height=" 324 "alt=" 4 "src=" http://img1.51cto.com/attachment/200902/16/339062_ 1234788861u4jg.jpg "border=" 0 "width=" 650 "style=" margin:0px;padding:0px;border:0px;vertical-align:top; "/>

650) this.width=650; "src=" http://img1.51cto.com/attachment/200812/200812231230011070250.jpg "border=" 0 "width=" 650 "style=" Margin:0px;padding:0px;border:medium none;vertical-align:top;/>

The-t parameter is meant to be viewed, and-F is the specified backup file to view. With the above command, you can view which files are backed up in the backup file.

1. Restore Backup

There are two ways to restore a backup, one is a full restore, and the other is a selective partial restore.

Let's take a look at the previous example, if you have a damaged/boot partition file in front of you, and you want to restore it, you can follow these steps:

650) this.width=650; "title=" 5 "height=" 232 "alt=" 5 "src=" http://img1.51cto.com/attachment/200902/16/339062_ 1234788861enod.jpg "border=" 0 "width=" 650 "style=" margin:0px;padding:0px;border:0px;vertical-align:top; "/>

-R parameter indicates rebuild

If only a portion of the data is lost, then you can use the parameter-I interactively to achieve a selective restore of the file

650) this.width=650; "title=" 200812231230011288890 "height=" "alt=" 200812231230011288890 "src="/HTTP/ Img1.51cto.com/attachment/200902/16/339062_1234788862nkhe.jpg "border=" 0 "width=" 650 "style=" margin:0px;padding:0 px;border:0px;vertical-align:top; "/>

This place I deliberately deleted a file initrd-2.6.18-53.el5.img

650) this.width=650; "title=" 6 "height=" 285 "alt=" 6 "src=" http://img1.51cto.com/attachment/200902/16/339062_ 1234788864pxkv.jpg "border=" 0 "width=" 650 "style=" margin:0px;padding:0px;border:0px;vertical-align:top; "/>

Use the parameter-I interactive and specify the backup file.

Pass? To view the commands you can use, LS is the contents of the backup file listed

650) this.width=650; "title=" 7 "height=" 157 "alt=" 7 "src=" http://img1.51cto.com/attachment/200902/16/339062_ 1234788865pne3.jpg "border=" 0 "width=" 650 "style=" margin:0px;padding:0px;border:0px;vertical-align:top; "/>

Select the file to be recovered by add and mark it as * when the LS is selected

Restores the selected file by extract.

When prompted with "specify next volume" As 1, it means a backup on a single volume of tape (where I'm using disk space). The following line prompts you to select "n" to indicate that you are not restoring the entire file system, but rather a single file.


This article is from the "Dream to Reality" blog, please be sure to keep this source http://lookingdream.blog.51cto.com/5177800/1839876

Use dump for backup and restore under Linux

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.