Oracle定时任务备份脚本

Linux
备份
#!/bin/bash
export ORACLE_SID=orcl
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export ORACLE_BASE=/u01/app/oracle
su - oracle -c “expdp admin/admin123 directory=dump dumpfile=xxx_date +%Y%m%d%H%M.dmp logfile=xxx_log_date +%Y%m%d%H%M.log schemas=xxx”

删除
#!/bin/bash
dumpdir="/u01/dump"
find $dumpdir -type f -name “.dmp" -mtime +5 -exec rm -rf {} ;
find $dumpdir -type f -name "
.log” -mtime +5 -exec rm -rf {} ;

定时任务
[oracle@orcldb script]$ crontab -l
0 22 * * * /bin/bash /home/oracle/script/orabak.sh >/dev/null 2>&1
0 02 * * * /bin/bash /home/oracle/script/oradel.sh >/dev/null 2>&1

Windows
备份
echo oracle database backup begins…
set dt=%DATE%
set FILE_NAME="%dt:0,4%%dt:5,2%%dt:~8,2%"
echo %FILE_NAME%
D:
cd D:\expdpbackup
expdp xxx/11111 dumpfile=xxx_%FILE_NAME%.dmp directory=expdpbackup schemas=xxx log=xxx_%FILE_NAME%.log

echo Del file 2 days ago:::::::::
forfiles /P D:\expdpbackup /M *.dmp /S /D -2 /C “cmd /c del /F /s /q @file”
forfiles /P D:\expdpbackup /M *.log /S /D -2 /C “cmd /c del /F /s /q @file”

你可能感兴趣的:(11g)