dump [Suvj] [-level] [-f 备份文件] 待备份数据
常见参数:
-level 0-9,备份等级,0表示最完整备份,指定0以上的等级,则为增量备份;
-f 文件名 指定那个备份之后的文件名
-S 仅列出后面待备份数据需要多少磁盘空间可以备份完毕;
-u 将这次dump的时间记录到/etc/dumpdares文件中;
-v 将dump的文件过程显示出来;
-j 加入bzip2的支持!将数据进行压缩,默认bzip2的压缩等级为2;
-W 列出在/etc/fstab里面的具有dump设置的分区是否有备份过;
1、查询磁盘空间,找容量较小的boot分区进行测试
[root@localhost /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 4.7G 555M 3.9G 13% /
tmpfs 931M 0 931M 0% /dev/shm
/dev/sda1 190M 27M 154M 15% /boot
/dev/sda3 4.7G 9.9M 4.5G 1% /data
/dev/sda7 5.5G 806M 4.4G 16% /usr
/dev/sda5 3.8G 99M 3.5G 3% /var
2、第一次等级0完全备份/boot分区并压缩
[root@localhost /]# dump -0uj -f /root/boot.bak.bz2 /boot/
DUMP: Date of this level 0 dump: Mon Aug 6 15:48:07 2018
DUMP: Dumping /dev/sda1 (/boot) to /root/boot.bak.bz2
DUMP: Date this dump completed: Mon Aug 6 15:48:13 2018
DUMP: Average transfer rate: 3853 kB/s
DUMP: Wrote 25670kB uncompressed, 23123kB compressed, 1.111:1
DUMP: DUMP IS DONE
3、查看备份时间文件
[root@localhost /]# cat /etc/dumpdates
/dev/sda1 0 Mon Aug 6 15:48:07 2018 +0800
4、找一个文件复制到boot分区以便测试增量备份
[root@localhost ~]# ll -h
总用量 23M
-rw-------. 1 root root 1.1K 7月 13 22:28 anaconda-ks.cfg
-rw-r--r--. 1 root root 23M 8月 6 15:48 boot.bak.bz2
-rw-r--r--. 1 root root 7.9K 7月 13 22:28 install.log
-rw-r--r--. 1 root root 3.4K 7月 13 22:28 install.log.syslog
[root@localhost ~]# cp install.log /boot/
5、第二次等级1增量备份/boot分区并压缩
[root@localhost ~]# dump -1uj -f /root/boot.bak1.bz2 /boot/
DUMP: Date of this level 1 dump: Mon Aug 6 15:51:49 2018
DUMP: Date of last level 0 dump: Mon Aug 6 15:48:07 2018
DUMP: Dumping /dev/sda1 (/boot) to /root/boot.bak1.bz2
DUMP: Date this dump completed: Mon Aug 6 15:51:49 2018
DUMP: Average transfer rate: 0 kB/s
DUMP: Wrote 40kB uncompressed, 13kB compressed, 3.077:1
DUMP: DUMP IS DONE
6、发现第二次备份只有14k,说明只备份了差异部分
[root@localhost ~]# ll -h
总用量 23M
-rw-------. 1 root root 1.1K 7月 13 22:28 anaconda-ks.cfg
-rw-r--r--. 1 root root 14K 8月 6 15:51 boot.bak1.bz2
-rw-r--r--. 1 root root 23M 8月 6 15:48 boot.bak.bz2
-rw-r--r--. 1 root root 7.9K 7月 13 22:28 install.log
7、查询各发分区的备份时间与备份级别
[root@localhost ~]# dump -W
Last dump(s) done (Dump '>' file systems):
> /dev/sda2 ( /) Last dump: never
/dev/sda1 ( /boot) Last dump: Level 1, Date Mon Aug 6 15:51:49 2018
> /dev/sda3 ( /data) Last dump: never
> /dev/sda7 ( /usr) Last dump: never
> /dev/sda5 ( /var) Last dump: never
restore [模式选项] [选项]
模式选项:
-C 使用对比模式,将备份的文件与现行的文件相互对比。
-i 使用互动模式,在进行还原操作时,restore指令将依序询问用户。
-t 查看模式,用于查看备份文件中拥有哪些数据
-r 进行还原操作。
选项:
-f 指定备份文件的文件名
1、修改一个文件名测试对比模式
[root@localhost boot]# mv vmlinuz-2.6.32-642.el6.x86_64 vmlinuz-2.6.32-642.el6.x86_64.bak
[root@localhost boot]# restore -C -f /root/boot.bak.bz2
Dump tape is compressed.
Dump date: Mon Aug 6 15:48:07 2018
Dumped from: the epoch
Level 0 dump of /boot on localhost.localdomain:/dev/sda1
Label: none
filesys = /boot
restore: unable to stat ./vmlinuz-2.6.32-642.el6.x86_64: No such file or directory
Some files were modified! 1 compare errors
2、查看模式
[root@localhost /]# restore -t -f /root/boot.bak.bz2
Dump tape is compressed.
Dump date: Mon Aug 6 15:48:07 2018
Dumped from: the epoch
Level 0 dump of /boot on localhost.localdomain:/dev/sda1
Label: none
2 .
11 ./lost+found
12 ./grub
40 ./grub/grub.conf
13 ./grub/splash.xpm.gz
25 ./grub/menu.lst
26 ./grub/device.map
18 ./vmlinuz-2.6.32-642.el6.x86_64
23 ./initramfs-2.6.32-642.el6.x86_64.img
3、建立新目录以便分级恢复模式
[root@localhost /]# mkdir /bootbak
[root@localhost /]# cd /bootbak/
[root@localhost bootbak]# restore -r -f /root/boot.bak.bz2
Dump tape is compressed.
[root@localhost bootbak]# ls
config-2.6.32-642.el6.x86_64 initramfs-2.6.32-642.el6.x86_64.img symvers-2.6.32-642.el6.x86_64.gz
efi lost+found System.map-2.6.32-642.el6.x86_64
grub restoresymtable vmlinuz-2.6.32-642.el6.x86_64
[root@localhost bootbak]# restore -r -f /root/boot.bak1.bz2
Dump tape is compressed.
[root@localhost bootbak]# ls
config-2.6.32-642.el6.x86_64 install.log System.map-2.6.32-642.el6.x86_64
efi lost+found vmlinuz-2.6.32-642.el6.x86_64
grub restoresymtable
initramfs-2.6.32-642.el6.x86_64.img symvers-2.6.32-642.el6.x86_64.gz