Experience: is what you get soon after you need it.

Experience: is what you get soon after you need it.



My Cloud Certifications:

GIAC Cloud Penetration Tester (GCPN)

GIAC Cloud Security Automation (GCSA)

GIAC Security Essentials (GSEC)

Certified Kubernetes Administrator (CKA)

Cloud Certified Security Professional (ISC2)

CyberSecurity Certified Professional (ISC2)

AWS Certified Solutions Architect Associate

Azure Certified Architect Expert

Azure Certified Architect

Azure Certified Administrator

Oracle Cloud Infrastructure 2018 Certified Architect Associate.

Oracle Cloud Infrastructure Classic 2018 Certified Architect Associate.

Oracle Database Cloud Administrator Certified Professional.

Oracle Database Cloud Service Operations Certified Associate.

Search This Blog

Tuesday, December 5, 2017

Oracle Cloud 12c database - Recover the database from the cloud backup using orec


In my previous post I showed you how to backup the Oracle cloud database using bkp_api and console.
Post related to Backups:
http://www.shaiksameer.com/2017/12/oracle-cloud-12c-how-to-manually-backup.html

In this series I will show how to restore/recover the Cloud database using orec (Oracle Recovery utility ) of dbaascli tool.


Recovery:


Oracle Cloud 12c database - Recover the database from the cloud backup using orec

First we will list the most recent backups use the below command and then use orec utility to restore/recover the database using the latest backup.


[root@erpdev1 ~]# dbaascli orec --args -list
DBAAS CLI version 1.0.0
Executing command orec --args -list
--args : -list


OREC version: 16.0.0.0


Starting OREC
Logfile is /var/opt/oracle/log/erpdev2/orec/orec_2017-12-04_20:31:47.log
Config file is /var/opt/oracle/orec/orec.cfg


DB name: erpdev2
OREC:: RUNNING IN NON DATAGUARD ENVIRONMENT
OREC:: Catalog mode:  Disabled
Getting list backups...
 Backup Tag             Completion Date         Config Files Location
 ---------------------- ----------------------- ------------------------
 TAG20171201T193037     12/01/2017 19:30:37
 TAG20171204T200050     12/04/2017 20:00:50
 TAG20171204T200105     12/04/2017 20:01:05
 TAG20171204T203034     12/04/2017 20:30:34
 TAG20171204T203050     12/04/2017 20:30:50


Now let's recover the database from the latest cloud backup using orec

[root@erpdev1 ~]#  dbaascli orec --args -latest
DBAAS CLI version 1.0.0
Executing command orec --args -latest
--args : -latest


OREC version: 16.0.0.0


Starting OREC
Logfile is /var/opt/oracle/log/erpdev2/orec/orec_2017-12-04_20:25:26.log
Config file is /var/opt/oracle/orec/orec.cfg


DB name: erpdev2
OREC:: RUNNING IN NON DATAGUARD ENVIRONMENT
OREC:: Checking prerequirements before recovery process.
OREC:: DB Status : OPEN
OREC:: Changing instance to MOUNT stage.
OREC:: Shutting down the database... Completed.
OREC:: (RMAN) Startup MOUNT... Completed.
OREC:: Checking for PDBs directories.
OREC:: Checking for REDO logs.
OREC:: Restablishing DB instance to the original stage.
OREC:: Shutting down the database... Completed.
OREC:: Starting up database... Completed.
OREC:: Catalog mode:  Disabled
OREC:: Testing RMAN connection.
OREC:: Verifying backups dates ..
   :: OK
OREC:: Latest backup : TAG20171204T200105


WARN: No corresponding cfg files exist for latest tag.
OREC:: Continuing with the DB recovery.
OREC:: Shutting down the database... Completed.
OREC:: Startup MOUNT... Completed.
OREC:: Performing recovery from latest backup.RMAN Completed.


RMAN Completed.

INFO : DB instance is up and running after recovery procedure.
OREC:: Recovery to latest backup completed.


[root@erpdev1 ~]#


List long term cloud backups using orec:
[root@erpdev1 ~]# dbaascli orec --args -keep -list
DBAAS CLI version 1.0.0
Executing command orec --args -keep -list
--args : -keep -list


