backup and restore
Backup: A backup is a copy of database data that can be used to reconstruct the database Restore and Recovery: Restore is the process of retrieving database files from backup storage. Recovery is the process of applying redo logs to bring the database back to a consistent state.
oraclesqlbackup-restorev1.0.0
0 stars2 downloads58 views0 comments
By Mahmoud • Created
Code
(113 lines)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
1 - ENSURE Archivelog mode is enable
------------------------------------
sqlplus / as sysdba
sql > archive log list;
- if not enable
sql > shutdown immediate ;
sql > startup mount ;
sql > alter database archivelog ; // ALTER DATABASE NOARCHIVELOG;
sql > alter database open ;
- check DB name and unique name
sql > select name from v$database;
sql > show parameter db_unique_name;
- Make sure the db_recovery_file_dest with value
sql > show parameter db_recovery_file_dest ;
if not
mkdir -R $ORACLE_HOME/diag/rdbms/<dbname>/<instance>/backupset
sql > alter system set db_recovery_file_dest =$ORACLE_HOME/diag/rdbms/<dbname>/<instance>/backupset;
==========================================================================
2 - take hot backup
-------------------
rman target /
rman > RUN {
CONFIGURE CONTROLFILE AUTOBACKUP ON;
BACKUP AS COMPRESSED BACKUP DATABASE PLUS ARCHIVELOG;
}
=======================================================================================
3 - copy necessary files to new vm
-----------------------------------
copy RMAN Backup files --> to $ORACLE_HOME/diag/rdbms/<dbname>/<instance>/backupset
copy or create pfile
sql > create pfile='/tmp/initmy.ora' from spfile;
-----> move to new vm path $ORACLE_HOME/dbs/initmy.ora
copy password file --> the path is $ORACLE_HOME/dbs/orapw<SID>
---------------------------- OR --------------------------------
you can create a new orapaw<SID> after you create & open the database
-- Ex
bash > orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=or@cle123 force=y
===================================================================
4 - on new VM
--------------
- install the same oracle version.
- export ORACLE_SID & ORACLE_HOME
export ORACLE_SID = TESTDB
export ORACLE_HOME = /u01/app/oracle/product/19.0.0/dbhome_1
===========================================================================
5 - restore the database with RMAN
----------------------------------
rman target /
RMAN > startup nomount pfile=/$ORACLE_HOME/dbs/initmy.ora ;
RMAN > restore controlfile from autobackup;
RMAN > alter database mount;
RMAN > restore database ;
RMAN > recover database ;
- after successful recovery
RMAN > alter database open resetlogs;
=================================================
on sql
sql > create spfile from pfile='$ORACLE_HOME/dbs/initmy.ora';
=====================================================
add the instance and ORACLE_HOME to oratabe
vi /etc/oratabe
TESTDB:/u01/app/oracle/product/19.0.0/dbhome_1:N
========================================================
use netca to create listener.ora
use netca to create tnsnames.ora
create sqlnet.ora
-----------------
# sqlnet.ora Network Configuration File: /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME)
SQLNET.ALLOWED_LOGON_VERSION_SERVER=8
SQLNET.ALLOWED_LOGON_VERSION_CLIENT=8
/* this allow you to connect to the database by toad older version */Usage Instructions
* this is a sample script