Check whether database is running on archivelog mode or not
SQL> archive log list;
Database log mode No Archive Mode
Archive destination /D02/COMSID/db/apps_st/data/archive
Oldest online log sequence 9
Current log sequence 10
-----------------------------------------------------
Enable archivelog in the database first
Login as sysdba. Run the following command to setup archive_log_destination.
SQL> alter system set log_archive_dest_1='LOCATION=/D01/Directory1/dbreco/archivedest' scope=spfile;
Change the following two parameters if you are not mentioning any particular location in your RMAN scripts.
<![if !supportLists]>1. <![endif]>db_recovery_file_dest
<![if !supportLists]>2. <![endif]>db_recovery_file_dest_size
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database archivelog; [to take database in noarchivelog mode later on, use this command “alter database noarchivelog”]
SQL> alter database open;
Check Archive log list command again.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /D01/Directory1/dbreco/archivedest
Oldest online log sequence 9
Next log sequence to archive 10
Current log sequence 10
SQL> alter system archive log current;
Try to connect the target database RMAN repository with following command. Don’t forget to setup database environment file before.
Check the RMAN configuration with following command.
RMAN> show all;
You may be interested to change the retention period of the backup with the following command.
RMAN> configure retention policy to recovery window of 8 days;
The following are two RMAN scripts to take back up automatically. You need to attach these scripts to crontab for schedule run.
The following RMAN unix script is for FULL backup
. /D02/COMSID/db/tech_st/11.1.0/DEVLOP_hostname001.env
dt=`date +"%d.%m.%Y"`
rman <<EOF
spool msglog to '$HOME/CRON_LOGS/RMANFULLlogs/rman_FULL_$dt.log'
connect target /
crosscheck archivelog all;
run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
BACKUP as compressed backupset INCREMENTAL LEVEL=0 TAG HOT_PROD_BKP_LEVEL0 FILESPERSET 3
FORMAT '/D01/Directory1/dbreco/FULL/DEV_%s_%p_%t' DATABASE;
sql 'alter system archive log current';
RELEASE CHANNEL c1;
RELEASE CHANNEL c2;
allocate channel c1 type disk;
BACKUP FORMAT '/D01/Directory1/dbreco/FULL/DEVctrl_%s_%p_%t'
CURRENT CONTROLFILE;
RELEASE CHANNEL c1;
allocate channel c1 type disk;
BACKUP FILESPERSET 5
FORMAT '/D01/Directory1/dbreco/FULL/ARC_PROD_%s_%p_%t'
ARCHIVELOG ALL skip inaccessible;
RELEASE CHANNEL c1;
allocate channel d1 type disk;
copy current controlfile to '/D01/Directory1/dbreco/FULL/PRODcontrol.bkp';
RELEASE CHANNEL d1;
}
EXIT;
EOF
The following RMAN unix script is for daily incremental backup
#########################################################################
########################### RMAN INC BACKUP #############################
#########################################################################
. /D02/COMSID/db/tech_st/11.1.0/DEVLOP_hostname001.env
dt=`date +"%d.%m.%Y"`
rman <<EOF
spool msglog to '$HOME/CRON_LOGS/RMANINClogs/rman_INC_$dt.log'
connect target /
crosscheck archivelog all;
run {
sql 'alter system archive log current';
ALLOCATE CHANNEL C1 DEVICE TYPE DISK MAXPIECESIZE 4096M;
ALLOCATE CHANNEL C2 DEVICE TYPE DISK MAXPIECESIZE 4096M;
ALLOCATE CHANNEL C3 DEVICE TYPE DISK MAXPIECESIZE 4096M;
ALLOCATE CHANNEL C4 DEVICE TYPE DISK MAXPIECESIZE 4096M;
ALLOCATE CHANNEL C5 DEVICE TYPE DISK MAXPIECESIZE 4096M;
ALLOCATE CHANNEL C6 DEVICE TYPE DISK MAXPIECESIZE 4096M;
BACKUP as compressed backupset incremental level 1
DATABASE format '/D01/Directory1/dbreco/INC/rmanbkp_Dly_INC_DB_%D_%s_%p_%t.COMSID'
PLUS ARCHIVELOG
FORMAT '/D01/Directory1/dbreco/INC/rmanbkp_Dly_INC_ARC_%D_%s_%p_%t.COMSID';
}
If you want to recover the database till a time, use the following command.
Recover till point in time.
RUN
{
SET UNTIL TIME "to_date('Apr 03 2013 15:30:00','Mon DD YYYY HH24:MI:SS')";
RESTORE DATABASE;
RECOVER DATABASE;
}
RMAN> sql 'alter database open resetlogs';
No comments:
Post a Comment