IT审计与灾备 4月24日 星期三 20:00 云祺视频号准时直播
vinchin linked
delta 扫码预约直播,观看精彩内容!
closed
logo
关于我们

技术分享

技术分享 数据备份--dump

数据备份--dump

2019-07-12

数据中 心操作大量的数据。当遭到破坏时,这就是一场灾难。这时候需要备份来恢复,及时你又大量的备份数据都没用,备份也肯定不是在浪费时间。你也许很幸运从 来没有经历过数据丢失。但是, 由于这种事情极少发生以及保持数据的完整性是非常重要的,通过跳过备份来“节省时间”和资源似乎是没有问题的。但是数据中心备份时非常重要的,IT从业人员都相信备份的价值并且尽最大努力进行适当的备份。

完全备份

完全备份就是完整地备份业务数据。例如周一用一盘磁带对整个业务系统进行备份,周二用另一个磁带队整个业务系统进行备份。

优点是:当数据发生 丢失时,只要用一盘磁带就可以恢复所有丢失的数据。

缺点是:由于每天进行数据完全备份,会造成大量的数据重复,占用了大量的磁带空间,增加了备份成本,如果数据量比较大,那么备份的时间也会比较长。


增量备份

增量备份是指在一次全备份或上一次增量备份后,以后每次的备份只需备份与前一次相比增加和者被修改的文件。这就意味着,第一次增量备份的对象是进行全备后所产生的增加和修改的文件;第二次增量备份的对象是进行第一次增量备份后所产生的增加和修改的文件。

优点就是:没有重复的备份数据,因此备份的数据量不大,备份所需的时间很短。

缺点是: 增量备份的数据恢复是比较麻烦的。必须具有上一次全备份和所有增量备份磁带(一旦丢失或损坏其中的一盘磁带,就会造成恢复的失败),并且它们必须沿着从全备份到依次增量备份的时间顺序逐个反推恢复,因此这就极大地延长了恢复时间。

差异备份是以完全为基准的一种备份方式。例如,系统管理员在星期天对系统进行以此完全备份,周一备份周日到周一的数据,周二备份周日到周二之间的数据,以此类推。

优点是:避免了以上两种备份策略的缺陷,同时又具有两者的优点。无需每天对系统做全量备份,因此备份数据量小,备份时间短,别且可以节约磁盘空间;其次在恢复数据时也很方便,只需要两个备份即可,即完全备份和灾难发生前一天的备份。

dump备份

使用dump备份的优点

1、备份可以跨多卷磁带;

2、备份可以是任何类型的文件,甚至可以是设备

3、备份时,文件的权限,属主,属组,修改时间等都会被保存;

4、能够正确处理从未包含任何数据的文件块;

5、能够做增量,差异备份。

安装dump

[root@localhost ~]# yum install -y dump

dump的基本用法

dump    -level     -u    -f     备份文件名     需要备份的对象

level表示备份的级别,0表示完全备份;1,表示当前和0比较的差异部分,2表示当前和1比较的差异部分。备份文件系统可以用的级别是0-9,而备份文件夹只能用0.如果每天做增量备份时,先选择级别0做完全备份,然后每天都使用同一大于0的级别就可以了,选择了1,就一直用1。

-u 将备份的时间记录到/etc/dumpuodates文件中,如果要使用增量或者差异备份方案,一定要使用-u选项,如果备份文件夹不能使用u选项

-f 指定备份生成的文件

-j或者-z 压缩备份

完全备份

dump -0u  -f  /tmp/baskup/full.dmp  /tmp/test

增量备份

dump -1u -f  /tmp/backup/add_001.dmp   /tmp/test

dump -2u -f  /tmp/backup/add_002.dmp   /tmp/test


查看备份文档中的文件和还原命令restore

-t  查看备份文件中的内容

-r 查看或者恢复整个文件系统

-f  要查看或恢复的备份文件


