Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Shell script should not refresh a production DB by mistake

Mark82May 26 2022 — edited May 26 2022

Oracle RDBMS version: 19c 
Platform : Linux

I am writing a shell script in which development pluggable databases will be refreshed from production pluggable databases.
Refreshing means Dropping the Dev PDB then creating it from production PDB.

Among other things, my shell script (currently under development) will prompt for 

Enter target PDB to refresh:
Enter source PDB name:

If the user executing my shell script wrongly enters a production PDB name for "Enter target PDB to refresh:" prompt, the script should abort the execution.
To implement this functionality, I can ask my bash script to lookup and text file which has all the production PDB names and abort the script if the entered PDB is found in this text file. But, my shop is large and new PDBs can get added occasionally. 
So, it may be a bad idea to manually update this look up text file. 

PDBs in my shop follows the naming convention: 
PDB_<4 or 5 Letter Apps Name>_P for production PDBs
and 
PDB_<4 or 5 Letter Apps Name>_D for development PDBs

In the shell script, I can write a logic to just abort execution of the shell script if somebody enters a PDB name that ends with "_P" when "Enter target PDB to refresh:" is prompted. 

What do you thing of the above-mentioned approaches ? Is there any other better approach I can follow to prevent my shell script from wrongly refreshing a production PDB ?

Comments
Post Details
Added on May 26 2022
3 comments
260 views