Dump backup
Restore
Dd Data Backup
Create a mkisofs Image File
Dump backup
Dump is mainly used to back up a real file system backup. Although it can also back up a single directory, it does not provide sufficient support for the directory. We recommend that you back up a single directory by packing and compressing it.
Dump another function is to set the level, that is, Incremental Backup can be performed.
Dump levels are divided into 0 ~ 9: 10 levels. 0 indicates full backup, 1 indicates Incremental Backup Based on 0, and so on.
When the data to be backed up is a single file system
Level 0 ~ 9. Back up data and use the full dump function.
When the data to be backed up is only a directory, it is not a single file system
Restrictions:
All backup data must be in this directory
Only level 0 can be used for data backup
The-u parameter is not supported, that is, the/etc/dumpdates level backup time record file cannot be created
Syntax: dump [-Suvj] [-level] [-f backup file] data to be backed up
Dump-W
Options and parameters:
-S: only list the disk space required for data backup to be completed.
-U: record this backup to the/etc/dumpdates file.
-V: displays the dump file process.
-J: added support for bzip2 to compress data. The default compression level is 2.
-Level: Backup grade 0 ~ 9
-F: Backup File
-W: List whether the partitions with dump settings have been backed up in/etc/fstab.
Example 1: Mount backup to/boot file system level-0
[Root @ localhost ~] # Dump-S/boot16752640 [root @ localhost ~] # Dump-u-0-f/root/boot. dump.0/boot DUMP: Date of this level 0 dump: Fri Feb 28 15:05:56 2014 DUMP: Dumping/dev/sda1 (/boot) to/root/boot. dump.0 DUMP: Label:/boot DUMP: Writing 10 Kilobyte records DUMP: mapping (Pass I) [regular files] DUMP: mapping (Pass II) [directories] DUMP: estimated 16360 blocks. DUMP: Volume 1 started with block 1 at: Fri Feb 28 15:05:56 2014 DUMP: dumping (Pass III) [Directories] DUMP: dumping (Pass IV) [regular files] DUMP: Closing/root/boot. dump.0 DUMP: Volume 1 completed at: Fri Feb 28 15:05:58 2014 DUMP: Volume 1 16440 blocks (16.05 MB) DUMP: Volume 1 took 0:00:02 DUMP: Volume 1 transfer rate: 8220 kB/s DUMP: 16440 blocks (16.05 MB) on 1 volume (s) DUMP: finished in 2 seconds, throughput 8220 kBytes/sec DUMP: Date of this level 0 dump: fri Feb 28 15:05:56 2 014 DUMP: Date this dump completed: Fri Feb 28 15:05:58 2014 DUMP: Average transfer rate: 8220 kB/s DUMP: dump is done [root @ localhost ~] # Cat/etc/dumpdates/dev/sda1 0 Fri Feb 28 15:05:56 2014 + 0800 => You Can See That etc/dumpdates records the backup information.
Example 2: view the backup records of the file system
[Root @ localhost ~] # Dump-WLast dump (s) done (Dump '> 'file systems):>/dev/sda2 (/) Last dump: never>/dev/sda3 (/home) last dump: never/dev/sda1 (/boot) Last dump: Level 0, Dat>/dev/sda6 (/mnt/sda6) Last dump: never => we can see that sda1 has been backed up by level0, and others have not yet been backed up.
Example 3: Incremental Backup level 1
[Root @ localhost ~] # Dd if =/dev/zero of =/boot/bigfile. img bs = 1 M count = 2020 + 0 records in20 + 0 records out20971520 bytes (21 MB) copied, 0.320717 seconds, 65.4 MB/s => first create a file about 20 mb [root @ localhost ~] # Dump-u-1-f/root/boot. dump.1/boot DUMP: Date of this level 1 dump: Fri Feb 28 15:17:51 2014 DUMP: Date of last level 0 dump: Fri Feb 28 15:05:56 2014 DUMP: dumping/dev/sda1 (/boot) to/root/boot. dump.1 DUMP: Label:/boot DUMP: Writing 10 Kilobyte records DUMP: mapping (Pass I) [regular files] DUMP: mapping (Pass II) [directories] DUMP: estimated 20543 blocks. DUMP: Volume 1 started with bloc K 1 at: Fri Feb 28 15:17:52 2014 DUMP: dumping (Pass III) [directories] DUMP: dumping (Pass IV) [regular files] DUMP: Closing/root/boot. dump.1 DUMP: Volume 1 completed at: Fri Feb 28 15:17:53 2014 DUMP: Volume 1 20580 blocks (20.10 MB) DUMP: Volume 1 took 0:00:01 DUMP: Volume 1 transfer rate: 20580 kB/s DUMP: 20580 blocks (20.10 MB) on 1 volume (s) DUMP: finished in 1 seconds, throughput 20580 kByte S/sec DUMP: Date of this level 1 dump: Fri Feb 28 15:17:51 2014 DUMP: Date this dump completed: Fri Feb 28 15:17:53 2014 DUMP: Average transfer rate: 20580 kB/s DUMP: dump is done [root @ localhost ~] # Cat/etc/dumpdates/dev/sda1 0 Fri Feb 28 15:05:56 2014 + 0800/dev/sda1 1 Fri Feb 28 15:17:51 2014 + 0800 => This configuration is written to the backup record [root @ localhost ~] # Dump-WLast dump (s) done (Dump '> 'file systems):>/dev/sda2 (/) Last dump: never>/dev/sda3 (/home) last dump: never/dev/sda1 (/boot) Last dump: Level 1, Date Fri Feb 28 15:17:51 2014>/dev/sda6 (/mnt/sda6) Last dump: never [root @ localhost ~] # Ll/root/boot *-rw-r -- 1 root 16834560 02-28/root/boot. dump.0-rw-r -- 1 root 21073920 02-28 15:17/root/boot. dump.1 => boot. dump.1 is about 20 mb in size. It can be seen that it is an incremental backup.
Example 4: backing up a single directory
[root@localhost ~]# dump -0 -f /root/etc.dump /etc DUMP: Date of this level 0 dump: Fri Feb 28 15:23:39 2014 DUMP: Dumping /dev/sda2 (/ (dir etc)) to /root/etc.dumpDUMP: Label: / DUMP: Writing 10 Kilobyte records DUMP: mapping (Pass I) [regular files] DUMP: mapping (Pass II) [directories] DUMP: estimated 177675 blocks. DUMP: Volume 1 started with block 1 at: Fri Feb 28 15:23:41 2014 DUMP: dumping (Pass III) [directories] DUMP: dumping (Pass IV) [regular files] DUMP: Closing /root/etc.dump DUMP: Volume 1 completed at: Fri Feb 28 15:24:23 2014 DUMP: Volume 1 188600 blocks (184.18MB) DUMP: Volume 1 took 0:00:42 DUMP: Volume 1 transfer rate: 4490 kB/s DUMP: 188600 blocks (184.18MB) on 1 volume(s) DUMP: finished in 42 seconds, throughput 4490 kBytes/sec DUMP: Date of this level 0 dump: Fri Feb 28 15:23:39 2014 DUMP: Date this dump completed: Fri Feb 28 15:24:23 2014 DUMP: Average transfer rate: 4490 kB/s DUMP: DUMP IS DONE[root@localhost ~]# ll /root/etc.dump -rw-r--r-- 1 root root 193126400 02-28 15:24 /root/etc.dump
Restore
The dump backup file is restored by the restore.
Syntax:
View the dump file: restore-t [-f dumpfile] [-h]
Compare dump with the actual file: restore-C [-f dumpfile]-D mount point
Enter interaction mode (restore a single file): restore-I [-f dumpfile]
Restore the entire file system: restore-r [-f dumpfile]
Options and parameters:
Different models cannot be mixed. For example, you cannot write-tC
-T: This mode is used to check the important data contained in the dump backup file! Similar to the tar-t function;
-C: In this mode, the data in dump can be taken out and compared with the actual file system. In the end, files with records in the dump file are listed, which are different from those in the current file system;
-I: In interactive mode, only some files can be restored and used to restore the dump directory.
-R: A mode for restoring the entire filesystem. It is used to restore the dump backup for the file system;
Other commonly used options:
-H: View inode, file system label, and other information in the complete backup data.
-F: The dump file you want to process
-D: Works with-C to check whether the mount point to be followed is different from that in dump.
Example 1: view the dump backup file
[root@localhost ~]# restore -t -f /root/boot.dump.0Dump date: Fri Feb 28 15:05:56 2014Dumped from: the epochLevel 0 dump of /boot on localhost.localdomain:/dev/sda1Label: /boot 2 . 11 ./lost+found 10041 ./grub 10059 ./grub/grub.conf……. 14 ./System.map-2.6.18-371.el5 15 ./config-2.6.18-371.el5 16 ./symvers-2.6.18-371.el5.gz 17 ./vmlinuz-2.6.18-371.el5
Example 2: Compare file differences
[root@localhost ~]# mv /boot/message /boot/message-back[root@localhost ~]# restore -C -f /root/boot.dump.0 -D /bootDump date: Fri Feb 28 15:05:56 2014Dumped from: the epochLevel 0 dump of /boot on localhost.localdomain:/dev/sda1Label: /bootfilesys = /bootrestore: unable to stat ./message: No such file or directorySome files were modified! 1 compare errors
Example 3: Restore the entire file system
[Root @ localhost ~] # Dd if =/dev/zero of =/home/newfile bs = 1 M count = 200200 + 0 records in200 + 0 records out209715200 bytes (210 MB) copied, 3.83857 seconds, 54.6 MB/s [root @ localhost ~] # Mkfs-t ext3/home/newfile mke2fs 1.39 (29-May-2006)/home/newfile is not a block special device ....... 180 days, whichever comes first. Use tune2fs-c or-I to override. [root @ localhost ~] # Mount-o loop/home/newfile/mnt [root @ localhost ~] # Df-H file system capacity in use % available mount point/dev/sda2 9.5G 4.4G 4.7G 49% G 4.8/dev/sda3 339G 4.2 M 8% G/home/dev /sda1 99 M 42 M 53 M 45%/boottmpfs 1014 M 0 1014 M 0%/dev/shm/home/newfile 194 M 5.6 M 179 M 4%/mnt => create a file Mount go to [root @ localhost ~] Under mnt # Cd/mnt [root @ localhost mnt] # restore-r-f/root/boot. dump.0restore :. /lost + found: file exists [root @ localhost mnt] # ll total 16149-rw-r -- r -- 1 root 70400 10-01 config-2.6.18-371.el5drwxr-xr-x 2 root 1024 02-18 grub-rw ------- 1 root 2748313 02-18 initrd-2.6.18-371.el5.imgdrwx ------ 2 root 12288 02-14 lost + found-rw-r -- 1 root 80032 message-rw ------- 1 root 27676 02-28 restoresymtable-rw-r -- 1 root 117436 10-01 symvers-2.6.18-371.el5.gz-rw-r -- r -- 1 root 996296 10-01 System. map-2.6.18-371.el5-rw-r -- r -- 1 root 10485760 02-28 testing. img-rw-r -- 1 root 1912148 10-01 vmlinuz-2.6.18-371.el5 => restore level 0 backup [root @ localhost mnt] # restore-r-f/root/boot. dump.1 [root @ localhost mnt] # ll Total Bytes 11-rw-r -- r -- 1 root 20971520 02-28 bigfile. img-rw-r -- 1 root 70400 10-01 config-2.6.18-371.el5drwxr-xr-x 2 root 1024 02-18 grub-rw ------- 1 root 2748313 02-18 initrd-2.6.18-371.el5.imgdrwx ------ 2 root 12288 02-14 lost + found-rw-r -- 1 root 80032 message -------- 1 root 27724 02-28 restoresymtable-rw-r -- 1 root 117436 10-01 symvers-2.6.18-371.el5.gz-rw-r -- r -- 1 root 996296 10-01 System. map-2.6.18-371.el5-rw-r -- r -- 1 root 10485760 02-28 testing. img-rw-r -- 1 root 1912148 10-01 vmlinuz-2.6.18-371.el5 => restore level 1 backup can see more bigfile. img incremental file
Dd
Dd is not only used to create files, but also "backup", cp, and dump are simple file data copies. dd can read all the content of the device, such as superblock, boot sector, mete data, etc.
Syntax: dd if = "input file" of = "output file" bs = "block" count = "number"
Options and parameters:
If: input file or device
Of: output file or device
Bs: the size of each block. The default value is 512 KB.
Count: number of blocks
Example 1. file backup
[root@localhost ~]# dd if=~/.bashrc of=/tmp/bashrc 0+1 records in0+1 records out176 bytes (176 B) copied, 7.3142e-05 seconds, 2.4 MB/s[root@localhost ~]# ll /tmp/bashrc -rw-r--r-- 1 root root 176 02-28 16:17 /tmp/bashrc
Example 2: File System Backup
[root@localhost ~]# dd if=/dev/sda1 of=/tmp/boot.dd bs=1M 101+1 records in101+1 records out106896384 bytes (107 MB) copied, 9.60492 seconds, 11.1 MB/s[root@localhost ~]# ll /tmp/boot.dd-rw-r--r-- 1 root root 106896384 02-28 16:19 /tmp/boot.dd
Example 3: File System Restoration
[Root @ localhost ~] # Dd if =/tmp/boot. dd of =/dev/sda1 bs = 1 M
Example 4. Complete File System Replication
During Dump backup, we need to first back up the file system with Dump, then create a new file system, format it, And then restore the backup file to the new file system.
You can use dd to completely copy a file system without formatting, because dd copies uperblock, boot sector, mete data, and other information. Isn't formatting exactly the same?
[Root @ bogon ~] # Fdisk/dev/sda ....... Command (m for help): n ...... Command (m for help): P ...... Device Boot Start End Blocks Id System/dev/sda1 * 1 13 104391 83 Linux ...... /Dev/sda7 2116 2134 152586 83 LinuxCommand (m for help): w ...... [Root @ bogon ~] # Partprobe => after the partition is created, [root @ bogon ~] # Dd if =/dev/sda1 of =/dev/sda7 208782 + 0 records in208782 + 0 records outparts 896384 bytes (107 MB) copied, 23.5363 seconds, 4.5 MB/s [root @ bogon ~] # Mount/dev/sda7/mnt [root @ bogon ~] # Ll/mnt total 5838-rw-r -- r -- 1 root 70400 10-01 config-2.6.18-371.el5drwxr-xr-x 2 root 1024 02-18 grub-rw ------- 1 root 2748762 02-27 initrd-2.6.18-371.el5.imgdrwx ------ 2 root 12288 02-19 lost + found-rw-r -- 1 root 80032 message-rw-r -- 1 root 117436 10-01 symvers-2.6.18-371.el5.gz-rw-r -- r -- 1 root 996296 10-01 System. map-2.6.18-371.el5-rw-r -- r -- 1 root 1912148 10-01 vmlinuz-2.6.18-371.el5 =>/mnt and/boot contents are the same and not formatted
Mkisofs (backup of image files)
Syntax: mkisofs [-o image file] [-rv] [-m file] file to be backed up [-V vol]-graft-point isodir = sysdir
Options and parameters:
-O: Image File
-R: Generate file data supported by UNIX/Linux
-V: displays the ISO building process.
-M: excluded files
-V: volume label name
-Graft-point: Directory Control name. If this parameter is not specified, the information will be kept in the root directory.
Example:
[root@bogon ~]# mkisofs -o /tmp/system.img -r -m /home/lost+found -V 'tkf_file' -graft-point /root=/root /home=/home /etc=/etc[root@bogon ~]# mount -o loop /tmp/system.img /mnt[root@bogon ~]# ll /mntdr-xr-xr-x 114 root root 34816 03-01 14:31 etcdr-xr-xr-x 3 root root 2048 03-01 14:31 homedr-xr-xr-x 18 root root 4096 03-01 14:31 root