[root@localhost test]# dump -0u -f /test/boot.dump  /boot
  DUMP: Date of this level 0 dump: Tue Oct  8 08:57:45 2013
  DUMP: Dumping /dev/vda1 (/boot) to /test/boot.dump
  DUMP: Label: none
  ……………………
  DUMP: Volume 1 transfer rate: 18880 kB/s
  DUMP: 18880 blocks (18.44MB) on 1 volume(s)
  DUMP: finished in 1 seconds, throughput 18880 kBytes/sec
  DUMP: Date of this level 0 dump: Tue Oct  8 08:57:45 2013
  DUMP: Date this dump completed:  Tue Oct  8 08:57:46 2013
  DUMP: Average transfer rate: 18880 kB/s
  DUMP: DUMP IS DONE


[root@localhost test]# cd /etc/

[root@localhost etc]# cp passwd shadow /boot/
[root@localhost etc]# cd /boot/
[root@localhost boot]# ls
config-2.6.32-71.el6.x86_64
efi
grub
initramfs-2.6.32-71.el6.x86_64.img
lost+found
passwd
shadow
symvers-2.6.32-71.el6.x86_64.gz
System.map-2.6.32-71.el6.x86_64
vmlinuz-2.6.32-71.el6.x86_64

[root@localhost boot]# dump -u1 -f /test/add_001.dump /boot

再创建几个文件,然后继续备份

[root@localhost boot]# touch test1
[root@localhost boot]# touch test2
[root@localhost boot]# touch test3
[root@localhost boot]# touch test4
[root@localhost boot]# touch test5
[root@localhost boot]# ls
config-2.6.32-71.el6.x86_64
efi
grub
initramfs-2.6.32-71.el6.x86_64.img
lost+found
passwd
shadow
symvers-2.6.32-71.el6.x86_64.gz
System.map-2.6.32-71.el6.x86_64
test1
test2
test3
test4
test5
vmlinuz-2.6.32-71.el6.x86_64

[root@localhost boot]# dump -u2 -f /test/add_002.dump /boot


[root@localhost boot]# cd /test/
[root@localhost test]# ls
add_001.dump  add_002.dump  boot.dump

使用命令restore查看备份文件里面的内容

[root@localhost test]# restore -tf /test/boot.dump 
Dump   date: Tue Oct  8 08:57:45 2013
Dumped from: the epoch
Level 0 dump of /boot on localhost.localdomain:/dev/vda1
Label: none
         2  .
        11  ./lost+found
     65025  ./grub
     65031  ./grub/grub.conf
     65026  ./grub/splash.xpm.gz
     65032  ./grub/menu.lst
     65033  ./grub/device.map
     65034  ./grub/stage1
     65035  ./grub/stage2
     65036  ./grub/e2fs_stage1_5
     65037  ./grub/fat_stage1_5
     65038  ./grub/ffs_stage1_5
     65039  ./grub/iso9660_stage1_5
     65040  ./grub/jfs_stage1_5
     65041  ./grub/minix_stage1_5
     65042  ./grub/reiserfs_stage1_5
     65043  ./grub/ufs2_stage1_5
     65044  ./grub/vstafs_stage1_5
     65045  ./grub/xfs_stage1_5
     65027  ./efi
     65028  ./efi/EFI
     65029  ./efi/EFI/redhat
     65030  ./efi/EFI/redhat/grub.efi
        12  ./.vmlinuz-2.6.32-71.el6.x86_64.hmac
        13  ./System.map-2.6.32-71.el6.x86_64
        14  ./config-2.6.32-71.el6.x86_64
        15  ./symvers-2.6.32-71.el6.x86_64.gz
        16  ./vmlinuz-2.6.32-71.el6.x86_64
        17  ./initramfs-2.6.32-71.el6.x86_64.img


[root@localhost test]# restore -tf /test/add_001.dump 
Dump   date: Tue Oct  8 09:00:42 2013
Dumped from: Tue Oct  8 08:57:45 2013
Level 1 dump of /boot on localhost.localdomain:/dev/vda1
Label: none
         2  .
        18  ./passwd
        19  ./shadow


[root@localhost test]# restore -tf /test/add_002.dump查看增量备份的内容
Dump   date: Tue Oct  8 09:02:58 2013
Dumped from: Tue Oct  8 09:00:42 2013
Level 2 dump of /boot on localhost.localdomain:/dev/vda1
Label: none
         2  .
        20  ./test1
        21  ./test2
        22  ./test3
        23  ./test4
        24  ./test5