OREC version: 16.0.0.0


Starting OREC
Logfile is /var/opt/oracle/log/erpdev2/orec/orec_2017-12-05_14:23:19.log
Config file is /var/opt/oracle/orec/orec.cfg


DB name: erpdev2
OREC:: RUNNING IN NON DATAGUARD ENVIRONMENT
OREC:: Catalog mode:  Disabled
Tag parameter not required
OREC::############ LONG-TERM RETENTION BACKUPS #############


 Backup Tag             Completion Date
------------------------ -------------------------
 JAAS20171201T170605        12/01/2017 17:06:05
OREC:: Looking for known issues
Not issues found


Restoring from a Specific Backup using dbaascli - orec Utility


[root@erpdev1 ~]# dbaascli orec --args  -pitr TAG20171204T203050
DBAAS CLI version 1.0.0
Executing command orec --args -pitr TAG20171204T203050
--args : -pitr TAG20171204T203050


OREC version: 16.0.0.0


Starting OREC
Logfile is /var/opt/oracle/log/erpdev2/orec/orec_2017-12-05_14:28:50.log
Config file is /var/opt/oracle/orec/orec.cfg


DB name: erpdev2
OREC:: RUNNING IN NON DATAGUARD ENVIRONMENT
OREC:: Catalog mode:  Disabled
OREC:: Checking prerequirements before recovery process.
OREC:: DB Status : OPEN
OREC:: Changing instance to MOUNT stage.
OREC:: Shutting down the database... Completed.
OREC:: (RMAN) Startup MOUNT... Completed.
OREC:: Checking for PDBs directories.
OREC:: Checking for REDO logs.
OREC:: Restablishing DB instance to the original stage.
OREC:: Shutting down the database... Completed.
OREC:: Starting up database... Completed.
OREC:: Testing RMAN connection.
OREC:: Verifying backups dates ..
   :: OK
WARN: No Config files backup exist for the specified tag.
OREC:: Shutting down the database... Completed.
OREC:: Startup MOUNT... Completed.
OREC:: Performing Point-In-Time-Recovery to: 12/04/2017 20:30:50 ...
OREC:: Checking if PITR is across incarnations ...
OREC:: Determining current incarnation ...
OREC:: Determining target incarnation for time: 12/04/2017 20:30:50 ...


OREC:: PITR is within current incarnation 3


INFO : DB instance is up and running after recovery procedure.
OREC:: PITR Completed.


You have new mail in /var/spool/mail/root

Recover Oracle Cloud database up to a Specific SCN by Using the dbaascli Utility


Use : dbaascli orec --args  -SCN <scn number>


Find the SCN of the system for the particular date/time as below:

SQL> select timestamp_to_scn(to_date('12/03/2017 12:01:00','mm/dd/yyyy hh24:mi:ss')) from dual;


TIMESTAMP_TO_SCN(TO_DATE('12/03/201712:01:00','MM/DD/YYYYHH24:MI:SS'))
----------------------------------------------------------------------
                                                              3005455

Now use the above SCN to do a Point-in-time Recovery.

[root@erpdev1 ~]# dbaascli orec --args -scn 3005455
DBAAS CLI version 1.0.0
Executing command orec --args -scn 3005455
--args : -scn 3005455


OREC version: 16.0.0.0


Starting OREC
Logfile is /var/opt/oracle/log/erpdev2/orec/orec_2017-12-05_15:12:28.log
Config file is /var/opt/oracle/orec/orec.cfg


DB name: erpdev2
OREC:: RUNNING IN NON DATAGUARD ENVIRONMENT
OREC:: Verifying scn validity...
PITR using SCN: 3005455
OREC:: Catalog mode:  Disabled
OREC:: Checking prerequirements before recovery process.
OREC:: DB Status : OPEN
OREC:: Changing instance to MOUNT stage.
OREC:: Shutting down the database... Completed.
OREC:: (RMAN) Startup MOUNT... Completed.
OREC:: Checking for PDBs directories.
OREC:: Checking for REDO logs.
OREC:: Restablishing DB instance to the original stage.
OREC:: Shutting down the database... Completed.
OREC:: Starting up database... Completed.
OREC:: Testing RMAN connection.
OREC:: Verifying backups dates ..
   :: OK
