Tuesday, July 29, 2014

How to install Oracle 11g the easy way.

This website has the best method, using YUM you download a package that contains most of the PREREQs already to go.

http://www.oracle-base.com/articles/11g/oracle-db-11gr2-installation-on-oracle-linux-6.php

Monday, July 7, 2014

Temp file can't grow, how to add a file

Here is what I used to add 16GB to the temp space on Oracle 11g.

ALTER TABLESPACE "TEMP2" ADD TEMPFILE '/home/oracle/app/oracle/oradata/orcl/temp03.dbf' SIZE 100M AUTOEXTEND ON NEXT 500M MAXSIZE 16G

Added these to TEMP table space on 2015-11-05
ALTER TABLESPACE "TEMP" ADD TEMPFILE
  '/home/oracle/app/oracle/oradata/orcl/temp8.dbf' SIZE 100M REUSE AUTOEXTEND ON NEXT 500M MAXSIZE 8192M;

ALTER TABLESPACE "TEMP" ADD TEMPFILE
  '/home/oracle/app/oracle/oradata/orcl/temp9.dbf' SIZE 100M REUSE AUTOEXTEND ON NEXT 500M MAXSIZE 8192M;

ALTER TABLESPACE "TEMP" ADD TEMPFILE '/home/oracle/app/oracle/oradata/orcl/temp10.dbf' SIZE 100M REUSE AUTOEXTEND ON NEXT  500M MAXSIZE 8192M;

ALTER TABLESPACE "TEMP" ADD TEMPFILE '/home/oracle/app/oracle/oradata/orcl/temp11.dbf' SIZE 100M REUSE AUTOEXTEND ON NEXT 500M MAXSIZE 8192M;

commit;