现在我把自己的/boot/下的东西全都删除,尝试恢复一下

[root@localhost test]# rm -rf /boot/*   删除所有文件
[root@localhost test]# cd /boot/
[root@localhost boot]# ls
[root@localhost boot]# 

恢复数据

[root@localhost boot]# restore -rf /test/boot.dump  首先恢复到完全备份
[root@localhost boot]# ls
config-2.6.32-71.el6.x86_64
efi
grub
initramfs-2.6.32-71.el6.x86_64.img
lost+found
restoresymtable
symvers-2.6.32-71.el6.x86_64.gz
System.map-2.6.32-71.el6.x86_64
vmlinuz-2.6.32-71.el6.x86_64


[root@localhost boot]# restore -rf /test/add_001.dump  恢复第一次的增量备份
[root@localhost boot]# ls
config-2.6.32-71.el6.x86_64
efi
grub
initramfs-2.6.32-71.el6.x86_64.img
lost+found
passwd
restoresymtable
shadow
symvers-2.6.32-71.el6.x86_64.gz
System.map-2.6.32-71.el6.x86_64
vmlinuz-2.6.32-71.el6.x86_64

[root@localhost boot]# restore -rf /test/add_002.dump  恢复第二次的增量备份
[root@localhost boot]# ls
config-2.6.32-71.el6.x86_64
efi
grub
initramfs-2.6.32-71.el6.x86_64.img
lost+found
passwd
restoresymtable
shadow
symvers-2.6.32-71.el6.x86_64.gz
System.map-2.6.32-71.el6.x86_64
test1
test2
test3
test4
test5
vmlinuz-2.6.32-71.el6.x86_64

这样就可以实现最基本的全量和增量备份了,当然restore数据还可以实现恢复备份文件中的部分文件的功能,也就是restore的交互模式


现在我只想恢复add_002.dmp中的test2,test3文件



[root@localhost boot]# restore -if /test/add_002.dump  ------------>进入交互模式的参数是if
restore > ?          ------------> 查看当前模式下可以使用的命令
Available commands are:
        ls [arg] - list directory
        cd arg - change directory
        pwd - print current directory
        add [arg] - add `arg' to list of files to be extracted
        delete [arg] - delete `arg' from list of files to be extracted
        extract - extract requested files
        setmodes - set modes of requested directories
        quit - immediately exit program
        what - list dump header information
        verbose - toggle verbose flag (useful with ``ls'')
        prompt - toggle the prompt display
        help or `?' - print this list
If no `arg' is supplied, the current directory is used

restore > ls   --------->列出所有可以恢复的文件
.:
test1 test2 test3 test4 test5

restore > add test2 test3  -------------> 添加需要恢复的文件
restore > ls  -------------> ls的结果中带*的就是要恢复的文件
.:
 test1 *test2 *test3  test4  test5


restore > extract  --------------开始恢复
You have not read any volumes yet.
Unless you know which volume your file(s) are on you should start
with the last volume and work towards the first.
Specify next volume # (none if no more volumes): 1  -----------------表示是在一个磁盘中
set owner/mode for '.'? [yn] n --------------不改变文件的权限
restore > quit--------结束退出交互模式
[root@localhost boot]# ls
config-2.6.32-71.el6.x86_64         shadow
efi                                 symvers-2.6.32-71.el6.x86_64.gz
grub                                System.map-2.6.32-71.el6.x86_64
initramfs-2.6.32-71.el6.x86_64.img  test2
lost+found                          test3
passwd                              vmlinuz-2.6.32-71.el6.x86_64
restoresymtable

上述整个过程就是一个完整备份和增量备份的例子,供大家参考一下

云祺备份软件,云祺容灾备份系统,虚拟机备份,数据库备份,文件备份,实时备份,勒索软件,美国,图书馆
  • 标签:
  • 网络安全

您可能感兴趣的新闻 换一批

现在下载,可享30天免费试用

立即下载