RMAN backup
=====================
[oracle@hostvm01 rman_orap_BKP] cat orapbackup.sh
#!/usr/bin/ksh
export ORACLE_SID=orap
export ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1
export LD_LIBRARY_PATH=$ORACLE_HOME/11b
export PATH=$ORACLE_HOME/bin:$PATH
export NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS'
rman target / log=backup_orap_2024.log <<EOF>/mount/path/path/backup/oracle01/rman_orap_BKP/backup_orap.log
run
{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
:
:
allocate channel c20 device type disk;
sql 'alter system switch logfile';
backup as compressed backupset incremental level 0 filesperset 4 tag 'orap_L0_source_pldsaw'
format '/mount/path/path/backup/oracle01/man_orap_BP/DF_orap_pldsaw_%T_data_%u_%d_%U' cumulative database;
sql 'alter system switch logfile';
backup filesperset 16 tag 'orap_ARCH_LO_source_pldsaw'
format '/mount/path/path/backup/oracle0l/rman_orap_BKP/ARCH_orap_pldsaw_%T_arch_%u_%d_%U' archivelog all;
backup current controlfile format '/mount/path/path/backup/oracle01/rman_orap_BKP/CF_orap_pldsaw_%T_controlfile_%u_%d_%U';
backup current controlfile for standby format '/mount/path/path/backup/oracle01/rman_orap_BKP/STDBY_CL_orap_pldsaw_standbycontrolfile_%U';
sql 'alter database backup controlfile to trace';
release channel cl;
release channel c2;
release channel c20;
}
exit
EOF
[oracle@server]
RMAN restore
=================================
set head off pages 0 feed off echo off verify off
set lines 200
spool rename datafiles.1st
select 'set newname for datafile ' || file_id || ' to ''/oradata_db/ORAPRD/data/' ||
substr(file_name, instr (file_name, '/',-1)+1) || ''';'
from dba data files;
spool off
exit;
Restore
=============
[oracle@hostvm01 rman_oraprdp_BKP]$ cat oraprdp_local_restore.sh
#!/usr/bin/ksh
export ORACLE_SID=oraprdp
export ORACLE_HOME=/u01/app/oracle/product/19.0.0
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE HOME/bin:$PATH
rman target / log=restore_oraprdp_from_local_backup.log <<EOF>/home/oracle/scripts/restore_oraprdp_local.log
restore controlfile from '/mount/path/path/backup/oracle01/rman_oraprdp_BKP/CF_oraprdp_pldsaw_controlfile';
sql 'alter database mount';
catalog start with '/mount/path/path/backup/oracle01/rman_oraprdp_BKP' noprompt:
run
{
allocate channel cl device type disk;
allocate channel c2 device type disk;
:
:
allocate channel c20 device type disk:
set newname for datafile 1 to /orabackup/oraprdp/DATAFILE/system01.dbf';
set newname for datafile 2 to /orabackup/oraprdp/DATAFILE/sysaux01.dbf';
:
:
set newname for datafile 83 to /orabackup/oraprdp/DATAFILE/qssrdspace_01.dbf';
RESTORE DATABASE:
SWITCH DATAFILE ALL:
RECOVER DATABASE:
release channel cl;
release channel c2;
release channel c3;
:
:
release channel c20;
}
sql 'alter database open resetlogs';
exit
EOF
[oracle]
#!/usr/bin/ksh
export ORACLE_SID=oraprdp
export ORACLE_HOME=/u01/app/oracle/product/19.0.0
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE HOME/bin:$PATH
rman target / log=restore_oraprdp_from_local_backup.log <<EOF>/home/oracle/scripts/restore_oraprdp_local.log
restore controlfile from '/mount/path/path/backup/oracle01/rman_oraprdp_BKP/CF_oraprdp_pldsaw_controlfile';
sql 'alter database mount';
catalog start with '/mount/path/path/backup/oracle01/rman_oraprdp_BKP' noprompt:
run
{
allocate channel cl device type disk;
allocate channel c2 device type disk;
:
:
allocate channel c20 device type disk:
set newname for datafile 1 to /orabackup/oraprdp/DATAFILE/system01.dbf';
set newname for datafile 2 to /orabackup/oraprdp/DATAFILE/sysaux01.dbf';
:
:
set newname for datafile 83 to /orabackup/oraprdp/DATAFILE/qssrdspace_01.dbf';
RESTORE DATABASE:
SWITCH DATAFILE ALL:
RECOVER DATABASE:
release channel cl;
release channel c2;
release channel c3;
:
:
release channel c20;
}
sql 'alter database open resetlogs';
exit
EOF
[oracle]
DUPLICATE
=============
[oracle@hostvm01 oraprd_BACKUP_01072024]$ more restore_147.sh
#!/bin/ksh
export ORACLE_SID=oraprd
export ORACLE_HOME=/u01/app/oracle/product/19.0.0
export PATH=$ORACLE_HOME/bin:$PATH
export NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS'
rman auxiliary / log=restore_oraprd_142024.log <<EOF> nohup_restore_oraprd_142024.log
run {
allocate auxiliary channel c1 device type disk;
allocate auxiliary channel c2 device type disk;
:
:
allocate auxiliary channel c20 device type disk;
DUPLICATE DATABASE TO oraprd
BACKUP LOCATION '/mount/path/path/backup/oracle01/oraprd_BACKUP_01072024'
NOFILENAMECHECK;
}
exit
EOF
[oracle
No comments:
Post a Comment