Loading Staging Data into test database (Data Manager version 2.5 (CCC 2.5)

This morning I connected to a customer Oracle DB with SQL Developer 4.x

Selected these tables:

  • CLUSTER_STAGING_DATA_TABLE.ctl
  • CLUSTER_METRICS_STAGING_DATA_TABLE.ctl
  • ENTITY_METRICS_STAGING_DATA_TABLE.ctl
  • GROUP_CONFIG_STAGING_DATA_TABLE.ctl
  • RESOURCE_POOL_STAGING_DATA_TABLE.ctl
  • RESOURCE_POOL_METRICS_STAGING_DATA_TABLE.ctl
  • SERVER_METRICS_STAGING_DATA_TABLE.ctl
  • SERVER_STAGING_DATA_TABLE.ctl
  • SERVER_VIRTUAL_STAGING_DATA_TABLE.ctl

 Then Exported to Loader (Separate Files, Compressed).  Took all defaults.
Saved As filename:  YYYY-MM-DD_Deploy.zip

Then Exported the  TRANSACTIONS_CONFIG table to "Insert" statements.
  --- Only those statements for transactions still in the staging tables.

Transferred both files to my workstation.


Then I ran the INSERT statements for last night's jobs.

Then I ran these IMPORT statements from the Command line:

command line:
sqlldr cccuser/cccuser@oralinux/orcl control=CLUSTER_STAGING_DATA_TABLE.ctl
sqlldr cccuser/cccuser@oralinux/orcl control=CLUSTER_METRICS_STAGING_DATA_TABLE.ctl
sqlldr cccuser/cccuser@oralinux/orcl control=ENTITY_METRICS_STAGING_DATA_TABLE.ctl
sqlldr cccuser/cccuser@oralinux/orcl control=GROUP_CONFIG_STAGING_DATA_TABLE.ctl
sqlldr cccuser/cccuser@oralinux/orcl control=RESOURCE_POOL_STAGING_DATA_TABLE.ctl
sqlldr cccuser/cccuser@oralinux/orcl control=RESOURCE_POOL_METRICS_STAGING_DATA_TABLE.ctl
sqlldr cccuser/cccuser@oralinux/orcl control=SERVER_METRICS_STAGING_DATA_TABLE.ctl
sqlldr cccuser/cccuser@oralinux/orcl control=SERVER_STAGING_DATA_TABLE.ctl
sqlldr cccuser/cccuser@oralinux/orcl control=SERVER_VIRTUAL_STAGING_DATA_TABLE.ctl

----------------- Transactions_Config ---- updates

I ran these in SQL developer to add entries into Transactions Config.

Insert into TRANSACTIONS_CONFIG (TRANSACTION_ID,STATUS,USER_ID,START_TIMEKEY,DATASOURCE_ID,END_TIMEKEY,COMMENTS,FILENAME,DELETED_FLAG,PARENT_TRANSACTION_ID,START_MIGRATION,END_MIGRATION,LOAD_JOB_ID,MIGRATE_JOB_ID,DATA_WINDOW_START,DATA_WINDOW_END,LOAD_DATA_RANGE_PERCENT,LOAD_STATUS_ID,MIGRATE_STATUS_ID,ROWS_LOADED,SYSTEM_ROWS_LOADED,CONFIG_ROWS_LOADED,SAP_ROWS_LOADED,SAP_CONFIG_ROWS_LOADED) values (206,112,0,to_date('07-JUL-14','DD-MON-RR'),5,to_date('07-JUL-14','DD-MON-RR'),' ',' ','0',null,to_date('07-JUL-14','DD-MON-RR'),to_date('07-JUL-14','DD-MON-RR'),103,null,to_date('06-JUL-14','DD-MON-RR'),to_date('06-JUL-14','DD-MON-RR'),0,102,112,78336,78336,240,0,0);
Insert into TRANSACTIONS_CONFIG (TRANSACTION_ID,STATUS,USER_ID,START_TIMEKEY,DATASOURCE_ID,END_TIMEKEY,COMMENTS,FILENAME,DELETED_FLAG,PARENT_TRANSACTION_ID,START_MIGRATION,END_MIGRATION,LOAD_JOB_ID,MIGRATE_JOB_ID,DATA_WINDOW_START,DATA_WINDOW_END,LOAD_DATA_RANGE_PERCENT,LOAD_STATUS_ID,MIGRATE_STATUS_ID,ROWS_LOADED,SYSTEM_ROWS_LOADED,CONFIG_ROWS_LOADED,SAP_ROWS_LOADED,SAP_CONFIG_ROWS_LOADED) values (205,112,0,to_date('07-JUL-14','DD-MON-RR'),1,to_date('07-JUL-14','DD-MON-RR'),' ',' ','0',null,to_date('07-JUL-14','DD-MON-RR'),to_date('07-JUL-14','DD-MON-RR'),100,null,to_date('06-JUL-14','DD-MON-RR'),to_date('06-JUL-14','DD-MON-RR'),0,102,112,153214,153214,413,0,0);
Insert into TRANSACTIONS_CONFIG (TRANSACTION_ID,STATUS,USER_ID,START_TIMEKEY,DATASOURCE_ID,END_TIMEKEY,COMMENTS,FILENAME,DELETED_FLAG,PARENT_TRANSACTION_ID,START_MIGRATION,END_MIGRATION,LOAD_JOB_ID,MIGRATE_JOB_ID,DATA_WINDOW_START,DATA_WINDOW_END,LOAD_DATA_RANGE_PERCENT,LOAD_STATUS_ID,MIGRATE_STATUS_ID,ROWS_LOADED,SYSTEM_ROWS_LOADED,CONFIG_ROWS_LOADED,SAP_ROWS_LOADED,SAP_CONFIG_ROWS_LOADED) values (204,112,0,to_date('07-JUL-14','DD-MON-RR'),4,to_date('07-JUL-14','DD-MON-RR'),' ',' ','0',null,to_date('07-JUL-14','DD-MON-RR'),to_date('07-JUL-14','DD-MON-RR'),107,null,to_date('06-JUL-14','DD-MON-RR'),to_date('06-JUL-14','DD-MON-RR'),0,102,112,2165973,2165973,18994,0,0);
Insert into TRANSACTIONS_CONFIG (TRANSACTION_ID,STATUS,USER_ID,START_TIMEKEY,DATASOURCE_ID,END_TIMEKEY,COMMENTS,FILENAME,DELETED_FLAG,PARENT_TRANSACTION_ID,START_MIGRATION,END_MIGRATION,LOAD_JOB_ID,MIGRATE_JOB_ID,DATA_WINDOW_START,DATA_WINDOW_END,LOAD_DATA_RANGE_PERCENT,LOAD_STATUS_ID,MIGRATE_STATUS_ID,ROWS_LOADED,SYSTEM_ROWS_LOADED,CONFIG_ROWS_LOADED,SAP_ROWS_LOADED,SAP_CONFIG_ROWS_LOADED) values (203,112,0,to_date('07-JUL-14','DD-MON-RR'),6,to_date('07-JUL-14','DD-MON-RR'),' ',' ','0',null,to_date('07-JUL-14','DD-MON-RR'),to_date('07-JUL-14','DD-MON-RR'),106,null,to_date('06-JUL-14','DD-MON-RR'),to_date('06-JUL-14','DD-MON-RR'),0,102,112,1233111,1233111,19295,0,0);
Insert into TRANSACTIONS_CONFIG (TRANSACTION_ID,STATUS,USER_ID,START_TIMEKEY,DATASOURCE_ID,END_TIMEKEY,COMMENTS,FILENAME,DELETED_FLAG,PARENT_TRANSACTION_ID,START_MIGRATION,END_MIGRATION,LOAD_JOB_ID,MIGRATE_JOB_ID,DATA_WINDOW_START,DATA_WINDOW_END,LOAD_DATA_RANGE_PERCENT,LOAD_STATUS_ID,MIGRATE_STATUS_ID,ROWS_LOADED,SYSTEM_ROWS_LOADED,CONFIG_ROWS_LOADED,SAP_ROWS_LOADED,SAP_CONFIG_ROWS_LOADED) values (202,112,0,to_date('06-JUL-14','DD-MON-RR'),3,to_date('06-JUL-14','DD-MON-RR'),' ',' ','0',null,to_date('07-JUL-14','DD-MON-RR'),to_date('07-JUL-14','DD-MON-RR'),101,null,to_date('05-JUL-14','DD-MON-RR'),to_date('05-JUL-14','DD-MON-RR'),0,102,112,0,0,0,0,0);
Insert into TRANSACTIONS_CONFIG (TRANSACTION_ID,STATUS,USER_ID,START_TIMEKEY,DATASOURCE_ID,END_TIMEKEY,COMMENTS,FILENAME,DELETED_FLAG,PARENT_TRANSACTION_ID,START_MIGRATION,END_MIGRATION,LOAD_JOB_ID,MIGRATE_JOB_ID,DATA_WINDOW_START,DATA_WINDOW_END,LOAD_DATA_RANGE_PERCENT,LOAD_STATUS_ID,MIGRATE_STATUS_ID,ROWS_LOADED,SYSTEM_ROWS_LOADED,CONFIG_ROWS_LOADED,SAP_ROWS_LOADED,SAP_CONFIG_ROWS_LOADED) values (197,112,0,to_date('05-JUL-14','DD-MON-RR'),3,to_date('05-JUL-14','DD-MON-RR'),' ',' ','0',null,to_date('06-JUL-14','DD-MON-RR'),to_date('06-JUL-14','DD-MON-RR'),101,null,to_date('04-JUL-14','DD-MON-RR'),to_date('04-JUL-14','DD-MON-RR'),0,102,112,0,0,0,0,0);
Insert into TRANSACTIONS_CONFIG (TRANSACTION_ID,STATUS,USER_ID,START_TIMEKEY,DATASOURCE_ID,END_TIMEKEY,COMMENTS,FILENAME,DELETED_FLAG,PARENT_TRANSACTION_ID,START_MIGRATION,END_MIGRATION,LOAD_JOB_ID,MIGRATE_JOB_ID,DATA_WINDOW_START,DATA_WINDOW_END,LOAD_DATA_RANGE_PERCENT,LOAD_STATUS_ID,MIGRATE_STATUS_ID,ROWS_LOADED,SYSTEM_ROWS_LOADED,CONFIG_ROWS_LOADED,SAP_ROWS_LOADED,SAP_CONFIG_ROWS_LOADED) values (196,101,0,to_date('05-JUL-14','DD-MON-RR'),1,null,' ',' ','0',null,null,null,100,null,to_date('04-JUL-14','DD-MON-RR'),to_date('04-JUL-14','DD-MON-RR'),0,101,null,null,null,null,null,null);
Insert into TRANSACTIONS_CONFIG (TRANSACTION_ID,STATUS,USER_ID,START_TIMEKEY,DATASOURCE_ID,END_TIMEKEY,COMMENTS,FILENAME,DELETED_FLAG,PARENT_TRANSACTION_ID,START_MIGRATION,END_MIGRATION,LOAD_JOB_ID,MIGRATE_JOB_ID,DATA_WINDOW_START,DATA_WINDOW_END,LOAD_DATA_RANGE_PERCENT,LOAD_STATUS_ID,MIGRATE_STATUS_ID,ROWS_LOADED,SYSTEM_ROWS_LOADED,CONFIG_ROWS_LOADED,SAP_ROWS_LOADED,SAP_CONFIG_ROWS_LOADED) values (195,101,0,to_date('05-JUL-14','DD-MON-RR'),5,null,' ',' ','0',null,null,null,103,null,to_date('04-JUL-14','DD-MON-RR'),to_date('04-JUL-14','DD-MON-RR'),0,101,null,null,null,null,null,null);
Insert into TRANSACTIONS_CONFIG (TRANSACTION_ID,STATUS,USER_ID,START_TIMEKEY,DATASOURCE_ID,END_TIMEKEY,COMMENTS,FILENAME,DELETED_FLAG,PARENT_TRANSACTION_ID,START_MIGRATION,END_MIGRATION,LOAD_JOB_ID,MIGRATE_JOB_ID,DATA_WINDOW_START,DATA_WINDOW_END,LOAD_DATA_RANGE_PERCENT,LOAD_STATUS_ID,MIGRATE_STATUS_ID,ROWS_LOADED,SYSTEM_ROWS_LOADED,CONFIG_ROWS_LOADED,SAP_ROWS_LOADED,SAP_CONFIG_ROWS_LOADED) values (194,112,0,to_date('05-JUL-14','DD-MON-RR'),4,to_date('05-JUL-14','DD-MON-RR'),' ',' ','0',null,to_date('06-JUL-14','DD-MON-RR'),to_date('06-JUL-14','DD-MON-RR'),107,null,to_date('04-JUL-14','DD-MON-RR'),to_date('04-JUL-14','DD-MON-RR'),0,102,112,2166204,2166204,19008,0,0);
Insert into TRANSACTIONS_CONFIG (TRANSACTION_ID,STATUS,USER_ID,START_TIMEKEY,DATASOURCE_ID,END_TIMEKEY,COMMENTS,FILENAME,DELETED_FLAG,PARENT_TRANSACTION_ID,START_MIGRATION,END_MIGRATION,LOAD_JOB_ID,MIGRATE_JOB_ID,DATA_WINDOW_START,DATA_WINDOW_END,LOAD_DATA_RANGE_PERCENT,LOAD_STATUS_ID,MIGRATE_STATUS_ID,ROWS_LOADED,SYSTEM_ROWS_LOADED,CONFIG_ROWS_LOADED,SAP_ROWS_LOADED,SAP_CONFIG_ROWS_LOADED) values (193,112,0,to_date('05-JUL-14','DD-MON-RR'),6,null,' ',' ','0',null,to_date('05-JUL-14','DD-MON-RR'),to_date('05-JUL-14','DD-MON-RR'),106,null,to_date('04-JUL-14','DD-MON-RR'),to_date('04-JUL-14','DD-MON-RR'),0,103,112,null,null,null,null,null);
commit;


Then to see the jobs this query:

select transaction_id,START_TIMEKEY,status,load_status_id,migrate_status_id from transactions_config where status=101;  --Show jobs in progress

To view last 10 transactions that completed Staging, Migration, or in Progress

select * from --Show last 10 jobs complete
(select transaction_id,START_TIMEKEY,status,load_status_id,migrate_status_id,transactions_config.ROWS_LOADED
from transactions_config
  where status in (102,112,101)
  order by START_TIMEKEY desc)
where rownum <11
order by TRANSACTION_ID desc;


To update the Status of Transactions found I used:

update transactions_config
set status= 102,
load_status_id = 102,
migrate_status_id = null
where  TRANSACTION_ID in (206,203,204,205,195,196);
commit; 


Thursday, July 3, 2014

Sequence numbers and changing status codes

update transactions_config
set status= 102,
load_status_id = 102,
migrate_status_id = null
where status = 112
and TRANSACTION_ID in (186,185,184,183);
commit;

drop sequence "CCCUSER"."JOB_ID_SEQ";
CREATE SEQUENCE  "CCCUSER"."JOB_ID_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 108 CACHE 2 NOORDER  NOCYCLE ;

drop sequence  "CCCUSER"."MIGRATION_SESSION_ID_SEQ";
CREATE SEQUENCE  "CCCUSER"."MIGRATION_SESSION_ID_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 81 CACHE 20 NOORDER  NOCYCLE ;


drop SEQUENCE  "CCCUSER"."JOB_DGE_DETAIL_SEQ";
CREATE SEQUENCE  "CCCUSER"."JOB_DGE_DETAIL_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 107 CACHE 2 NOORDER  NOCYCLE ;

drop sequence "CCCUSER"."JOB_ACTIVITY_MIGRATE_SEQ";
CREATE SEQUENCE  "CCCUSER"."JOB_ACTIVITY_MIGRATE_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 175 CACHE 2 NOORDER  NOCYCLE ;

drop sequence "CCCUSER"."JOB_ACTIVITY_ERROR_SEQ";
CREATE SEQUENCE  "CCCUSER"."JOB_ACTIVITY_ERROR_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 600 CACHE 2 NOORDER  NOCYCLE ;

drop sequence "CCCUSER"."GROUP_XML_DOCUMENT_ID";
CREATE SEQUENCE  "CCCUSER"."GROUP_XML_DOCUMENT_ID"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 200 CACHE 10 NOORDER  NOCYCLE ;
commit;


select * from TRANSACTIONS_CONFIG where status = 112
and TRANSACTION_ID in (186,185,184,183);

How to setup Status of JOB to Staging Complete



1.     SQL Oracle script for Migrations set Status back to Staging Complete:


update transactions_config
set status= 102,
load_status_id = 102,
migrate_status_id = null
where status = 110;
commit;

Importing customer sample database without calling the DBA

After many attempts to load exported staging tables, I determined to try and load them into a BLANK database.

So I uninstalled CCC 2.5 and reinstalled CCC 2.5 (same version the customer is using).

Planning to import staging tables, after importing the DataSource_Config tables and the Transaction_config tables.

Then I should be able to change the latest transactions that migrated to Staging_completed...then it should work.

Hope it will work, more later.

Wednesday, July 2, 2014

Import Exported data into Staging tables.

SQLLDR - importing from EXPORTED data

This time I search and replaced the LDR files so they had the correct TransactionID and DataSourceID.

Then loaded them.


Tuesday, July 1, 2014

Converting the SQL Developer created CTL and LDR files

After loading the files using the command line SQLLDR I found that a new entry for the Transaction_Config had to be included.

The transaction_ID (5237 is what I used) had to be valid and unused on the destination Data Manager.

Also a valid DataSource_ID for VMWARE data type had to be in the system.
--Added the VMWARE DA, and created a fake Datasource without testing it...just saved it.
This gave me the new DataSource_ID (21 is what this created) I needed.

The staging tables imported will have the WRONG transaction ID and DataSourceID.

These must be corrected with code like this:

(Where clause was set to the wrong Transaction_ID=174.  I ran this twice. So the second time I had to use transaction ID = 5237 in my where clause...because it had already been fixed, but the Datasource_ID was still wrong.)

update server_Virtual_staging 
set Transaction_id=5237,DATASOURCE_ID=21
where transaction_id = 5237;  
commit;

update server_staging 
set Transaction_id=5237,DATASOURCE_ID=21
where transaction_id = 5237;
commit;

update Server_Metrics_staging
set Transaction_id=5237,DATASOURCE_ID=21
where transaction_id = 5237;
commit;

update resource_pool_staging
set Transaction_id=5237,DATASOURCE_ID=21
where transaction_id = 5237;
commit;

update RESOURCE_POOL_METRICS_STAGING
set Transaction_id=5237,DATASOURCE_ID=21
where transaction_id = 5237;
commit;

update GROUP_CONFIG_STAGING
set Transaction_id=5237,DATASOURCE_ID=21
where transaction_id = 5237;
commit;

update ENTITY_METRICS_STAGING
set Transaction_id=5237,DATASOURCE_ID=21
where transaction_id = 5237;
commit;

update CLUSTER_STAGING
set Transaction_id=5237,DATASOURCE_ID=21
where transaction_id = 5237;
commit;

update CLUSTER_METRICS_STAGING
set Transaction_id=5237,
DATASOURCE_ID=21
where transaction_id = 5237;
commit;

SQLLDR - how to import data into tables exported from SQL DEV

BEFORE you do this, first add the Fake Transaction for the PULL that needs to happen before these can be added to the staging tables.


command line:
sqlldr cccuser/cccuser@oralinux/orcl control=CLUSTER_STAGING_DATA_TABLE.ctl

sqlldr cccuser/cccuser@oralinux/orcl control=CLUSTER_METRICS_STAGING_DATA_TABLE.ctl
sqlldr cccuser/cccuser@oralinux/orcl control=ENTITY_METRICS_STAGING_DATA_TABLE.ctl
sqlldr cccuser/cccuser@oralinux/orcl control=GROUP_CONFIG_STAGING_DATA_TABLE.ctl
sqlldr cccuser/cccuser@oralinux/orcl control=RESOURCE_POOL_STAGING_DATA_TABLE.ctl
sqlldr cccuser/cccuser@oralinux/orcl control=RESOURCE_POOL_METRICS_STAGING_DATA_TABLE.ctl
sqlldr cccuser/cccuser@oralinux/orcl control=SERVER_METRICS_STAGING_DATA_TABLE.ctl
sqlldr cccuser/cccuser@oralinux/orcl control=SERVER_STAGING_DATA_TABLE.ctl
sqlldr cccuser/cccuser@oralinux/orcl control=SERVER_VIRTUAL_STAGING_DATA_TABLE.ctl

This imports the CTL file definitions and it points to the DATA file LDR files!

Use Create Loader Exports from SQL Developer.

Read the contents of the CTL file to see what folder it is expected to be in!
C:\CCC\Downloads\  - folder where I had to place the files.

Below is CTL file for Cluster_metrics_Staging

OPTIONS (ERRORS=50)
LOAD DATA 
INFILE 'C:\CCC\Downloads\CLUSTER_METRICS_STAGING_DATA_TABLE.ldr' "str '{EOL}'"
APPEND
CONTINUEIF NEXT(1:1) = '#'
INTO TABLE "CLUSTER_METRICS_STAGING"
FIELDS TERMINATED BY'|'
OPTIONALLY ENCLOSED BY '"' AND '"'
TRAILING NULLCOLS ( 
"CLUSTER_ID" CHAR (255),
"CLUSTER_NAME" CHAR (255),
"METRIC_SOURCE" CHAR (255),
"STD_METRIC_NAME" CHAR (255),
"METRIC_TIME" DATE "YYYY-MM-DD HH24:MI:SS" ,
"GMT_METRIC_TIME" DATE "YYYY-MM-DD HH24:MI:SS" ,
"DURATION" ,
"METRIC_VALUE" ,
"GMT_OFFSET" ,
"TRANSACTION_ID" ,
"DATASOURCE_ID" ,
"INSERT_DATE" DATE "YYYY-MM-DD HH24:MI:SS" ,
"GAP" )


Wednesday, June 18, 2014

Automate Nightly database backup

Implement Nightly Oracle Hot  Backup – Non RMAN/OEM Approach
1.    Ensure the following files are located in your database server’s scripts directory (eg. /oraprod/oracle/scripts).
a.    hotbkup_orcl.sh
b.    hotbkup.sh
2.    Replace the existing script directory specified in hotbkup.sh to reflect the correct scripts directory.
Script file
# Invoke hot backup script. Make sure to specify the correct scripts directory.
cd /var/opt/oracle/scripts
./hotbkup_orcl.sh orcl
3.    Make appropriate changes to the values of the following parameters in hotbkup_orcl.sh file.
a.  export SPOOL=/tmp/hotbackup.lst
b.  export BACKUP_DEST=/oraprod/orabkup
c.  export OLD_BACKUP_DEST=/orabkup/oraprod
d.  export SYSTEM_PWD=yadayadayada

4.    Encrypt hotbkup_orcl.sh file to preserve sensitive information.
a.  $ gpg –c hotbkup_orcl.sh
  Enter passphrase: <enter your password here >

a.  To decrypt file use gpg command:
$ gpg hotbkup_orcl.sh.gpg
gpg: CAST5 encrypted data
gpg: encrypted with 1 passphrase
File `hotbkup_orcl.sh' exists. Overwrite? (y/N) y
gpg: WARNING: message was not integrity protected


5.    As oracle software owner OS id, run
a.    crontab –e
b.    Make an entry as follows to execute the backup script to run at 1.30 a.m.
                                          i.    59 23 * * 1,2,3,4,5 /var/opt/oracle_dm/scripts/hotbkup.sh – This entry executes the script orabkup.sh which in turn backs up the oracle database.

Automate archive log deletion
 Automate archive log deletion.
1.    Ensure the following files are located in your database server’s scripts directory (eg. /oraprod/oracle/scripts).
a.    delarch.sh
2.    Replace the existing archive destination specified in delarch.sh with the correct archive log destination.
Script File
# Script to delete archive log files older than 2 days.
find /u03/oracle/arch  -name '*.log' -mtime +2 -exec rm -f {} ';'
3.    As oracle software owner OS id, run
a.    Crontab -e
b.    Make an entry as follows to execute archive log deletion script to run at 12.30 a.m.
                                          i.    01 23 * * 1,2,3,4,5 /var/opt/oracle_dm/scripts/delarch.sh  -- This entry executes the script /home/oracle/scripts/delarch.sh which in turn deletes the archive logs older than 2 days.



Referenced scripts.

hotbkup.sh
# Move backup log file
mv /oraprod/orabkup/logs/orabkup.log /oraprod/orabkup/logs/orabkup.`date '+%y%m%d%H%M%S'`
# Start of hot backup
cd /var/opt/oracle_dm/scripts
./hotbkup_orcl.sh orcl


hotbkup_orcl.sh

#===================================================================#
#                                                                   #
# Name     : hotbkup_orcl.sh                                           #
# Synopsis : Performs an online backup of the database specified in #
#            the script's only argument.                            #
#            Please remember to customize the values in the         #
#            CONSTANTS section before attempting to use the script. #
# Arguments: The following parameters must be provided when         #
#            running this script:                                   #
#              1) The sid of the database to run against            #
#===================================================================#

#--------------------------------------------------------------------
# ARGUMENTS

export ORACLE_SID=${1}

#--------------------------------------------------------------------
# CONSTANTS

export HOME=`awk -F: '/oracle/ {print $6}' /etc/passwd`
export DATESTAMP=`date '+%m-%d-%y_%H:%M:%S'`
export SPOOL=/tmp/hotbackup.lst

export BACKUP_DEST=/oraprod/orabkup
export OLD_BACKUP_DEST=/oraprod/orabkup
export SYSTEM_PWD=bkuptemppw
export ORATAB=/etc/oratab
#--------------------------------------------------------------------
# FUNCTIONS

usage()
{

      echo ""
      echo "USAGE:"
      echo "******"
      echo "hotbackup.sh sid"
      echo ""
      echo "where sid    = database sid to run against"

}

derive_oracle_paths()
{

      if [ -f ${ORATAB} ]; then
            export ORACLE_HOME=`awk -F: "/^${ORACLE_SID}:/ {print \\$2; exit}"\
                  ${ORATAB} 2>/dev/null`
            export PATH=${ORACLE_HOME}/bin:${PATH}
      else
            echo "" >> ${LOG}
            echo "ERROR:" >> ${LOG}
            echo "******" >> ${LOG}
            echo "${ORATAB} not found" >> ${LOG}
            echo "Aborting hotbackup.sh" >> ${LOG}
            exit 1
      fi

}

check_parameter()
{

      if [ `grep -c ${ORACLE_SID} ${ORATAB}` -eq 0 ]; then
            echo "" >> ${LOG}
            echo "ERROR:" >> ${LOG}
            echo "******" >> ${LOG}
            echo "Oracle sid ${ORACLE_SID} not found in ${ORATAB}" >> ${LOG}
            echo "Aborting hotbackup.sh" >> ${LOG}
            exit 1
      fi

}

do_backup()
{

      sqlplus system/${SYSTEM_PWD} << _E_O_F

      col tablespace_name     noprint
      col seqn                noprint
      set pagesize            0
      set linesize            132
      set feedback            off
      set sqlprompt           ""

      Whenever SQLERROR exit 1

      select chr(1)   tablespace_name
      ,      -9999    seqn
      ,      'alter system switch logfile;'
      from   dual
      UNION
      select chr(1)   tablespace_name
      ,      -9998    seqn
      ,      'alter database backup controlfile to '''||'${BACKUP_DEST}/controlfile_${ORACLE_SID}.HOT.before'' reuse;'
      from   dual
      UNION
      select tablespace_name
      ,      0
      ,      'alter tablespace '||tablespace_name||' begin backup;'
      from   sys.dba_tablespaces
      where  status = 'ONLINE' and tablespace_name not in ('TEMP')
      UNION
      select tablespace_name
      ,      file_id
      ,      '!gzip < '||file_name||'> ${BACKUP_DEST}/'||substr(file_name,instr(file_name,'/',-1) + 1) || '.Z'
      from   sys.dba_data_files
      where  status = 'AVAILABLE'
      UNION
      select tablespace_name
      ,      9999
      ,      'alter tablespace '||tablespace_name||' end backup;'
      from   sys.dba_tablespaces
      where  status = 'ONLINE' and tablespace_name not in ('TEMP')
      UNION
      select chr(255) tablespace_name
      ,      9998             seqn
      ,      'alter database backup controlfile to '''||'${BACKUP_DEST}/controlfile_${ORACLE_SID}.HOT.after'' reuse;'
      from   dual
      UNION
      select chr(255) tablespace_name
      ,      9999             seqn
      ,      'alter system switch logfile;'
      from   dual
      ORDER  BY 1,2

      spool  ${SPOOL}
      /
      spool  off

      start ${SPOOL}

      exit
_E_O_F

}
#-------------------------------------------------------------------- 
# MAIN                                                                
                                                                      
if [ $# -lt 1 ]; then                                                 
        usage                                                          
        exit 1                                                        
fi                                                                    
                                                                      
derive_oracle_paths                                                   
check_parameter                                                       
do_backup                                                             
#cp $ORACLE_HOME/dbs/init$ORACLE_SID.ora  $BACKUP_DEST                 


delarch.sh
# To delete archive log files older than 2 days.

find /oraprod/oracle/arch  -name '*.dbf' -mtime +2 -exec rm -f {} ';'