数据备份--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的交互模式,这个,后面做完实验再补充。
数据备份--dump的更多相关文章
- 数据备份--dump(此作者有许多有用的博客文章)
数据中 心操作大量的数据.当遭到破坏时,这就是一场灾难.这时候需要备份来恢复,及时你又大量的备份数据都没用,备份也肯定不是在浪费时间.你也许很幸运从 来没有经历过数据丢失.但是, 由于这种事情极少发生 ...
- MySQL基础之第16章 数据备份与还原
16.1.数据备份 16.1.1.使用 mysqldump 命令备份 mysqldump [OPTIONS] database [tables]mysqldump [OPTIONS] --databa ...
- MYSQL数据备份与还原学习笔记
数据备份与还原 1.mysqldump 1.1 文件地址: E:\xampp\mysql\bin 文件名:mysqldump.exe CMD下进入mysqldump.exe cd E:\xampp ...
- MySQL数据备份之mysqldump使用(转)
mysqldump常用于MySQL数据库逻辑备份. 1.各种用法说明 A. 最简单的用法: mysqldump -uroot -pPassword [database name] > [dump ...
- MySQL(十五)之数据备份中mysqldump详解
前言 其实前面一篇数据备份已经是非常的详细了,这里我想单独的讲解一下mysqldump,相信很多程序员都是用过这个命令的! 一.MySQL数据库的备份与还原 1.1.MySQL数据库备份 1)语法 m ...
- Redis数据持久化、数据备份、数据的故障恢复
1.redis持久化的意义----redis故障恢复 在实际的生产环境中,很可能会遇到redis突然挂掉的情况,比如redis的进程死掉了.电缆被施工队挖了(支付宝例子)等等,总之一定会遇到各种奇葩的 ...
- Linux服务器数据备份恢复策略
一.Linux 备份恢复基础 1.什么是备份 最简单的讲,备份数据的过程就是拷贝重要的数据到其他的介质之上(通常是可移动的),以保证在原始数据丢失的情况下可以恢复数据.一次备份可能是简单的 cp命令, ...
- MySQL数据库----IDE工具介绍及数据备份
一.IDE工具介绍 生产环境还是推荐使用mysql命令行,但为了方便我们测试,可以使用IDE工具 下载链接:https://pan.baidu.com/s/1bpo5mqj 二.MySQL数据备份 # ...
- mysql 数据备份及数据迁移
一.使用mysql数据导出进行备份时,会备份整个表的数据,有时候只想备份一部分数据,这个时候可以使用如下方法: 1. 使用insert into 和 select结合: insert into tal ...
随机推荐
- json-lib-2.4.jar Bug,json字符串中value为"[value]"结构时,解析为数组,不会解析成字符串
使用json-lib.jar 2.4进行json字符串转换为对象时发现一个bug.贴下测试代码: <dependency> <groupId>net.sf.json-lib&l ...
- xamarin android——数据绑定到控件(一)
mono for android 中光标由ICursor 接口标识,该接口公开了操作结果数据集的所有方法.光标的使用非常消耗系统资源,所以不使用时应该光比光标.可以通过StartManagingCur ...
- Servlet、Filter 生命周期
Servlet作为JavaEE必须掌握的内容,Struts2通过使用Filter的功能实现了一个MVC的框架.因此掌握这Servlet以及Filter的生命周期显得非常重要. 1. Servlet的生 ...
- php三维数组去重(示例代码)
php三维数组去重的示例代码. 假设叫数组 $my_array; <?php // 新建一个空的数组. $tmp_array = array(); $new_array = array(); ...
- leetcode学习笔记--开篇
1 LeetCode是什么? LeetCode是一个在线的编程测试平台,国内也有类似的Online Judge平台.程序开发人员可以通过在线刷题,提高对于算法和数据结构的理解能力,夯实自己的编程基础. ...
- 2、[转]WPF与WinForm的比较
http://www.cnblogs.com/KnightsWarrior/archive/2010/07/09/1774059.htmlhttp://www.cnblogs.com/zenghong ...
- oracle 绿色版本 instantclient 使用说明
1,将instantclient直接放到D盘根目录 2,注册表修改 3,点击工具>>首选项, 在Oracle主目录名中输入“D:\instantclient_10_2\”,在OCI库中输入 ...
- [译] ASP.NET 生命周期 – ASP.NET 应用生命周期(一)
概述 ASP.NET 平台定义了两个非常重要的生命周期.第一个是 应用生命周期 (application life cycle),用来追踪应用从启动的那一刻到终止的那一刻.另一个就是 请求生命周期 ...
- html 页面 ajax 方法显示遮罩
showLoading.css 样式: ;;list-style-type:none;} a,img{;} .overlay{;;;;;width:100%;height:100%;_padding: ...
- EXTJS 4.2 资料 控件之btn设置可否点击
1.下面是一个btn按钮的代码,默认不可以点击 { id: 'skipStep3', disabled: true,//默认不可点击 text: "跳转第三步", handler: ...