OREC:: Performing PITR using SCN number 3005455 ...OREC:: Checking if PITR is ac      ross incarnations ...
OREC:: Determining current incarnation ...
OREC:: Determining target incarnation for SCN: 3005455 ...


OREC:: PITR is from current incarnation 4 to target incarnation 3


OREC:: Converting SCN to timestamp as PITR to a different incarnation using SCN       is not possible unless using a recovery catalog.
OREC:: Converting SCN to timestamp ...
OREC:: Shutting down the database... Completed.
OREC:: Starting up database... Completed.
OREC:: Performing Point-In-Time-Recovery to: 12/01/2017 19:57:15 ...
OREC:: Checking if PITR is across incarnations ...
OREC:: Determining current incarnation ...
OREC:: Determining target incarnation for time: 12/01/2017 19:57:15 ...


OREC:: PITR is from current incarnation 4 to target incarnation 3
OREC:: Reseting database to incarnation # : 3
OREC:: Shutting down the database... Completed.


OREC: Startup NOMOUNT... Completed.
OREC:: Restoring controlfile from autobackup... Completed.


INFO : DB instance is up and running after recovery procedure.
OREC:: PITR Completed.


OREC:: Recovery to SCN completed.


You have new mail in /var/spool/mail/root
[root@erpdev1 ~]#



For help and explore the commands that are available with orec

[root@erpdev1 ~]# dbaascli orec --args -help
DBAAS CLI version 1.0.0
Executing command orec --args -help
--args : -help


OREC version: 16.0.0.0


Starting OREC
Logfile is /var/opt/oracle/log/erpdev2/orec/orec_2017-12-04_20:34:15.log


Usage:
  orec -dbname=<db_instance> -list


Where:
  -help      = Print this help.
  -list      = List all the available RMAN backups.
  ------------------------ Long-term backup retention options -----------------------
  -keep      = General Mode for Long-term backup retention
  -keep -list = Shows the list of the current Long-term backups


Examples:
  orec -help
  orec -dbname=PROD -list

Usage:
  orec -list
  orec -pitr <backup_tag>
  orec -pitr <backup_tag> -data
  orec -pitr <backup_tag> -cfgfiles
  orec -timestamp="<date_and_time>"
  orec -scn <SCN number>
  orec -latest
  orec -latest -data
  orec -latest -cfgfiles
  orec -duplicate
  orec -duplicate -dbrole <db_role>


Where:
  -help      = Print this help.
  -list      = List all the available RMAN backups and the location of their respective config files.
  -pitr      = Point-in-time recovery for the entire Database, an RMAN tag must be specified.
  -timestamp = Point-in-time recovery for the entire Database using a timestamp.
               Time format "DD-MON-YYYY hh24:mi:ss"
  -scn       = Point-in-time recovery for the entire Database using SCN (System Change Number) number.
  -latest    = Performs a database recovery using the latest backup.
  -data      = Recovery only for DATA, exludes config files.
  -cfgfiles  = Recovery only for config files, excludes DATA.
  -duplicate = Executes RMAN duplicate when issued in a Standby instance. (DataGuard)
  -dbrole    = Specify the DB instance role when OREC is unable to detect it (DataGuard).
  ------------------------ Long-term backup retention options -----------------------
  -keep      = General Mode for Long-term backup retention
  -keep -list = Shows the list of the current Long-term backups
  -keep -tag <backup_tag> = Performs a recovery using the backup tag


Examples:
  orec -help
  orec -list
  orec -pitr TAG20140117T061554
  orec -pitr TAG20140117T061554 -cfgfiles
  orec -pitr TAG20140117T061554 -data
  orec -timestamp="31-JAN-2014 14:50:07"
  orec -scn 1815307
  orec -latest -cfgfiles
  orec -latest -data
  orec -latest
  orec -duplicate
  orec -duplicate -dbrole standby


Note : It is highly recommended to perform a backup prior using this recovery tool.


Recover Oracle Cloud database 12c using console

Login into your cloud console →
Go to DBCS →
Open Service Console →
Pick your database service →
Click on Administration →
Click on Backup.


