Restore Database

This page is still in construction, and his content is still not yet very safe to be done in production
The explanation here, can be done by instance if you want to put a a database to another complet computer, you only need the same version of oracle.

You first need to do a full backup of the database you want to move, and then make available these file to the other system, to be used with rman.

At this moment, I did the procedure only with backup piece, and not yet with copy of datafile copy. I think it's better to do like that, because there is much smaller size to move. When you used compress backup piece with RMAN, you database can be 10x smaller than the size of all your datafile !

At this moment, all the information that rman get is from the controlfile, I still didn't create any special catalog only for rman, so as you might guess, the controlfile is very important for us !

After doing your full backup of the database, you need to known where all your file is, in which directory. Put these files on a cd, dvd, nfs share or something other that can be reach by the other system.

Then, on the other system, start the oracle instance in mount mode :

rman> startup mount;

and then you need to get rman aware of the backuped file from the other system :
rman> catalog backuppiece '/u0/data-rman/backup/bkp_661957308_32_1';

and you have to do that command for each of your backup file piece, and also the backuped controlfile, very important !
Otherwise, you can let rman discover all your backup files within a directory :
rman> catalog start with '/u0/data-rman/';

And rman will find any backup piece, backup copy of a data file, or something else in directory :


that rman recognize to restore a database, and will add this data to his catalog.
Now, if you do a :

rman> list backup;

you will probably see something new, but perhaps still some gaps due to the fact that we still don't use the proper controlfile !
Something like that :
List of Datafiles in backup set 5
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 678732741  02-SEP-08 /u01/app/oracle/oradata/oraasz/system01.dbf
  2       Full 678732741  02-SEP-08 /u01/app/oracle/oradata/oraasz/undotbs01.dbf
  3       Full 678732741  02-SEP-08 /u01/app/oracle/oradata/oraasz/sysaux01.dbf
  4       Full 678732741  02-SEP-08 /u01/app/oracle/oradata/oraasz/users01.dbf
  5       Full 678732741  02-SEP-08 
  6       Full 678732741  02-SEP-08 
  7       Full 678732741  02-SEP-08 
  8       Full 678732741  02-SEP-08 


As you can see, at this moment I don't known the names of files, and his directory !
So, we will restore the controlfile that get all the relevant information of our backup from the other system, the one from we do the backup !
rman> restore controlfile to '/my/dir/controlfile-new.ctl;

If all goes smoothly, you can now shutdown the instance of the database :
sqlplus> shutdown;

Copy the new control file to the one that is used to start up the database, and don't forget to do that for the 3 controlfile :
# cp /my/dir/controlfile-new.ctl /u01/oradata/control01.ctl;
# cp /my/dir/controlfile-new.ctl /u01/oradata/control02.ctl;
# cp /my/dir/controlfile-new.ctl /u01/oradata/control03.ctl;

Now, we can start our instance of the database :
sqllplus> startup mount;

And now, if you do a :
list backup;

something like that :
List of Datafiles in backup set 22
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1    0  Incr 678732741  02-SEP-08 /u01/app/oracle/oradata/oraasz/system01.dbf
  2    0  Incr 678732741  02-SEP-08 /u01/app/oracle/oradata/oraasz/undotbs01.dbf
  3    0  Incr 678732741  02-SEP-08 /u01/app/oracle/oradata/oraasz/sysaux01.dbf
  4    0  Incr 678732741  02-SEP-08 /u01/app/oracle/oradata/oraasz/users01.dbf
  5    0  Incr 678732741  02-SEP-08 /u0/oradata/4small_tables/small_tables01.dbf
  6    0  Incr 678732741  02-SEP-08 /u0/oradata/6large_tables/large_tables01.dbf
  7    0  Incr 678732741  02-SEP-08 /u0/oradata/1idx/indx01.dbf
  8    0  Incr 678732741  02-SEP-08 /u0/oradata/6large_tables/other_large.dbf

You can known, whether or not you have to create the specified directory or not, because by default rman will restore the datafile to the director he knowns from previous backup !!

If you got this error :

channel ORA_DISK_1: reading from backup piece /u0/data-rman/backup/bkp_664364117_40_1
ORA-19870: error reading backup piece /u0/data-rman/backup/bkp_664364117_40_1
ORA-19504: failed to create file "/u0/oradata/6large_tables/large_tables01.dbf"
ORA-27040: file create error, unable to create file
Linux Error: 2: No such file or directory
failover to previous backup

This is probably because the directory doesn't exist, or the property aren't good for oracle to create something ! So, double-check the property of the directory if oracle user can write into it !
And be sure that the directory that you saw in the command :

RMAN> list backup;

are all present on system, rman will restore the datafile there !
You normally would see all the backup files from the previous system, and we can now restore this datafile ! This is due that we start the instance database with the control file that contains all the relevant information for the backup, how we do the backup, when we did it, and so on…
Ok, let's go for the restore ! Before doing any futher step, don't forget to create the hierarchy of file system needed to put the datafile ! As rman only create the file and not the directory needed ! So, the host from where you did the backup, all the datafile was in this directory :


don't forget to create this directory on the host where you want to restore the database, and change the ownership to oracle :

# mkdir -p /u22/oradata;
# chown -R oracle /u022/oradata

Now, let's go again in rman prompt :
# rman target /

and in the rman prompt, let's restore the database :
rman> restore database;

Be patient now, as it can take a lot of time to restore a full database !
Then, you would probably need now to still do some recovery for you database, so :
rman> recover database;

And if you get an error like this one :
unable to find archive log
archive log thread=1 sequence=1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 09/09/2008 19:38:43
RMAN-06054: media recovery requesting unknown log: thread 1 seq 1 lowscn 678732742

You can now start up your db again, it try to recover with the archive file, but as it didn't find any one, and actually don't need it, your next step is to start-up the db with :
rman> alter database open resetlogs;

If you get any errors during this command, and it tell you about any datafile that need some recovery, let rman do the restore and recovery of the datafile :
rman> restore datafile '/dir/datafile-that-restore.dbf'

Voila, these simple few step is not too complicated to do a complete restore on an other database !
Ok at this point, I still got some errors, I will continue when I get more time to investigate the things…
Keep connection with the site of course… and if you have any question or advice, please let me known , give a message or send me an e-mail…
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License