以oracle用户登录系统:
1、创建数据库备份文件存放目录和日志存放目录
mkdir -p /workdb/oracle_backup
mkdir -p /workdb/oracle_backup_logs
2、创建备份脚本:
该脚本为每周日进行数据库全备,然后每天进行增量备份
vi /home/oracle/scripts/backuporacle.sh
内容如下:
#!/bin/sh
. $HOME/.bash_profile
backup_dir=/workdb/oracle_backup
backup_log_dir=/workdb/oracle_backup_logs
backup_date=`date +"%Y%m%d"`
backup_week=`date +"%w"`
ps -ef | grep dbw0_$ORACLE_SID | grep -v grep > /dev/null
if [ $? -eq 0 ]; then
if [ "$backup_week" = "0" ]; then
rman target=/ log=$backup_log_dir/fulldbbackup$backup_date.log < run {
backup database format '$backup_dir/fullbackup_%d_%T_%U';
sql 'alter system archive log current';
backup archivelog all delete all input format '$backup_dir/archbackup_%d_%T_%U';
backup current controlfile format '$backup_dir/ctlbackup_%d_%T_%U';
delete noprompt obsolete;}
exit;
EOF
else
rman target=/ log=$backup_log_dir/archbackup$backup_date.log < run {
backup archivelog all
format '$backup_dir/archbackup_%d_%T_%U' delete all input;}
exit;
EOF
fi
fi
3、修改脚本属性为可以执行:
chmod u+x /home/oracle/scripts/backuporacle.sh
4、修改备份参数:
rman target /
RMAN> configure controlfile autobackup on;
RMAN> configure controlfile autobackup format for device type disk to '/workdb/oracle_backup/controlfile_www_%F';
5、让脚本在晚上自动运行:
crontab -e
00 02 * * * /home/oracle/scripts/backuporacle.sh > /dev/null 2>&1
1、创建数据库备份文件存放目录和日志存放目录
mkdir -p /workdb/oracle_backup
mkdir -p /workdb/oracle_backup_logs
2、创建备份脚本:
该脚本为每周日进行数据库全备,然后每天进行增量备份
vi /home/oracle/scripts/backuporacle.sh
内容如下:
#!/bin/sh
. $HOME/.bash_profile
backup_dir=/workdb/oracle_backup
backup_log_dir=/workdb/oracle_backup_logs
backup_date=`date +"%Y%m%d"`
backup_week=`date +"%w"`
ps -ef | grep dbw0_$ORACLE_SID | grep -v grep > /dev/null
if [ $? -eq 0 ]; then
if [ "$backup_week" = "0" ]; then
rman target=/ log=$backup_log_dir/fulldbbackup$backup_date.log < run {
backup database format '$backup_dir/fullbackup_%d_%T_%U';
sql 'alter system archive log current';
backup archivelog all delete all input format '$backup_dir/archbackup_%d_%T_%U';
backup current controlfile format '$backup_dir/ctlbackup_%d_%T_%U';
delete noprompt obsolete;}
exit;
EOF
else
rman target=/ log=$backup_log_dir/archbackup$backup_date.log < run {
backup archivelog all
format '$backup_dir/archbackup_%d_%T_%U' delete all input;}
exit;
EOF
fi
fi
3、修改脚本属性为可以执行:
chmod u+x /home/oracle/scripts/backuporacle.sh
4、修改备份参数:
rman target /
RMAN> configure controlfile autobackup on;
RMAN> configure controlfile autobackup format for device type disk to '/workdb/oracle_backup/controlfile_www_%F';
5、让脚本在晚上自动运行:
crontab -e
00 02 * * * /home/oracle/scripts/backuporacle.sh > /dev/null 2>&1
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26194851/viewspace-1154824/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26194851/viewspace-1154824/