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)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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

General Comments(0)

Tip: Click on a line number in the code to add a line-specific comment

No general comments yet. Be the first to comment!