Now you can either click on the menu on a available backup to recover from it or go recover tab and pick a date/SCN/latest backup to recover.




-OR-





If you chose a particular backup to restore then confirm your selection as shown below and click OK.



Now wait for the recovery to complete.






Friday, December 1, 2017

Oracle Cloud 12c - How to manually backup the database using bkp_api



How to manually backup the database using bkp_api

as root :
Run /var/opt/oracle/bkup_api/bkup_api bkup_start

or
  • To create a long-term backup, enter the following bkup_api command:      /var/opt/oracle/bkup_api/bkup_api bkup_start -- keep

[root@erpdev1 etc]# /var/opt/oracle/bkup_api/bkup_api bkup_start
DBaaS Backup API V1.5 @2016 Multi-Oracle home
DBaaS Backup API V1.5 @2015 Multi-Oracle home
-> Action : bkup_start
-> logfile: /var/opt/oracle/bkup_api/log/bkup_api.log
UUID 7d06371a-d6b6-11e7-a905-c6b0ce5986ff for this backup
** process started with PID: 2314
** see log file for monitor progress
-------------------------------------
You have new mail in /var/spool/mail/root


Check the log:
[root@erpdev1 etc]# view /var/opt/oracle/bkup_api/log/bkup_api.log
Fri, 01 Dec 2017 16:41:32 DBaaS Backup API V1.5 @2016 Multi-Oracle home
Fri, 01 Dec 2017 16:41:32 DBaaS Backup API V1.5 @2015 Multi-Oracle home
Fri, 01 Dec 2017 16:41:32 -> Action : bkup_start
Fri, 01 Dec 2017 16:41:32 -> logfile: /var/opt/oracle/bkup_api/log/bkup_api.log
Fri, 01 Dec 2017 16:41:32 UUID 7d06371a-d6b6-11e7-a905-c6b0ce5986ff for this backup
Fri, 01 Dec 2017 16:41:36 API::2192:: Backup list synchronization in background.
Fri, 01 Dec 2017 16:41:44 API::2192:: Backup list synchronization completed.
Fri, 01 Dec 2017 16:41:44 ** process started with PID: 2314
Fri, 01 Dec 2017 16:41:44 ** see log file for monitor progress
Fri, 01 Dec 2017 16:41:44 -------------------------------------
Fri, 01 Dec 2017 16:41:44 7d06371a-d6b6-11e7-a905-c6b0ce5986ff -> Starting execution of backup log in background
Fri, 01 Dec 2017 16:41:44 7d06371a-d6b6-11e7-a905-c6b0ce5986ff STARTING BACKUP REQUEST
Fri, 01 Dec 2017 16:41:44 UUID 7d06371a-d6b6-11e7-a905-c6b0ce5986ff written with PID 2314
Fri, 01 Dec 2017 16:41:45 7d06371a-d6b6-11e7-a905-c6b0ce5986ff Checking if erpdev2 resource is available
Fri, 01 Dec 2017 16:41:45 7d06371a-d6b6-11e7-a905-c6b0ce5986ff has a lock erpdev2
Fri, 01 Dec 2017 16:41:45 7d06371a-d6b6-11e7-a905-c6b0ce5986ff The process is no longer running removing lock
Fri, 01 Dec 2017 16:41:45 7d06371a-d6b6-11e7-a905-c6b0ce5986ff registering request into the database
Fri, 01 Dec 2017 16:41:49 7d06371a-d6b6-11e7-a905-c6b0ce5986ff current backups 9
Fri, 01 Dec 2017 16:41:49 7d06371a-d6b6-11e7-a905-c6b0ce5986ff command /var/opt/oracle/ocde/assistants/bkup/obkup


Verify the status of the backup:
[root@erpdev1 etc]# /var/opt/oracle/bkup_api/bkup_api bkup_status
DBaaS Backup API V1.5 @2016 Multi-Oracle home
DBaaS Backup API V1.5 @2015 Multi-Oracle home
-> Action : bkup_status
-> logfile: /var/opt/oracle/bkup_api/log/bkup_api.log
 Warning: unable to get current configuration of: catalog
