步骤:
1>写shell脚本;
$ less rman_fullbackup.sh
######RMAN Backup begin #######
cd /d10/fullbackup/
mkdir `date +%Y%m%d`
cd `date +%Y%m%d`
rman catalog rman/rman target sys/oracle@prod cmdfile /d10/scripts/rman_fullbac
kup.sql log /d10/scripts/rman_fullbackup.log
####RMAN Backup end #######
######RMAN Backup begin #######
cd /d10/fullbackup/
mkdir `date +%Y%m%d`
cd `date +%Y%m%d`
rman catalog rman/rman target sys/oracle@prod cmdfile /d10/scripts/rman_fullbac
kup.sql log /d10/scripts/rman_fullbackup.log
####RMAN Backup end #######
2>写rman备份脚本;
$ less rman_fullbackup.sql
run
{ allocate channel node1 type disk;
set limit channel node1 kbytes =2000000;
sql 'alter system archive log current';
backup format '/d10/fullbackup/full%n%s%p%t' (database include current controlfi
le);
backup format '/d10/fullbackup/arch%n%s%p' (archivelog all delete all input);
release channel node1;
}
run
{ allocate channel node1 type disk;
set limit channel node1 kbytes =2000000;
sql 'alter system archive log current';
backup format '/d10/fullbackup/full%n%s%p%t' (database include current controlfi
le);
backup format '/d10/fullbackup/arch%n%s%p' (archivelog all delete all input);
release channel node1;
}
3>写crontab执行计划
30 0 * * 1,3,5 /d10/scripts/fullbackup.sh
每个星期1,3,5的00:30am执行脚本命令
问题点:
1>crontab -e进行编写执行计划时,无法退出保存(先按ESC键,再输入:wq)
解决方法:
在oracle用户主目录(home)下修改.profile文件,加入下面两条命令,保存退出即可。
EDITOR=vi
export EDITOR
export EDITOR
2>crontab无法执行
解决方法:
1>crontab中调用的shell文件是否有执行权限;
chmod 755 test1.sh
2>crontab中调用的shell文件的宿主是否正确;
chown oracle:dba test1.sh (假设数据库用户为oracle)
3>cron.allow或cron.deny是否有增加针对oracle用户的允许或限制;