全备
run{
allocate channel c1 device type disk;
backup database format '/app/oracle/backup/full_%d_%T_%s_%p.bak';
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
backup archivelog all delete input format '/app/oracle/backup/full_arch_%d_%T_%s_%p.bak';
backup current controlfile format '/app/oracle/backup/full_controlfile_%U';
backup spfile format '/app/oracle/backup/full_spfile_%d_%T_%s_%p.bak';
release channel c1;
}
备份归档脚本
#!/bin/bash
#script.:Backuparch.sh
#creater:llf
#date:2022-1-13
#desc:backup incremental 1 database datafile in archive with rman
#connect database
backtime=`date +"%Y_%m_%d_%T"`
v_date=`date +%Y%m%d`
mkdir -p /PGBACKUP/orcltest_backup/$v_date/arch
export ORACLE_SID=orcltest1
export ORACLE_BASE=/app/oracle
export ORACLE_HOME=/app/product/11.2.0/db
$ORACLE_HOME/bin/rman target / log /PGBACKUP/orcltest_backup/$v_date/arch/rman_archivelog_$backtime.log << EOF
RUN {
allocate channel c1 device type disk;
allocate channel c2 device type disk;
sql 'ALTER SYSTEM CHECKPOINT';
sql 'alter system archive log current';
sql 'alter system archive log current';
backup as backupset archivelog all format '/PGBACKUP/orcltest_backup/$v_date/arch/arc0_%U_%d_%T_%I_%s' delete all input tag='ARC';
delete noprompt archivelog all completed before 'sysdate-12/24';
crosscheck archivelog all;
delete expired archivelog all;
backup current controlfile format '/PGBACKUP/orcltest_backup/$v_date/_arch/ctl_%u_%T.bak' tag='CTL';
}
EOF
增备
#!/bin/bash
#script.:Backuparch.sh
#creater:llf
#date:2022-1-13
#desc:backup incremental 1 database datafile in archive with rman
#connect database
backtime=`date +"%Y_%m_%d_%T"`
v_date=`date +%Y%m%d`
mkdir -p /PGBACKUP/orcltest_backup/$v_date/arch
export ORACLE_SID=orcltest1
export ORACLE_BASE=/app/oracle
export ORACLE_HOME=/app/product/11.2.0/db
$ORACLE_HOME/bin/rman target / log /PGBACKUP/orcltest_backup/$v_date/arch/rman_archivelog_$backtime.log << EOF
RUN {
allocate channel c1 device type disk;
allocate channel c2 device type disk;
sql 'ALTER SYSTEM CHECKPOINT';
sql 'alter system archive log current';
sql 'alter system archive log current';
backup as backupset archivelog all format '/PGBACKUP/orcltest_backup/$v_date/arch/arc0_%U_%d_%T_%I_%s' delete all input tag='ARC';
delete noprompt archivelog all completed before 'sysdate-12/24';
crosscheck archivelog all;
delete expired archivelog all;
backup current controlfile format '/PGBACKUP/orcltest_backup/$v_date/_arch/ctl_%u_%T.bak' tag='CTL';
}
EOF