Can anyone share the proper method of RMAN restore to another server with another database name in oracle 11g(Windows platform). I'm totally confused with all the RMAN restore methods which I've found. I've taken the backup using the command
BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG;
Please confirm whether is it required to take control file backup separately.
Any help will be appreciated.
Best Answer
By default, the controlfile is backed up with your data. This is turned on or off by this command:
But as a matter of habit, I usually follow my data backups with:
I've had a great deal of trouble using duplicate database on Windows. Typically, I run into NTS permissions failures for the target login, which prevents the auxiliary db from creating. My efforts to troubleshoot these errors... well, I gave up.
This has led me to drafting a "playbook" document with all of the various OS and RMAN commands needed to manually restore a database to a new server with a new instance name. This also lets me tweak things to the new host with more control.
These scripts were tested in my Oracle 12.1 Windows environment, but may not be ideal for yours. I know RMAN is more willing to run SQL statements in 12c than in 11g, for example. Hopefully they help.
These scripts were created over several trial and error efforts, based on this link for the restore and this for changing the SID. The steps are:
Make sure everything is backed up.
I like to get a fresh copy of the spfile and controlfile, as it makes it easier later.
If your old and new servers do not use the same file paths for Oracle data, then run this:
take the output and change the paths / filenames as needed to match your new environment.
Copy backups from old to new host
Optional but I like the RMAN backup files to be on the box I'm restoring to. So log into the new server, and copy the full backups, archivelogs, and autobackup folders from the old server's fast recovery area. Note that you only need to go back to the most recent full backup, no need to get weeks worth of files.
Stage the new instance
On the new host, create your data folder, your fast recovery folder, and your admin folder. Make sure Oracle is installed and the Oracle user accounts have full control of these folders.
Create an empty instance, with the same name as the old:
Use RMAN to recover the SPFILE and Control Files. inside RMAN, set the DBID to match the old instance's DB ID, and the file names and paths to match your environment:
Do not close RMAN yet. Edit the pfile from the previous step in NotePad or NotePad++. Adjust the paths and memory requirements as needed to reflect the new environment. Don't change the name of the database, but change the folder paths to the new instance name.
Go back to your RMAN session and restore the control files. Again, fix paths as needed.
Restore your database files
Still in RMAN, inventory the backup files you copied over.
Now move your redo log files to their new folders in RMAN. You generated these scripts earlier.
And now we do the restore and recover, substitute the NewName scripts created earlier.
Once RMAN finishes the base restore and recovery, create a new SPFile.
Oracle does not backup or restore TEMP tablespace. This will prevent the full recovery from succeeding. Create a new temp tablespace, drop the old, and then rebuild the original one.
Change the instance name
At this point, Oracle should be running a fully restored copy of your database. But you want a new name. In RMAN:
Don't close RMAN, but from a new CMD window running as administrator:
Note the DBID this gives you, as you'll need it later for disaster recovery (notice that was our first RMAN command at the top).
Back in the RMAN window:
Start up your new DB!
From the other CMD window, create a new password file, and recreate the Windows services. Note, this utility does not use quotes around the path, unlike most cases in Oracle.
Start the database.
Back up your new database
At this point, your DB has no backups. Perform an RMAN backup before you do any work in this DB.