Dump and restore commands for full backup, Incremental backup, and differential backup

Source: Internet
Author: User

Differential backup: Back up data based on full backup. Because the tar command cannot implement differential backup, this article explains how to use the dump and restore commands. Of course, the dump and restore commands can also implement full backup and Incremental backup.

 

1. Create Backup directory partition mounting

[root@serv01 data]# mkdir /backup[root@serv01 data]# fdisk /dev/sdb[root@serv01 data]# fdisk /dev/sdc[root@serv01 data]# mkfs.ext4 /dev/sdb1[root@serv01 data]# mkfs.ext4 /dev/sdc1 [root@serv01 data]# mount /dev/sdb1 /data[root@serv01 data]# mount /dev/sdc1/backup/

Copy files and modify configuration files

# Copy a file [root @ serv01 data] # rm-RF * [root @ serv01 data] # cp/boot /*. CP: omitting directory '/boot/EFI' CP: omitting directory '/boot/GRUB' CP: omitting directory '/boot/lost + found' # Append content to the fstab file [root @ serv01 data] # echo "/dev/sdb1/Data ext4 defaults 1 2">/etc /fstab [root @ serv01 data] # echo "/dev/sdc1/backup ext4 defaults 1 2">/etc/fstab

Three dump and restore -- implement full backup

[Root @ serv01 data] # Yum install dump-y # dump: Incremental backup and differential backup are supported, and only individual partitions can be backed up #0: Full backup # U: update/etc/dumpdates # F: backup name [root @ serv01 data] # cd/backup/[root @ serv01 backup] # lslost + found [root @ serv01 backup] # rm-RF lost + found /# first view, dumpdates has no content [root @ serv01 backup] # ls/etc/dumpdates # backup [root @ serv01 backup] # dump-0 UF data01.dump/data/dump: date of this level 0 dump: Fri Aug 2 18:57:53 2013 dump: dumping/dev/sdb1 (/data) to data01.dump dump: Label: None dump: writing 10 kilobyte records dump: mapping (pass I) [regular files] Dump: Mapping (pass II) [directories] Dump: estimated 59 blocks. dump: Volume 1 started with Block 1 at: Fri Aug 2 18:57:53 2013 dump: dumping (pass III) [directories] Dump: dumping (pass IV) [regular files] Dump: closing data01.dump dump: Volume 1 completed at: Fri Aug 2 18:57:53 2013 dump: Volume 1 50 blocks (0.05 MB) dump: 50 blocks (0.05 MB) On 1 volume (s) dump: finished in less than a second dump: date of this level 0 dump: Fri Aug 2 18:57:53 2013 dump: date this dump completed: Fri Aug 2 18:57:53 2013 dump: Average transfer rate: 0 kb/s dump: dump is done [root @ serv01 backup] # lltotal 52-rw-r -- r -. 1 Root 51200 Aug 2 data01.dump # view the dumpdates file, it is found that the [root @ serv01 backup] # Cat/etc/dumpdates/dev/sdb1 0 Fri Aug 2 18:57:53 2013 + 0800 # restoration has been updated, and the data is gone, re-Backup [root @ serv01 backup] # cd/data [root @ serv01 data] # lslost + found [root @ serv01 data] # rm-RF * [root @ serv01 data] # CP/boot /*. /CP: omitting directory '/boot/EFI' CP: omitting directory '/boot/GRUB' CP: omitting directory '/boot/lost + found' [root @ serv01 data] # cd/backup/[root @ serv01 backup] # lsdata01.dump [root @ serv01 backup] # rm-RF * [root @ serv01 backup] # ls [root @ serv01 backup] #>/etc/dumpdates [root @ serv01 backup] # dump-0 UF dump01.dump/data/dump: date of this level 0 dump: Fri Aug 2 19:02:20 2013 dump: dumping/dev/sdb1 (/data) to dump01.dump dump: Label: None dump: writing 10 kilobyte records dump: mapping (pass I) [regular files] Dump: Mapping (pass II) [directories] Dump: Estimated 18674 blocks. dump: Volume 1 started with Block 1 at: Fri Aug 2 19:02:20 2013 dump: dumping (pass III) [directories] Dump: dumping (pass IV) [regular files] Dump: closing dump01.dump dump: Volume 1 completed at: Fri Aug 2 19:02:20 2013 dump: Volume 1 18670 blocks (18.23 MB) dump: 18670 blocks (18.23 MB) On 1 volume (s) dump: finished in less than a second dump: date of this level 0 dump: Fri Aug 2 19:02:20 2013 dump: date this dump completed: Fri Aug 2 19:02:20 2013 dump: Average transfer rate: 0 kb/s dump: dump is done # enter the data directory, found data [root @ serv01 backup] # cd/data [root @ serv01 data] # lsconfig-2.6.32-131.0.15.el6.x86_64 symvers-2.6.32-131.0.15.el6.x86_64.gz vmlinuz-2.6.32-131.0.15.el6.x86_64initramfs-2.6.32-131.0.15.el6.x86_64.img system. map-2.6.32-131.0.15.el6.x86_64 # Delete All, simulate data loss [root @ serv01 data] # rm-RF * [root @ serv01 data] # ls # recover data [root @ serv01 data] # restore-RF/backup/dump01.dump # recovery successful [root @ serv01 data] # lsconfig-2.6.32-131.0.15.el6.x86_64 restoresymtable system. map-2.6.32-131.0.15.el6.x86_64initramfs-2.6.32-131.0.15.el6.x86_64.img symvers-2.6.32-131.0.15.el6.x86_64.gz vmlinuz-2.6.32-131.0.15.el6.x86_64 [root @ serv01 data] # cp/etc/passwd. /[root @ serv01 data] # lsconfig-2.6.32-131.0.15.el6.x86_64 passwd symvers-2.6.32-131.0.15.el6.x86_64.gz vmlinuz-2.6.32-131.0.15.el6.x86_64initramfs-2.6.32-131.0.15.el6.x86_64.img restoresymtable system. map-2.6.32-131.0.15.el6.x86_64 [root @ serv01 data] # cd/backup/

