Restoring an RMAN backup



  • 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 ;
        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.



  • 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 '';
       RMAN> shutdown immedate
       RMAN> startup nomount
      
    3. Restore controlfile and database

       RMAN> restore controlfile from '';
       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;
      



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2