Linux ORCLE數(shù)據(jù)庫增量備份腳本
更新時間:2009年11月20日 17:57:19 作者:
Linux下ORCLE數(shù)據(jù)庫增量備份腳本 (基礎篇) ,需要的朋友可以參考下。
ORCLE數(shù)據(jù)庫備份策略
1.通過使用exp和imp命令實現(xiàn)數(shù)據(jù)庫導出和導入。
有三種模式:
a. 用戶模式: 導出(導入)用戶所有對象以及對象中的數(shù)據(jù);
b. 表模式: 導出(導入)用戶所有表或者指定的表;
c. 整個數(shù)據(jù)庫: 導出(導入)數(shù)據(jù)庫中所有對象。
如:
普通導出
a.導出一個完整數(shù)據(jù)庫
exp system/manager file=f.dmp full=y
b.導出數(shù)據(jù)庫定義而不導出數(shù)據(jù)
exp system/manager file=f.dmp full=y rows=n
普通導入:
a.完全導入
imp system/manager file=f.dmp full=y
b.數(shù)據(jù)庫結構存在時,只導入數(shù)據(jù)
imp system/manager file=f.dmp full=y ignore=y
2.每周進行數(shù)據(jù)庫備份,以防數(shù)據(jù)庫被意外破壞后恢復數(shù)據(jù)
安排如下:
周一: 完全備份(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
比如數(shù)據(jù)庫在周日被破壞,則可用以下方式恢復:
1.創(chuàng)建空的數(shù)據(jù)庫,同之前的結構。
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
說明:
完全導出:對整個數(shù)據(jù)庫的備份
增量導出:是備份上一次完全導出后改變的數(shù)據(jù)。
累積導出:是備份自上次完全導出后改變的數(shù)據(jù)。
EXAMPLE:LINUX下備份數(shù)據(jù)庫
BACKUP_DIR=/home/oracle/backups
if [ ! -d $BACKUP_DIR ]; then
mkdir -p $BACKUP_DIR
fi
DAYS=(Sun Mon Tue Wed Thu Fri Sat) #創(chuàng)建數(shù)組
TYPES=(incremental complete incremental incremental incremental cumulative incremental)
day=`date +%w` #取得本周天數(shù),0代表周日,1代表周一
DAY_NAME=${DAYS[$day]} #取得數(shù)組的值
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 #刪除七天前更改過的文件
1.通過使用exp和imp命令實現(xiàn)數(shù)據(jù)庫導出和導入。
有三種模式:
a. 用戶模式: 導出(導入)用戶所有對象以及對象中的數(shù)據(jù);
b. 表模式: 導出(導入)用戶所有表或者指定的表;
c. 整個數(shù)據(jù)庫: 導出(導入)數(shù)據(jù)庫中所有對象。
如:
普通導出
a.導出一個完整數(shù)據(jù)庫
exp system/manager file=f.dmp full=y
b.導出數(shù)據(jù)庫定義而不導出數(shù)據(jù)
exp system/manager file=f.dmp full=y rows=n
普通導入:
a.完全導入
imp system/manager file=f.dmp full=y
b.數(shù)據(jù)庫結構存在時,只導入數(shù)據(jù)
imp system/manager file=f.dmp full=y ignore=y
2.每周進行數(shù)據(jù)庫備份,以防數(shù)據(jù)庫被意外破壞后恢復數(shù)據(jù)
安排如下:
周一: 完全備份(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
比如數(shù)據(jù)庫在周日被破壞,則可用以下方式恢復:
1.創(chuàng)建空的數(shù)據(jù)庫,同之前的結構。
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
說明:
完全導出:對整個數(shù)據(jù)庫的備份
增量導出:是備份上一次完全導出后改變的數(shù)據(jù)。
累積導出:是備份自上次完全導出后改變的數(shù)據(jù)。
EXAMPLE:LINUX下備份數(shù)據(jù)庫
BACKUP_DIR=/home/oracle/backups
if [ ! -d $BACKUP_DIR ]; then
mkdir -p $BACKUP_DIR
fi
DAYS=(Sun Mon Tue Wed Thu Fri Sat) #創(chuàng)建數(shù)組
TYPES=(incremental complete incremental incremental incremental cumulative incremental)
day=`date +%w` #取得本周天數(shù),0代表周日,1代表周一
DAY_NAME=${DAYS[$day]} #取得數(shù)組的值
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 #刪除七天前更改過的文件
相關文章
Win7 64環(huán)境下Oracle10g 64位版本安裝教程
這篇文章主要為大家詳細介紹了Win7 64環(huán)境下Oracle10g 64位版本安裝教程,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-03-03
Oracle?exadata存儲節(jié)點更換內(nèi)存操作及報錯處理方法
在進行Oracle?Exadata巡檢時,發(fā)現(xiàn)cell節(jié)點內(nèi)存報錯,需確認內(nèi)存PN號及大小,并更換備件,這篇文章主要介紹了Oracle?exadata存儲節(jié)點更換內(nèi)存操作及報錯處理的相關資料,需要的朋友可以參考下2024-10-10
使用geotools導入shp文件到Oracle數(shù)據(jù)庫時表名帶下劃線問題的解決方法
這篇文章主要介紹了使用geotools導入shp文件到Oracle數(shù)據(jù)庫時表名帶下劃線的問題解決 的相關資料,需要的朋友可以參考下2016-08-08
oracle 9i使用閃回查詢恢復數(shù)據(jù)庫誤刪問題
本篇文章給大家介紹在oracle 9i中使用閃回查詢恢復數(shù)據(jù)庫誤刪問題,涉及到數(shù)據(jù)庫增刪改查的基本操作,對oracle數(shù)據(jù)庫閃回查詢感興趣的朋友可以一起學習下本篇文章2015-10-10