Four dump and restore -- Incremental Backup

# Incremental Backup: 1-9 # dump: backs up disks, not just files; only separate partitions can be backed up [root @ serv01 data] # rm-RF * [root @ serv01 data] # cp/boot /*. CP: omitting directory '/boot/EFI' CP: omitting directory '/boot/GRUB' CP: omitting directory '/boot/lost + found' [root @ serv01 data] # cd/backup/[root @ serv01 backup] # lltotal 18672-rw-r -- r --. 1 Root 19118080 Aug 2 2013dump01. dump [root @ serv01 backup] # rm-RF dump01.dump # first backup: Full backup [root @ serv01 backup] # dump-0 UF data01.dump/data/dump: date of this level 0 dump: Fri Aug 2 11:25:57 2013 dump: dumping/dev/sdb1 (/data) to data01.dump dump: Label: None dump: writing 10 kilobyte records dump: mapping (pass I) [regular files] Dump: Mapping (pass II) [directories] Dump: Estimated 18674 blocks. dump: Volume 1 started with Block 1 at: Fri Aug 2 11:25:57 2013 dump: dumping (pass III) [directories] Dump: dumping (pass IV) [regular files] Dump: closing data01.dump dump: Volume 1 completed at: Fri Aug 2 11:25:57 2013 dump: Volume 1 18670 blocks (18.23 MB) dump: 18670 blocks (18.23 MB) On 1 volume (s) dump: finished in less than a second dump: date of this level 0 dump: Fri Aug 2 11:25:57 2013 dump: date this dump completed: Fri Aug 2 11:25:57 2013 dump: Average transfer rate: 0 kb/s dump: dump is done [root @ serv01 backup] # lltotal 18672-rw-r-r -. 1 Root 19118080 Aug 2 data01.dump # copy the file to the data directory # second backup: incremental Backup [root @ serv01 backup] # cp/etc/inittab/data/[root @ serv01 backup] # dump-1 UF data02.dump/data/dump: date of this level 1 dump: Fri Aug 2 11:26:28 2013 dump: Date of last level 0 dump: Fri Aug 2 11:25:57 2013 dump: dumping/dev/sdb1 (/data) to data02.dump dump: Label: None dump: writing 10 kilobyte records dump: Mapping (pass I) [regular files] Dump: Mapping (pass II) [directories] Dump: estimated 55 blocks. dump: Volume 1 started with Block 1 at: Fri Aug 2 11:26:28 2013 dump: dumping (pass III) [directories] Dump: dumping (pass IV) [regular files] Dump: closing data02.dump dump: Volume 1 completed at: Fri Aug 2 11:26:28 2013 dump: Volume 1 50 blocks (0.05 MB) dump: 50 blocks (0.05 MB) On 1 volume (s) dump: finished in less than a second dump: date of this level 1 dump: Fri Aug 2 11:26:28 2013 dump: date this dump completed: Fri Aug 2 11:26:28 2013 dump: Average transfer rate: 0 kb/s dump: dump is done [root @ serv01 backup] # lltotal 18724-rw-r -- r --. 1 Root 19118080 Aug 2 11: 25 data01.dump-RW-r -- r -. 1 Root 51200 Aug 2 :26 data02.dump # copy the file again [root @ serv01 backup] # cp/etc/passwd/data/# The third backup: incremental Backup [root @ serv01 backup] # dump-2 UF data03.dump/data/dump: date of this level 2 dump: Fri Aug 2 11:27:07 2013 dump: Date of last level 1 dump: fri Aug 2 11:26:28 2013 dump: dumping/dev/sdb1 (/data) to data03.dump dump: Label: None dump: writing 10 kilobyte records dump: Mapping (pass I) [regular files] Dump: Mapping (pass II) [directories] Dump: estimated 55 blocks. dump: Volume 1 started with Block 1 at: Fri Aug 2 11:27:07 2013 dump: dumping (pass III) [directories] Dump: dumping (pass IV) [regular files] Dump: closing data03.dump dump: Volume 1 completed at: Fri Aug 2 11:27:07 2013 dump: Volume 1 50 blocks (0.05 MB) dump: 50 blocks (0.05 MB) On 1 volume (s) dump: finished in less than a second dump: date of this level 2 dump: Fri Aug 2 11:27:07 2013 dump: date this dump completed: Fri Aug 2 11:27:07 2013 dump: Average transfer rate: 0 kb/s dump: dump is done [root @ serv01 backup] # Cat/etc/dumpdates/dev/sdb1 0 Fri Aug 2 11:25:57 2013 + 0800/dev/sdb1 1 Fri Aug 2 11:26:28 2013 + 0800/ dev/sdb1 2 Fri Aug 2 11:27:07 2013 + 0800 # Fourth backup: incremental Backup [root @ serv01 backup] # dump-3 UF data04.dump/data/dump: date of this level 3 dump: Fri Aug 2 11:28:48 2013 dump: Date of last level 2 dump: fri Aug 2 11:27:07 2013 dump: dumping/dev/sdb1 (/data) to data04.dump dump: Label: None dump: writing 10 kilobyte records dump: Mapping (pass I) [regular files] Dump: Mapping (pass II) [directories] Dump: estimated 50 blocks. dump: Volume 1 started with Block 1 at: Fri Aug 2 11:28:48 2013 dump: dumping (pass III) [directories] Dump: dumping (pass IV) [regular files] Dump: closing data04.dump dump: Volume 1 completed at: Fri Aug 2 11:28:48 2013 dump: Volume 1 40 blocks (0.04 MB) dump: 40 blocks (0.04 MB) On 1 volume (s) dump: finished in less than a second dump: date of this level 3 dump: Fri Aug 2 11:28:48 2013 dump: date this dump completed: Fri Aug 2 11:28:48 2013 dump: Average transfer rate: 0 kb/s dump: dump is done [root @ serv01 backup] # Cat/etc/dumpdates/dev/sdb1 0 Fri Aug 2 11:25:57 2013 + 0800/dev/sdb1 1 Fri Aug 2 11:26:28 2013 + 0800/ dev/sdb1 2 Fri Aug 2 11:27:07 2013 + 0800/dev/sdb1 3 Fri Aug 2 11:28:48 2013 + 0800 # enter the data directory, simulate data loss [root @ serv01 backup] # cd/data [root @ serv01 data] # lsconfig-2.6.32-131.0.15.el6.x86_64 inittab symvers-2.6.32-131.0.15.el6.x86_64.gzinitramfs-2.6.32-131.0.15.el6.x86_64.img passwd vmlinuz-2.6.32-131.0.15.el6.x86_64 [root @ serv01 data] # rm-RF * [root @ serv01 data] # ls # restore data: level-1 recovery [root @ serv01 data] # restore-RF/backup/data01.dump [root @ serv01 data] # lsconfig-2.6.32-131.0.15.el6.x86_64 restoresymtable system. map-2.6.32-131.0.15.el6.x86_64initramfs-2.6.32-131.0.15.el6.x86_64.img symvers-2.6.32-131.0.15.el6.x86_64.gz vmlinuz-2.6.32-131.0.15.el6.x86_64 [root @ serv01 data] # restore-RF/backup/data03.dumprestore: Incremental tape too low [root @ serv01 data] # lsconfig-2.6.32-131.0.15.el6.x86_64 restoresymtable system. map-2.6.32-131.0.15.el6.x86_64initramfs-2.6.32-131.0.15.el6.x86_64.img symvers-2.6.32-131.0.15.el6.x86_64.gz vmlinuz-2.6.32-131.0.15.el6.x86_64 [root @ serv01 data] # restore-RF/backup/data02.dump [root @ serv01 data] # restore-RF/backup/data03.dump [root @ serv01 data] # restore- RF/backup/data04.dump [root @ serv01 data] # lsconfig-2.6.32-131.0.15.el6.x86_64 inittab restoresymtable vmlinuz-2.6.32-131.0.15.el6.x86_64initramfs-2.6.32-131.0.15.el6.x86_64.img passwd symvers-2.6.32-131.0.15.el6.x86_64.gz # recovery error: #1. the recovered data is incorrect: Check whether the mounting is correct #2. restore: the incremental tape too high is backed up multiple times at the same level, so this error is reported to check whether the/etc/dumpdates file and spelling are correct.

