0

Good morning, reading the documentation from Oracle I found a way that I feel comfortable with when taking a backup of a database, but I can't find satisfying informations about restoring them... In the following code I'll show how I take the backup, assuming that the database has activated Archivelog and Controlfile autobackup, using Win2016 Server and Oracle 12c and oracle_sid correctly set:

    C:\> sqlplus owner/password@database as sysdba
    SQL> shutdown immediate;
    SQL> startup mount;
    SQL> exit;
    C:\> rman target owner/password@database
    RMAN> backup archivelog all format "E:\Backup\%d_ALogs_%e_%p.Dmp" delete input;
    RMAN> backup database format "E:\Backup\%d_%f_%p.Dmp";
    RMAN> alter database open;

At this time I copy the backup of the control file in the same directory and compress all the files in .7z, then I move it in a different server. Let's assume I want to move this database in a different server, or I need to format the same server due to a failure, or a system update (to Win 2019, for example) and I need to restore it. After installing Oracle 12c (for simplicity I'll install the same version, but I may want/need to install the 19th; let's face this problem in a second time), I create a new database with the same name of the old one, the same owner with the same password, I assign system and sysdba the same password as the old one and the same configuration parameters. Everything is the same, just the OS and Oracle are freshly installed and I need to restore the database. As far as I can understand, I don't need the Archivelogs backup, because during the backup I flushed them all and stored permanently in the databse, am I right? I don't need the Control file either, because the database has been created by Oracle, am I right? Now I extract the last .Dmp file I created in E:\Backup, shutdown the database as my previously code and, in RMAN, I give:

    RMAN> restore database <with what parameters?>;
    RMAN> recover database;
    RMAN> alter database open;

I found different ways to specify the parameters, but the most correct, always as far as I can understand, is:

    RMAN> restore database format "E:\Backup\filename.Dmp";

Can it work?

Thank you very much in advance and excuse me for being so verbose, but I needed/wanted to be as much precise as possible.

2 Answers 2

1

Everything is the same

Wrong. Each database has a unique database id (dbid).

I don't need the Archivelogs backup, because during the backup I flushed them all and stored permanently in the databse

Basically correct because you have shutdown the database. However, Oracle don't use the terminology 'flush the Archivelogs'. It flushes the redo log buffer to redo log files, then (when the redo log file is full or when Oracle is requested to) it archives the redo log files to archivelogs.

I don't need the Control file either

Wrong. Your original DB and the newly created DB has different dbid.

You don't need to pre-create a DB. Actually you would probably fail to proceed if you start from your need DB.

Your full DB backup should have multiple files. There should be a "Control File auto backup", which is a small (tens of MB) file start with c_ by default.

The commands to restore the database should be

  1. Set environment variable ORACLE_SID.

  2. Restore spfile (These can be skipped if you don't need to restore spfile or pfile from backup)

     RMAN> startup nomount
     RMAN> restore spfile from '<path to Control File auto backup>';
     RMAN> shutdown immedate
     RMAN> startup nomount
    
  3. Restore controlfile and database

     RMAN> restore controlfile from '<path to Control File auto backup>';
     RMAN> shutdown immedate
     RMAN> startup mount
     RMAN> restore database;
     RMAN> recover database; -- shouldn't be needed because DB was shutdown gracefully before backup
     RMAN> alter database open resetlogs;
    
0

Probably not. When you restore a database from an rman backup, you are actually building that database from scratch. The database that you 'pre-created' on the new server means nothing. You need to restore your backup, starting with a restore of its spfile, then a restore of its own control file. Also since you had the database shut down for the backup, you have a 'consistent' backup, and so the archivelogs do not come into play. Also, I'd not name your rman backups '.dmp', as that is the default extension for the files created by exp or expdp. Other people looking at those files will assume they are export dumps, not rman backups.

4
  • First of all thank you for the answer. The reason why I shutdown the database is exactly to have a consistent backup... What does the spfile and control file contain, exactly? Ps: I'll change the extension of the backup, maybe .bak, .bkp or rman should do...
    – Alex
    Mar 11 at 18:21
  • FWIW, I always used '.rman', As for spfile and control file .... sounds like you need some grounding in oracle basics, not just backup and recovery. Spend some quality time with Oracle Database Concepts. As for actual explanation of those two files, it is really beyond the scope of comments here. The control file is explained pretty will in the Concepts manual, but I find nothing in it about the spfile (Cont . . . .)
    – EdStevens
    Mar 11 at 20:30
  • (. . . continued) The spfile is a small binary file and is the very first file read when you start a database. It contains information abut run-time parameters, how to allocate memory for the instance, and where to find the control file(s). In the absence of an spfile, the starting instance will look for a 'pfile', which is a clear text counterpart to the spfile.
    – EdStevens
    Mar 11 at 20:32
  • I tried to read more carefully the Oracle docs, just to find out that I'm in need of a disaster recovery... 1. I was sure that the backup files could be moved from the place they were put by Oracle (cut/paste), they need to stay in their position 2. Old controlfile backups have been deleted, so I only have the file I cut/pasted in a different directory (35Gb about) 3. I found a way to duplicate the database, using only the auxiliary instance and the backup file, but still it asks for the controlfile 4. Recuva restored the pfile and xwallet, but not a valid controlfile Help needed...
    – Alex
    Jun 17 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.