数据备份--dump(此作者有许多有用的博客文章)
数据中 心操作大量的数据。当遭到破坏时,这就是一场灾难。这时候需要备份来恢复,及时你又大量的备份数据都没用,备份也肯定不是在浪费时间。你也许很幸运从 来没有经历过数据丢失。但是, 由于这种事情极少发生以及保持数据的完整性是非常重要的,通过跳过备份来“节省时间”和资源似乎是没有问题的。但是数据中心备份时非常重要的,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
上述整个过程就是一个完整备份和增量备份的例子,供大家参考一下
http://blog.csdn.net/avilifans/article/details/12418013
数据备份--dump(此作者有许多有用的博客文章)的更多相关文章
- CSDN博客文章的备份及导出电子书CHM
需要用到的工具集合下载:http://download.csdn.net/source/2881423 在CSDN.百度等写博客文章的应该很多,很多时候担心服务器有一天突然挂了,或者担心自己的号被封了 ...
- 数据备份--dump
数据中 心操作大量的数据.当遭到破坏时,这就是一场灾难.这时候需要备份来恢复,及时你又大量的备份数据都没用,备份也肯定不是在浪费时间.你也许很幸运从 来没有经历过数据丢失.但是, 由于这种事情极少发生 ...
- 收藏了一篇很有用的博客 “npm的安装教程”
暂时贴上这一篇博客的地址,感谢原作者 https://www.cnblogs.com/goldlong/p/8027997.html 使用之前,我们先来掌握3个东西是用来干什么的. npm: Node ...
- Typecho博客转移服务器,数据备份.
目录 Typecho博客转移服务器,数据备份. 简述操作(有基础的mjj看这个简述就可以了.) 详细步骤(建议小白来看, 已经在很多详细方面进行说明了.) 备份篇 备份导入与数据库转移篇 重新部署ty ...
- Django博客开发-数据建模与样式设定
开发流程介绍 之前Django的学习过程当中已经把基本Django开发学完了,现在以Django 的博客项目完成一遍课程的回顾和总结.同时来一次完整开发的Django体验. 一个产品从研究到编码我们要 ...
- 推荐一款自己的软件作品[豆约翰博客备份专家],新浪博客,QQ空间,CSDN,cnblogs博客备份,导出CHM,PDF(转载)
推荐一款自己的软件作品[豆约翰博客备份专 豆约翰博客备份专家是完全免费,功能强大的博客备份工具,博客电子书(PDF,CHM和TXT)生成工具,博文离线浏览工具,软件界面美观大方,支持多个主流博客网站( ...
- Django----博客文章数据返回
步骤1:新建视图函数 from django.shortcuts import render from django.http import HttpResponse; from blog.model ...
- Linux下使用 github+hexo 搭建个人博客06-next主题接入数据统计
之前说了 next 主题的优化和接入评论系统.让我们完成了自己所需的页面风格和排版,也可让访问用户在每篇博文评论,完成博主和访问用户的交互. 本章我们继续讲解其他重要功能. 既然是一个网站,那么我们就 ...
- Java使用Jsoup之爬取博客数据应用实例
导入Maven依赖 <!-- https://mvnrepository.com/artifact/org.jsoup/jsoup --> <dependency> <g ...
随机推荐
- python成长之路15
一:JavaScript: JavaScript是一门编程语言,浏览器内置了JavaScript语言的解释器,所以在浏览器上按照JavaScript语言的规则编写相应代码之,浏览器可以解释并做出相应的 ...
- hdu 4465 Candy 2012 成都现场赛
/** 对于大数的很好的应用,,缩小放大,,保持精度 **/ #include <iostream> #include <cmath> #include <algorit ...
- (Problem 28)Number spiral diagonals
Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is forme ...
- 教你怎么用Mono Cecil - 动态注入 (注意代码的注释)
原文 教你怎么用Mono Cecil - 动态注入 (注意代码的注释) 使用 Mono Cecil 进行反编译:using Mono.Cecil; using Mono.Cecil.Cil; //.. ...
- Android Camera调用过程分析
源代码版本:allwinner 4.0.4 frameworks代码: frameworks/base/core/java/android/hardware/Camera.java JNI层代码: f ...
- Internet Explorer 11(IE11)无法切换第三方输入法
Windows 8.1搭载了新的IE11版本,还发布了IE11 for Windows 7. IE11除了支持全尺寸Win设备以外,还比IE10更快速流畅,支持3D等高性能的浏览体验.全新F12开发者 ...
- 如何使用W5300实现ADSL连接(一)
在介绍W5300连接ADSL之前,先给大家简单介绍一下WIZnet W5300这款芯片. W5300是WIZnet公司的一款单芯片器件,采用0.18μmCMOS工艺,内部集成10/100M以太网控制器 ...
- 【第三方SDK】百度地图实现最简单的定位功能(无地图界面)
在近期的项目中,须要实现无地图界面的定位功能,定位用户所在的城市.因此,本篇文章,主要介绍怎样使用百度地图SDK实现无导航界面的定位功能. 1.申请百度开发人员账户 2.创建应用,获取key 例如以下 ...
- HDU 4720 Naive and Silly Muggles (外切圆心)
Naive and Silly Muggles Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- C++_01_入门
一.类的定义 Person.h类声明 Person.cpp类实现 main.cpp主函数 二.命名空间的使用 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv ...