Rman compressed backup provides an efficient way to save space and transfer time over the network when cloning databases.
Here I'm including 2 scripts: Single Instance Backup with Rman and Duplicate Database.
The single instance script is a simplified version of the Rman RAC Backup Script, it includes the backup type as a variable:
# v_backt = backup type= 'as copy', 'as compressed backupset' or 'as backupset'
v_backt='as compressed backupset'
And then it builds the backup command using this variable:
backup $v_backt database include current controlfile;
The Duplicate Database is a simple script, it will run fine if you configured correctly the clone database; the required steps can be found on the post How to Manually Clone a Database using Rman
, this is a brief checklist:
- Setup a pfile on the destination server
- Setup SQLNet to provide connectivity for the clone on the Source and Target servers
- Create all required directories on the destination server: bdump, udump, cdump, adump, archive log destination, db_create_file_dest
- Copy the Rman backup files, including relevant archived logs, to the destination server into the SAME PATH as in the source server.
If you don't have the same directory structure on the destination server, then you can create a symbolic link to provide the correct path.
- Startup nomount the clone database
- Execute the Duplicate Command
Once you have configured the destination server and successfully cloned the database, refreshing the clone do require the following steps:
- Make a new backup of the source database
- FTP/scp the backup files to the destination server, remember, to the AME PATH as in the source server.
- Use the Drop Database command on the clone to remove all datafiles, controlfiles and redologs:
- shutdown abort;
- startup mount exclusive restrict;
- drop database;
- Startup nomount the clone
- Execute the Duplicate Database command