run {
#allocate channel ch1 device type disk;
backup device type disk incremental level 0
as compressed backupset
database force filesperset=1 plus archivelog ;
delete archivelog all completed before 'sysdate-1' device type disk backed up 1 times to device type disk;
delete noprompt obsolete;
}
list backup of database 'pdb$seed';
RMAN> run {
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE' PARMS="SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=/nfs)";
backup incremental level 0
as compressed backupset
database force filesperset=1;
RELEASE CHANNEL ch00;
}
run
{
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE' PARMS="SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=/nfs)";
crosscheck backup;
delete backupset;
RELEASE CHANNEL ch00;
}
run
{
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE' PARMS="SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=/nfs)";
restore database;
recover database;
RELEASE CHANNEL ch00;
}
run
{
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE' PARMS="SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=/nfs)";
restore pluggable database 'pdb$seed' ; #'cdb$root';
RELEASE CHANNEL ch00;
}
run
{
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE' PARMS="SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=/nfs)";
restore pluggable database 'pdb$seed';
RELEASE CHANNEL ch00;
}
ALLOCATE CHANNEL ch14 TYPE 'SBT_TAPE' $RMAN_PARMS;
ALLOCATE CHANNEL ch15 TYPE 'SBT_TAPE' $RMAN_PARMS;
send 'NB_ORA_SERV=$NB_ORA_SERV, NB_ORA_CLIENT=$NB_ORA_CLIENT, NB_ORA_POLICY=$NB_ORA_POLICY, NB_ORA_SCHED=$NB_ORA_SCHED';
backup incremental level 0
as compressed backupset
DATABASE root pluggable database pdb ,'PDB\\\$SEED';
#database force filesperset=1;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
RELEASE CHANNEL ch02;
RELEASE CHANNEL ch03;
recover pluggable database 'cdb$root',pdb;
磁盘和FRA备份到本地硬盘
[oracle@rac2 rman_backup]$ cat rman_backup_db3_pdb.sh
#-----------------------------------------------
# Usage : rman_backup_db.sh DB_NAME BACKUP_OPTION (e.g. full/incr/incrc)_
#-----------------------------------------------
export ORACLE_HOME=/u01/app/oracle/product/19.0.0/db_1
export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
ORACLE_DB=`basename $1`
BACKUP_OPTION=`basename $2`
case `hostname` in
rac1)
ORACLE_SID=$ORACLE_DB"1"
;;
rac2)
ORACLE_SID=$ORACLE_DB"2"
;;
rac3)
ORACLE_SID=$ORACLE_DB"3"
;;
*)
ORACLE_SID=$ORACLE_DB
;;
esac
export ORACLE_SID
RMAN_LOG_FILE=`dirname $0`'/log/'`basename ${1}`'_'`date '+%Y%m%d%H%M%S'`.out
RMAN=$ORACLE_HOME/bin/rman
BACKUP_TAG=$ORACLE_DB'_'`date '+%Y%m%d%H%M%S'`'_level0'
echo "ORACLE DB name: $ORACLE_DB" >> $RMAN_LOG_FILE
echo "ORACLE instance : $ORACLE_SID" >> $RMAN_LOG_FILE
# ---------------------------------------------------------------------------
# With the Oracle DBA user id (account)
# Set the target connect string.
# ---------------------------------------------------------------------------
ORACLE_USER=oracle
TARGET_CONNECT_STR=/
if [ "$ORACLE_DB" = "cdb" ]
then
CATALOG_CONNECT_STR="nocatalog"
else
CATALOG_CONNECT_STR="catalog rco/rco@rca"
fi
# ---------------------------------------------------------------------------
# Set env for TDE
# ---------------------------------------------------------------------------
export SFNT_HSMAPI_BASE=/opt/oracle/extapi/64/hsm/safenet/8.9.0.000
export NAE_Properties_Conf_Filename=$SFNT_HSMAPI_BASE/IngrianNAE.properties
export IngrianNAE_Properties_Conf_Slot_ID_Max=100
export IngrianNAE_Properties_Conf_SessionID_Max=100
export ORACLE_UNQNAME=$ORACLE_DB
ORA_FULL=0
ORA_INCR=0
ORA_CINC=0
case $BACKUP_OPTION in
incr)
ORA_INCR=1
;;
incrc)
ORA_CINC=1
;;
*)
ORA_FULL=1
;;
esac
# ---------------------------------------------------------------------------
# Print out the value of the variables set by this script.
# ---------------------------------------------------------------------------
echo >> $RMAN_LOG_FILE
echo "RMAN: $RMAN" >> $RMAN_LOG_FILE
echo "ORACLE_SID: $ORACLE_SID" >> $RMAN_LOG_FILE
echo "ORACLE_USER: $ORACLE_USER" >> $RMAN_LOG_FILE
echo "ORACLE_HOME: $ORACLE_HOME" >> $RMAN_LOG_FILE
# ---------------------------------------------------------------------------
# Print out the value of the variables set
# ---------------------------------------------------------------------------
echo >> $RMAN_LOG_FILE
echo "ORA_FULL: $ORA_FULL" >> $RMAN_LOG_FILE
echo "ORA_INCR: $ORA_INCR" >> $RMAN_LOG_FILE
echo "ORA_CINC: $ORA_CINC" >> $RMAN_LOG_FILE
# ---------------------------------------------------------------------------
# NOTE: This script assumes that the database is properly opened. If desired,
# this would be the place to verify that.
# ---------------------------------------------------------------------------
echo >> $RMAN_LOG_FILE
# ---------------------------------------------------------------------------
# If this script is executed from a NetBackup schedule, NetBackup
# sets an ORA environment variable based on the schedule type.
# The ORA variable is then used to dynamically set BACKUP_TYPE
# For example, when:
# schedule type is BACKUP_TYPE is
# ---------------- --------------
# Automatic Full INCREMENTAL LEVEL=0
# Automatic Differential Incremental INCREMENTAL LEVEL=1
# Automatic Cumulative Incremental INCREMENTAL LEVEL=1 CUMULATIVE
#
# For user initiated backups, BACKUP_TYPE defaults to incremental
# level 0 (full). To change the default for a user initiated
# backup to incremental or incremental cumulative, uncomment
# one of the following two lines.
# BACKUP_TYPE="INCREMENTAL LEVEL=1"
# BACKUP_TYPE="INCREMENTAL LEVEL=1 CUMULATIVE"
#
# Note that we use incremental level 0 to specify full backups.
# That is because, although they are identical in content, only
# the incremental level 0 backup can have incremental backups of
# level > 0 applied to it.
# ---------------------------------------------------------------------------
if [ "$ORA_FULL" = "1" ]
then
echo "Full backup requested" >> $RMAN_LOG_FILE
BACKUP_TYPE="INCREMENTAL LEVEL 0"
BACKUP_TAG=$ORACLE_DB'_'`date '+%Y%m%d%H%M%S'`'_level0'
elif [ "$ORA_INCR" = "1" ]
then
echo "Differential incremental backup requested" >> $RMAN_LOG_FILE
BACKUP_TYPE="INCREMENTAL LEVEL 1"
BACKUP_TAG=$ORACLE_DB'_'`date '+%Y%m%d%H%M%S'`'_level1D'
elif [ "$ORA_CINC" = "1" ]
then
echo "Cumulative incremental backup requested" >> $RMAN_LOG_FILE
BACKUP_TYPE="INCREMENTAL LEVEL 1 CUMULATIVE"
BACKUP_TAG=$ORACLE_DB'_'`date '+%Y%m%d%H%M%S'`'_level1C'
elif [ "$BACKUP_TYPE" = "" ]
then
echo "Default - Full backup requested" >> $RMAN_LOG_FILE
BACKUP_TYPE="INCREMENTAL LEVEL 0"
BACKUP_TAG=$ORA