* Current backup settings:
* Last registered Bkup: 12-01 16:41 API::2314:: Starting dbaas backup process
* Bkup state: finished
**************************************************
* API History: API steps
  API:: NEW PROCESS 2314
  API:: Starting dbaas backup process
  API:: Your new dbaas backup tag is TAG20171201T164410
  API:: BKUP COMPLETE YOUR BKUP TAG TAG20171201T164410
*************************************************
* Backup steps
 -> API:: Oracle database state is up and running
 -> API:: DB instance: erpdev2
 -> API:: Determining if the filesystem is not full
 -> API:: ...... OK
 -> API:: Validating the backup repository ......
 -> API::      All backup pieces are ok
 -> API:: Performing backup to local storage (primary backup)
 -> API:: Executing rman instructions
 -> API:: ...... OK
 -> API:: Backup to local storage is completed
 -> API:: Clean MOTD.
 -> API:: Performing backup to cloud storage (secondary backup)
 -> API:: Executing rman instructions
 -> API:: ......OK
 -> API:: Backup to cloud storage is completed
 -> API:: Clean MOTD.
 -> API:: Starting backup of config files
 -> API:: Executing rman instructions
 -> API:: at time: 2017-12-01:16:45:17
 -> API:: Determining the oracle database id
 -> API::  DBID: 3253488032
 -> API:: Creating directories to store config files
 -> API:: Determining the oracle database id
 -> API::  DBID: 3253488032
 -> API:: Compressing config files into tar files
 -> API:: .... OK
 -> API:: Uploading config files to cloud storage
 -> API:: Completed at time: 2017-12-01:16:45:30
 -> API:: at time: 2017-12-01:16:45:30
 -> API:: Config files backup ended successfully
 -> API:: Clean MOTD.
 -> API:: All requested tasks are completed
*
* RETURN CODE:0
##################################################

Oracle cloud database 12.2 - View backup information


To List the available backups by using bkup_api

As root user:

bkup_api command
$ /var/opt/oracle/bkup_api/bkup_api bkup_status
-OR-

 List the available backups by using bkup_api
$ /var/opt/oracle/bkup_api/bkup_api recover_list
-OR-

 List normal backups by using dbaascli
$ dbaascli orec --args -list
-OR-

 List long-term backups by using dbaascli
$dbaascli orec --args -keep -list

Verify the obkup.log generated for backup
/home/oracle/bkup/<SID>/log/obkup.log
-OR

 Switch to 'oracle' user and connect to RMAN
RMAN target /RMAN> list backup;
-OR-
RMAN> list backup summary;

Cron schedule:
[root@erpdev1 etc]# cat /etc/crontab | grep -v "#"
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=
HOME=/

44 23 * * * root /var/opt/oracle/bkup_api/bkup_api bkup_start --dbname=erpdev2
0,30 * * * * root /var/opt/oracle/bkup_api/bkup_api bkup_archlogs --dbname=erpdev2
15 03 * * 6 oracle /var/opt/oracle/cleandb/cleandblogs.pl





Examples:


[root@erpdev1 ~]# /var/opt/oracle/bkup_api/bkup_api recover_list
DBaaS Backup API V1.5 @2016 Multi-Oracle home
DBaaS Backup API V1.5 @2015 Multi-Oracle home
-> Action : recover_list
-> logfile: /var/opt/oracle/bkup_api/log/bkup_api.log
Utility output:

OREC version: 16.0.0.0

Starting OREC
Logfile is /var/opt/oracle/log/erpdev2/orec/orec_2017-12-01_15:48:41.log
Config file is /var/opt/oracle/orec/orec.cfg

DB name: erpdev2
OREC:: RUNNING IN DATAGUARD ENVIRONMENT
OREC:: Catalog mode:  Disabled
Getting list backups...
  Backup Tag             Completion Date         Config Files Location
  ---------------------- ----------------------- ------------------------
  TAG20171114T002226     11/14/2017 00:22:26

  TAG20171114T003039     11/14/2017 00:30:39

  TAG20171114T003106     11/14/2017 00:31:06

  TAG20171201T153055     12/01/2017 15:30:55

  TAG20171201T153111     12/01/2017 15:31:11

  TAG20171114T002226     11/14/2017 00:22:26

  TAG20171114T003039     11/14/2017 00:30:39

  TAG20171114T003106     11/14/2017 00:31:06

  TAG20171201T153055     12/01/2017 15:30:55

  TAG20171201T153111     12/01/2017 15:31:11


