linux oracle 的定时恢复和备份

1.exp导出
#!/bin/sh
ORACLE_HOME=/opt/oracle/product/9.2.0.4;export ORACLE_HOME
ORACLE_BASE=/opt/oracle;export ORACLE_BASE
ORACLE_SID=ilearndb;export ORACLE_SID
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib;export LD_LIBRARY_PATH
PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH;export PATH
rq=`date +%y_%m_%d_%H_%M_%S `
echo $rq
exp test/test file=/opt/oracle/backup/temp/examusr01_$rq.dmp log=/opt/oracle/backup/logs/bkplog_$rq owner=ilearn
exp test/test file=/opt/oracle/backup/temp/examusr02_$rq.dmp log=/opt/oracle/backup/logs/bkplog2_$rq owner=ilearn_rpt
tar -cvzf /opt/oracle/backup/temp/examusr01_$rq.tar.gz /opt/oracle/backup/temp/examusr01_$rq.dmp&&rm -f /opt/oracle/backup/temp/examusr01_$rq.dmp&&echo "Congratulations,your dmp file has been compressed correctly at $rq!" >> /opt/oracle/backup/logs/bkplog_$rq.log
tar -cvzf /opt/oracle/backup/temp/examusr02_$rq.tar.gz /opt/oracle/backup/temp/examusr02_$rq.dmp&&rm -f /opt/oracle/backup/temp/examusr02_$rq.dmp&&echo "Congratulations,your dmp file has been compressed correctly at $rq!" >> /opt/oracle/backup/logs/bkplog2_$rq.log
exit 0
2.本机备份+ftp异地备份
#!/bin/sh
ftp -n<open 10.10.140.87
user test test
binary
hash
cd /opt/oracle/racexambkp
lcd /opt/oracle/backup/temp
prompt
mput *
close
bye
!
mv /opt/oracle/backup/temp/* /opt/oracle/backup/
3.恢复
IMP log=/opt/oracle/plsimp.log file=/opt/oracle/examusr01_09_01_20_10_10_58.dmp userid=test/test@testdb_10.10.140.87 fromuser=test touser=test buffer=30720 commit=yes grants=yes ignore=no indexes=yes rows=yes show=yes constraints=yes
4.定时
corntab -e
corntab -l
41 17 * * * /opt/oracle/ora_bak.sh >>/opt/oracle/bak.txt
44 17 * * * /opt/oracle/move.sh >> /opt/oracle/move.txt
4.注意事项
exp的时候,用那个用户导入就用那个用户导出,操作方便。
ftp的时候,一定要开服务。
imp的时候,一定要给imp_full_databse权限,注意字符集
crontab的时候,注意环境变量。
imp的时候如果跳过表:
IGNORE=Y ,这样就不会跳过那些表了!
show= yes ,去掉!
NLS_LANG=AMERICAN_AMERICA.UTF8

exp的时候
如果有警报
NLS_LANG=AMERICAN_AMERICA.UTF8


[img]http://dl.iteye.com/upload/attachment/209204/a2cb6ca7-23a8-3452-8be8-29a7dfbaded3.gif[/img]

[img]http://dl.iteye.com/upload/attachment/209216/b7af5c86-e4ab-3568-937f-d4f681230de9.gif[/img]

[img]http://dl.iteye.com/upload/attachment/209216/b7af5c86-e4ab-3568-937f-d4f681230de9.gif[/img]

你可能感兴趣的:(database)