1、全量备份
#!/bin/bash
export ORACLE_SID=ynsb1;
export ORACLE_HOME=/u01/app/oracle/product/19.0.0.0/dbhome_1;
export RECORD_TIME=$(date +%y%m%d%H%M%S);
find /backup/rmandata/ -name "level_0_*.log" -mtime +15 -exec rm {} \;
/u01/app/oracle/product/19.0.0.0/dbhome_1/bin/rman log=/backup/rmandata/level_0_$RECORD_TIME.log append <<EOF
connect target sys/ynsb_2022_adminsys@YNSBBKP
run
{
allocate channel c1 type disk maxpiecesize=20G;
allocate channel c2 type disk maxpiecesize=20G;
allocate channel c3 type disk maxpiecesize=20G;
allocate channel c4 type disk maxpiecesize=20G;
allocate channel c5 type disk maxpiecesize=20G;
allocate channel c6 type disk maxpiecesize=20G;
allocate channel c7 type disk maxpiecesize=20G;
allocate channel c8 type disk maxpiecesize=20G;
backup as compressed backupset incremental level 0 database format='/backup/rmandata/ynsb_full_l0_%U.BKU' tag='ynsb_lev_0_$RECORD_TIME';
sql 'alter system archive log current';
backup as compressed backupset archivelog all tag='arc_bak_$RECORD_TIME' format='/backup/rmandata/arch_%U_%T' not backed up 1 times;
backup current controlfile tag='ctlfile_bak_$RECORD_TIME' format='/backup/rmandata/ctl_file_%U_%T';
backup spfile tag='spfile_bak_$RECORD_TIME' format='/backup/rmandata/spfile_%U_%T';
}
crosscheck backup of archivelog all;
delete noprompt obsolete;
exit;
EOF
2、增量备份
#!/bin/bash
export ORACLE_SID=ynsb1;
export ORACLE_HOME=/u01/app/oracle/product/19.0.0.0/dbhome_1;
export RECORD_TIME=$(date +%y%m%d%H%M%S);
find /backup/rmandata/ -name "level_1_*.log" -mtime +15 -exec rm {} \;
/u01/app/oracle/product/19.0.0.0/dbhome_1/bin/rman log=/backup/rmandata/level_1_$RECORD_TIME.log append <<EOF
connect target sys/ynsb_2022_adminsys@YNSBBKP
run
{
allocate channel c1 type disk maxpiecesize=20G;
allocate channel c2 type disk maxpiecesize=20G;
allocate channel c3 type disk maxpiecesize=20G;
allocate channel c4 type disk maxpiecesize=20G;
allocate channel c5 type disk maxpiecesize=20G;
allocate channel c6 type disk maxpiecesize=20G;
allocate channel c7 type disk maxpiecesize=20G;
allocate channel c8 type disk maxpiecesize=20G;
backup as compressed backupset incremental level 1 database format='/backup/rmandata/ynsb_inc_l1_%U.BKU' tag='ynsb_lev_1_$RECORD_TIME';
sql 'alter system archive log current';
backup as compressed backupset archivelog all tag='arc_bak_$RECORD_TIME' format='/backup/rmandata/arch_%U_%T' not backed up 1 times;
backup current controlfile tag='ctlfile_bak_$RECORD_TIME' format='/backup/rmandata/ctl_file_%U_%T';
}
exit;
EOF