ora-backup

1. 逻辑备份

05 01 * * * /home/oracle/oradmp.sh
[oracle@db ~]$ cat /home/oracle/oradmp.sh 
#!/bin/bash
D=$(date +%y%m%d%H%M);
export D;
export  ORACLE_HOME=/u01/oracle/product/11.2.0/dbhome_1;
export  NLS_LANG="AMERICAN_AMERICA.ZHS16GBK";
export  ORACLE_SID=db;
$ORACLE_HOME/bin/expdp  username/passwd  dumpfile=draftys_$D.dmp directory=data_path logfile=username_$D.log schemas=username
$ORACLE_HOME/bin/expdp  username/passwd  dumpfile=passwd_$D.dmp directory=data_path logfile=passwd_$D.log schemas=passwd
find  /home/oracle/dpdump/*  -ctime +15 -exec rm -rf {} \;


--使用操作系统命令直接删除备份集
find  /home/oracle/dpdump/*  -mtime +30 | xargs rm -f

2. 物理全备

#!/bin/bash
backuppath=/home/oracle/orabk
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
Logpath=${backuppath}/full_log
D=`date "+%Y%m%d"`
db_fullbak=${backuppath}/db_fullbak
archivelog_bak=${backuppath}/archivelog_bak
controlfile_bak=${backuppath}/controlfile_bak
spfile_bak=${backuppath}/spfile_bak
Logfile=${Logpath}/full_"$D".log
source  /home/oracle/.bash_profile
source /home/oracle/.bashrc
rman target / nocatalog log ${Logfile} append<

3. 物理增备

--level  0
#!/bin/bash

if [ -f ~/.bash_profile ];
then
        . ~/.bash_profile
fi

export ORACLE_BASE=/app/oracle
export ORACLE_HOME=/app/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=db
export NLS_LANG="Simplified Chinese_CHINA.ZHS16GBK"
export RMAN=$ORACLE_HOME/bin/rman

directory=`date +%F`
backtime=`date +%y%m%d%H%M`
c=`date +%y%m%d%H%M`
TODAY=`date`
export RMAN_LOG_FILE=/oracle/archlog/backup/$directory/log/bk0_$c.log
LOGPATH= /oracle/archlog/backup/$directory/log
if [ ! -d $LOGPATH ]; then
        mkdir -p   /oracle/archlog/backup/$directory/log
fi

echo "-----------------$TODAY-------------------">$RMAN_LOG_FILE
chmod 666 $RMAN_LOG_FILE

#--------------RMAN---------------

$RMAN nocatalog target / log=$RMAN_LOG_FILE append <$RMAN_LOG_FILE

chmod 666 $RMAN_LOG_FILE

$RMAN nocatalog target / log=$RMAN_LOG_FILE append <

你可能感兴趣的:(数据库)