rman备份例子

1.全备份例子

#!/bin/sh

RMAN_OUTPUT_LOG=/home/oracle/rman_output.log
RMAN_ERROR_LOG=/home/oracle/rman_error.log
rman target / log=/home/oracle/rman_output.log<<EOF
run
{
allocate channel ch1 device type disk;
backup full database format '/home/oracle/rman_bakckup/db_fullbackup_%d_%s_%p_%T';
backup current controlfile format '/home/oracle/rman_bakckup/ctl_%d_%s_%p_%T';
backup archivelog all format '/home/oracle/rman_bakckup/arch_%d_%s_%p_%T';

backup spfile format '/home/oracle/rman_bakckup/backup/spfile_%d_%s_%p_%T';
release channel ch1;
}
EOF

 

#!/bin/sh

RMAN_OUTPUT_LOG=/home/oracle/rman_output.log
RMAN_ERROR_LOG=/home/oracle/rman_error.log
rman target / << EOF 1>>$RMAN_OUTPUT_LOG 2>>$RMAN_ERROR_LOG
run
{
allocate channel ch1 device type disk;
backup full database format '/home/oracle/rman_bakckup/db_fullbackup_%d_%s_%p_%T';
backup current controlfile format '/home/oracle/rman_bakckup/ctl_%d_%s_%p_%T';
backup archivelog all format '/home/oracle/rman_bakckup/arch_%d_%s_%p_%T';

backup spfile format '/home/oracle/rman_bakckup/backup/spfile_%d_%s_%p_%T';
release channel ch1;
}
EOF

 

2.压缩备份

 

##非归档备份数据库
rman target / <<EOF
run
{
allocate channel ch1 device type disk;
backup as compressed backupset full filesperset 5 database format '/home/oracle/rman_bakckup/db_fullbackup_%d_%s_%p_%T';
backup current controlfile format '/home/oracle/rman_bakckup/ctl_%d_%s_%p_%T';
backup spfile format '/home/oracle/rman_bakckup/spfile_%d_%s_%p_%T';
release channel ch1;
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
}
EOF

 

3.压缩备份数据文件和归档日志文件

[oracle@cyz-server scripts]$ more rman_backup.sh
#!/bin/sh
backup_date=`date +%Y-%m-%d`

rman target / log=/home/oracle/scripts/logs/rmanbackup_log_${backup_date}.log<<EOF
run
{
allocate channel ch1 device type disk;
backup as compressed backupset full filesperset 5 database format '/home/oracle/rman_backup/db_fullbackup_%d_%s_%p_%T';
sql 'alter system archive log current';
backup as compressed backupset archivelog all delete input format '/home/oracle/rman_backup/arch_%d_%s_%p_%T';
backup current controlfile format '/home/oracle/rman_backup/ctl_%d_%s_%p_%T';
backup spfile format '/home/oracle/rman_backup/spfile_%d_%s_%p_%T';
release channel ch1;
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
}
EOF

 

posted @ 2019-01-09 19:25  slnngk  阅读(242)  评论(0编辑  收藏  举报