数据备份--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 ...
随机推荐
- zookeeper 安装
Zookeeper安装 一. 下载zookeeper http://www.apache.org/dist/zookeeper/stable/ 二. 解压zookeeper.tar >& ...
- 接收串口数据0x00 strlen函数会截断
写个串口接收程序接收到之后,用了一个上strlen,结果数据不全了,百度了下 strlen所作的仅仅是一个计数器的工作,它从内存的某个位置(可以是字符串开头,中间某个位置,甚至是某个不确定的内存区域) ...
- 删除缓存内容----unrecognized selector sent to instance
这条错误主要还得看unrecognized前面,,我的时[NSNumber-length...]其实是变量类型错误.. 无法识别选择器发送实例,,本来意思就是你的controllerview找不到视图 ...
- VS QT 配置OpenGL
在visual studio 下编译OpenGL代码出现以下错误,原因是vs没有自带opengl库,需要自己引入 无法解析的外部符号 __imp__glClear@4 无法解析的外部符号 __imp_ ...
- [置顶] IT屌丝的离职申请
各位好,很遗憾在如此关键的时刻和大家说告别.我为金三也付出了近一年的心血,几乎没怎么休过令人舒心的周末,熬了多少夜更不用说,如此的离开,请相信我也非常心痛. 尽管直到现在我的水 ...
- cocos2d-x游戏开发系列教程-超级玛丽08-消息机制
在超级玛丽游戏里,地图类CMGameMap负责所有的程序逻辑,它包含了背景地图,包含了游戏元素精灵,当游戏中的精灵之间发生碰撞时,比如马里奥撞上砖头这种事情发生时,马里奥对象本身不知道怎么处理这个逻辑 ...
- linux配置nfs服务
简单介绍: unix/linux系统一种远程文件文件夹共享的服务,能够把某一个远程的文件文件夹共享到本地,进而像操作本地文件一样,操作这个远程的文件夹. 比如:a主机作为服务端,共享出来test1这个 ...
- ASP.NET站点安全
<configuration> <appSettings/> <connectionStrings> <add name="MyBookShop&q ...
- DZNEmptyDataSet框架简介
给大家推荐一个设置页面加载失败时显示加载失败等的框架. 下载地址:DZNEmptyDataSet https://github.com/dzenbot/DZNEmptyDataSet 上效果首先在你的 ...
- c++ 虚析构函数[避免内存泄漏]
c++ 虚析构函数: 虚析构函数(1)虚析构函数即:定义声明析构函数前加virtual 修饰, 如果将基类的析构函数声明为虚析构函数时,由该基类所派生的所有派生类的析构函数也都自动成为虚析构函数. ...