Sunday, December 9, 2012

Shell Scripting of Rman Backup


This will create the backup on daily basis with new date folder .

Steps:- Change the red coloured location as per your path and destination.

then open new file vi backup.sh
copy and paste all the script in backup.sh file.
save the file.
then give the permission to backup.sh file.........     chmod -R 777 backup.sh
then run the file for testing purpose.

sh backup.sh and enjoy.

#

now=$(date +"%b-%d-%y")
echo $now
bakup=bakup-$now
mkdir -p /backup/daily_rmanbk/backups/$bakup
# Environment setting of database Tier (TEST)
rman msglog "/rmanbkp/hot_backup/logs/datebackuplog-$now.log" <<EOF

connect target /;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/rmanbkp/hot_backup/$bakup/%d_%F.ctl';
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO BACKUPSET;
run {
CROSSCHECK BACKUP;
BACKUP AS COMPRESSED BACKUPSET DATABASE FORMAT '/rmanbkp/hot_backup/$bakup/datafiles_%d_%s_%p_%c.bkp';
sql 'ALTER SYSTEM ARCHIVE LOG CURRENT';
BACKUP AS COMPRESSED BACKUPSET ARCHIVELOG ALL FORMAT '/rmanbkp/hot_backup/$bakup/archivelogs_%d_%s_%p_%c.bkp' DELETE INPUT;
BACKUP AS COMPRESSED BACKUPSET CURRENT CONTROLFILE FORMAT '/rmanbkp/hot_backup/$bakup/controlfiles_%d_%s_%p_%c.bkp';
crosscheck archivelog all;
CROSSCHECK BACKUP;
DELETE NOPROMPT OBSOLETE;
DELETE NOPROMPT EXPIRED BACKUP;
}
Exit;
EOF


Note:- Try everything at your own risk, if any thing happens wrong with your database so blogger will not be responsible.

No comments:

Post a Comment