V. Dump and restore -- implement differential backup

# Demonstrate differential backup [root @ serv01 data] # cd/backup/[root @ serv01 backup] # rm-RF * [root @ serv01 backup] # rm-RF data01.dump [root @ serv01 backup] #>/etc/dumpdates # first, full backup [root @ serv01 backup] # dump-0 UF data01.dump/data/dump: date of this level 0 dump: Fri Aug 2 11:43:51 2013 dump: dumping/dev/sdb1 (/data) to data01.dump dump: Label: None dump: writing 10 kilobyte records dump: mapping (pass I) [regular files] Dump: Mapping (pass II) [directories] Dump: Estimated 16672 blocks. dump: Volume 1 started with Block 1 at: Fri Aug 2 11:43:51 2013 dump: dumping (pass III) [directories] Dump: dumping (pass IV) [regular files] Dump: closing data01.dump dump: Volume 1 completed at: Fri Aug 2 11:43:51 2013 dump: Volume 1 16680 blocks (16.29 MB) dump: 16680 blocks (16.29 MB) On 1 volume (s) dump: finished in less than a second dump: date of this level 0 dump: Fri Aug 2 11:43:51 2013 dump: date this dump completed: Fri Aug 2 11:43:51 2013 dump: Average transfer rate: 0 kb/s dump: dump is done [root @ serv01 backup] # Cat/etc/dumpdates/dev/sdb1 0 Fri Aug 2 11:43:51 2013 + 0800 # copy the fstab file [root @ serv01 backup] # cp/ etc/fstab/data/# differential backup [root @ serv01 backup] # dump-1 UF data02.dump/data/dump: date of this level 1 dump: Fri Aug 2 11:44:20 2013 dump: Date of last level 0 dump: Fri Aug 2 11:43:51 2013 dump: dumping/dev/sdb1 (/data) to data02.dump dump: Label: None dump: writing 10 kilobyte records dump: Mapping (pass I) [regular files] Dump: Mapping (pass II) [directories] Dump: estimated 55 blocks. dump: Volume 1 started with Block 1 at: Fri Aug 2 11:44:20 2013 dump: dumping (pass III) [directories] Dump: dumping (pass IV) [regular files] Dump: closing data02.dump dump: Volume 1 completed at: Fri Aug 2 11:44:20 2013 dump: Volume 1 50 blocks (0.05 MB) dump: 50 blocks (0.05 MB) On 1 volume (s) dump: finished in less than a second dump: date of this level 1 dump: Fri Aug 2 11:44:20 2013 dump: date this dump completed: Fri Aug 2 11:44:20 2013 dump: Average transfer rate: 0 kb/s dump: dump is done # copy yum. CONF file [root @ serv01 backup] # cp/etc/yum. conf/data [root @ serv01 backup] # dump-1ufdata021. dump/data/dump: date of this level 1 dump: Fri Aug 2 11:44:47 2013 dump: Date of last level 0 dump: Fri Aug 2 11:43:51 2013 dump: dumping/dev/sdb1 (/data) to data021.dump dump: Label: None dump: writing 10 kilobyte records dump: Mapping (pass I) [regular files] Dump: Mapping (pass II) [directories] Dump: estimated 60 blocks. dump: Volume 1 started with Block 1 at: Fri Aug 2 11:44:47 2013 dump: dumping (pass III) [directories] Dump: dumping (pass IV) [regular files] Dump: closing data021.dump dump: Volume 1 completed at: Fri Aug 2 11:44:47 2013 dump: Volume 1 60 blocks (0.06 MB) dump: 60 blocks (0.06 MB) On 1 volume (s) dump: finished in less than a second dump: date of this level 1 dump: Fri Aug 2 11:44:47 2013 dump: date this dump completed: Fri Aug 2 11:44:47 2013 dump: Average transfer rate: 0 kb/s dump: dump is done # copy an object, then differential backup [root @ serv01 backup] # cp/etc/networks/data [root @ serv01 backup] # dump-1ufdata0211. dump/data/dump: date of this level 1 dump: Fri Aug 2 11:45:34 2013 dump: Date of last level 0 dump: Fri Aug 2 11:43:51 2013 dump: dumping/dev/sdb1 (/data) to data0211.dump dump: Label: None dump: writing 10 kilobyte records dump: Mapping (pass I) [regular files] Dump: Mapping (pass II) [directories] Dump: estimated 65 blocks. dump: Volume 1 started with Block 1 at: Fri Aug 2 11:45:34 2013 dump: dumping (pass III) [directories] Dump: dumping (pass IV) [regular files] Dump: closing data0211.dump dump: Volume 1 completed at: Fri Aug 2 11:45:34 2013 dump: Volume 1 70 blocks (0.07 MB) dump: 70 blocks (0.07 MB) On 1 volume (s) dump: finished in less than a second dump: date of this level 1 dump: Fri Aug 2 11:45:34 2013 dump: date this dump completed: Fri Aug 2 11:45:34 2013 dump: Average transfer rate: 0 kb/s dump: dump is done # Delete the simulated data [root @ serv01 backup] # cd/data [root @ serv01 data] # rm-RF * # a full backup file and a file to be recovered are required during restoration. (or the last time ), only two [root @ serv01 data] # restore-RF/backup/data01.dump [root @ serv01 data] # restore-RF/backup/data021.dump [root @ serv01 data] # lsconfig-2.6.32-131.0.15.el6.x86_64 inittab symvers-2.6.32-131.0.15.el6.x86_64.gzfstab passwd vmlinuz-2.6.32-131.0.15.el6.x86_64initramfs-2.6.32-131.0.15.el6.x86_64.img restoresymtable yum. conf [root @ serv01 data] # rm-RF * [root @ serv01 data] # restore-RF/backup/data01.dump [root @ serv01 data] # restore-RF/backup/data0211.dump [root @ serv01 data] # lsconfig-2.6.32-131.0.15.el6.x86_64 inittab restoresymtable yum. conffstab networks symvers-2.6.32-131.0.15.el6.x86_64.gzinitramfs-2.6.32-131.0.15.el6.x86_64.img passwd vmlinuz-2.6.32-131.0.15.el6.x86_64 # differential backup: must be on the basis of full backup # dd NO Incremental backup function # disk copy (copy) [root @ serv01 backup] # cd/data/[root @ serv01 data] # ls [root @ serv01 data] # cp/boot /*. CP: omitting directory '/boot/EFI' CP: omitting directory '/boot/GRUB' CP: omitting directory '/boot/lost + found' [root @ serv01 data] # dd If =/dev/sdb1of =/dev/sdc1dd: writing to '/dev/sdc1 ': input/outputerror4192897 + 0 records in4192896 + 0 records out2146762752 bytes (2.1 GB) Copied, 71.3082 s, 30.1 Mb/s [root @ serv01 data] # DF-hfilesystem size used avail use % mounted on/dev/sda2 9.7g 1.1G 8.1g 12%/tmpfs 188 M 0 188 m 0%/dev /SHM/dev/sda1 194 m 25 m 160 m 14%/boot/dev/sda5 4.0g 137 m 3.7g 4%/opt/dev/sr0 3.4g 3.4g 0 100%/ISO /dev/sdb1 2.0g 54 m 1.9g 3%/data/dev/sdc1 2.0g 35 m 1.9g 2%/backup [root @ serv01 data] # ls/backup/config-2.6.32-131.0.15.el6.x86_64 symvers-2.6.32-131.0.15.el6.x86_64.gz vmlinuz-2.6.32-131.0.15.el6.x86_64initramfs-2.6.32-131.0.15.el6.x86_64.img system. map-2.6.32-131.0.15.el6.x86_64

6. Related Articles
  • Tar command and tar for full backup and Incremental Backup

My mailbox: wgbno27@163.com Sina Weibo: @ wentasy27 public platform: justoracle (No.: justoracle) database technology exchange group: 336882565 (when adding group verification from csdn XXX) Oracle Exchange discussion group: https://groups.google.com/d/forum/justoracleBy Larry Wen
 
@ Wentasy blog is for your reference only. Welcome to visit. I hope to criticize and correct any mistakes. If you need to repost the original blog post, please indicate the source. Thank you for the [csdn blog]

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.