-OR

[root@erpdev1 ~]# dbaascli orec --args -list
DBAAS CLI version 1.0.0
Executing command orec --args -list
--args : -list

OREC version: 16.0.0.0

Starting OREC
Logfile is /var/opt/oracle/log/erpdev2/orec/orec_2017-12-01_15:57:43.log
Config file is /var/opt/oracle/orec/orec.cfg

DB name: erpdev2
OREC:: RUNNING IN NON DATAGUARD ENVIRONMENT
OREC:: Catalog mode:  Disabled
Getting list backups...
  Backup Tag             Completion Date         Config Files Location
  ---------------------- ----------------------- ------------------------
  TAG20171114T002226     11/14/2017 00:22:26

  TAG20171114T003039     11/14/2017 00:30:39

  TAG20171114T003106     11/14/2017 00:31:06

  TAG20171201T153055     12/01/2017 15:30:55

  TAG20171201T153111     12/01/2017 15:31:11

  TAG20171114T002226     11/14/2017 00:22:26

  TAG20171114T003039     11/14/2017 00:30:39

  TAG20171114T003106     11/14/2017 00:31:06

  TAG20171201T153055     12/01/2017 15:30:55

  TAG20171201T153111     12/01/2017 15:31:11




[root@erpdev1 ~]# dbaascli orec --args -keep -list
DBAAS CLI version 1.0.0
Executing command orec --args -keep -list
--args : -keep -list

OREC version: 16.0.0.0

Starting OREC
Logfile is /var/opt/oracle/log/erpdev2/orec/orec_2017-12-01_16:03:27.log
Config file is /var/opt/oracle/orec/orec.cfg

DB name: erpdev2
OREC:: RUNNING IN NON DATAGUARD ENVIRONMENT
OREC:: Catalog mode:  Disabled
Tag parameter not required
OREC::############ LONG-TERM RETENTION BACKUPS #############

  Backup Tag             Completion Date
------------------------ -------------------------
The system is clean no forever backups found
[root@erpdev1 ~]#



-OR

[oracle@ERPStandby ~]$ rman

Recovery Manager: Release 12.2.0.1.0 - Production on Fri Dec 1 16:03:44 2017

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

RMAN> connect target /

connected to target database: ERPPRD (DBID=1847233764)

RMAN> list backup summary;

using target database control file instead of recovery catalog

List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---

45      B  A  A SBT_TAPE    22-NOV-17       1       1       YES        TAG20171122T143044
46      B  A  A SBT_TAPE    22-NOV-17       1       1       YES        TAG20171122T143044
47      B  A  A SBT_TAPE    22-NOV-17       1       1       YES        TAG20171122T143044
48      B  F  A SBT_TAPE    22-NOV-17       1       1       NO         TAG20171122T143053
49      B  F  A DISK        22-NOV-17       1       1       NO         TAG20171122T155231
50      B  F  A DISK        22-NOV-17       1       1       NO         TAG20171122T161903
51      B  F  A DISK        22-NOV-17       1       1       NO         TAG20171122T194608
52      B  F  A DISK        01-DEC-17       1       1       NO         TAG20171201T154354



Oracle 12c - Convert standby database into a Primary



If your primary is not available and you want to convert your standby database into Primary manually then use the below steps on the standby database.


SQL> select open_mode,database_role from v$database;

OPEN_MODE            DATABASE_ROLE
-------------------- ----------------
READ ONLY            PHYSICAL STANDBY

SQL> recover managed standby database cancel;
ORA-16136: Managed Standby Recovery not active


SQL>
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;

Database altered.

SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;

Database altered.

SQL> select open_mode,database_role from v$database;

OPEN_MODE            DATABASE_ROLE
-------------------- ----------------
MOUNTED              PRIMARY

SQL> alter database open;

Database altered.

SQL> select open_mode,database_role from v$database;

OPEN_MODE            DATABASE_ROLE
-------------------- ----------------
READ WRITE           PRIMARY