回到三国粤语版,后妈没有拒绝我,塔机网
orcle数据库备份策略
1.通过使用exp和imp命令实现数据库导出和导入。
有三种模式:
a. 用户模式: 导出(导入)用户所有对象以及对象中的数据;
b. 表模式: 导出(导入)用户所有表或者指定的表;
c. 整个数据库: 导出(导入)数据库中所有对象。
如:
普通导出
a.导出一个完整数据库
exp system/manager file=f.dmp full=y
b.导出数据库定义而不导出数据
exp system/manager file=f.dmp full=y rows=n
普通导入:
a.完全导入
imp system/manager file=f.dmp full=y
b.数据库结构存在时,只导入数据
imp system/manager file=f.dmp full=y ignore=y
2.每周进行数据库备份,以防数据库被意外破坏后恢复数据
安排如下:
周一: 完全备份(f1) exp xxx/xxx inctype=complete file=f1.dmp
周二: 增量备份(f2) exp xxx/xxx inctype=incremental file=f2.dmp
周三: 增量备份(f3) exp xxx/xxx inctype=incremental file=f3.dmp
周四: 增量备份(f4) exp xxx/xxx inctype=incremental file=f4.dmp
周五: 累积备份(f5) exp xxx/xxx inctype=cumulative file=f5.dmp
周六: 增量备份(f6) exp xxx/xxx inctype=incremental file=f6.dmp
周日: 增量备份(f7) exp xxx/xxx inctype=incremental file=f7.dmp
比如数据库在周日被破坏,则可用以下方式恢复:
1.创建空的数据库,同之前的结构。
2.imp xxx/xxx inctype=restore full=y file=f1.dmp
3.imp xxx/xxx inctype=restore full=y file=f5.dmp
4.imp xxx/xxx inctype=restore full=y file=f6.dmp
说明:
完全导出:对整个数据库的备份
增量导出:是备份上一次完全导出后改变的数据。
累积导出:是备份自上次完全导出后改变的数据。
example:linux下备份数据库
backup_dir=/home/oracle/backups
if [ ! -d $backup_dir ]; then
mkdir -p $backup_dir
fi
days=(sun mon tue wed thu fri sat) #创建数组
types=(incremental complete incremental incremental incremental cumulative incremental)
day=`date +%w` #取得本周天数,0代表周日,1代表周一
day_name=${days[$day]} #取得数组的值
type=${types[$day]}
date_name=`date +%f`
file_name=${date_name}-${day_name}-${type}.dmp #2008-12-8-mon-complete.dmp
exp xxx/xxx inctype=$type file=${backup_dir}/${file_name} > /dev/null
gzip ${backup_dir}/${file_name}
find $backup_dir -mtime +7 -delete #删除七天前更改过的文件
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!!
点击进行留言回复
相关文章:
-
-
-
-
-
-
快速向表插入大量数据
当需要对一个非常大的表INSERT的时候,会消耗非常多的资源,因为update表的时候,oracle需要生成 redo log和undo log;此时最...
[阅读全文]
-
-
-
Oracle入门学习五
学习视频: https://www.bilibili.com/video/BV1tJ411r7EC?p=55 数据的完整性:保证插入表格的数据必须正确。...
[阅读全文]
-
Oracle入门学习六
事务:把一组操作看做一个工作单元,要么都执行,要么都不执行。dml操作才有事务,查询没有事务。 开始事务:从上一次的事务结束之后,从第一次dml操作,就...
[阅读全文]
-
网友评论