Reputation: 19
I need to generate a RMAN backup script dynamically and stored in a file so it can be executed later to backup database and also delete the old backups older than defined retention period. I am passing the value of retention period in a variable inside a script where it will generate RMAN script as shown below;
connect target /
set echo off;
run {
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
crosscheck archivelog all;
backup full
filesperset 5
format 'D:\Oracle\DB_Backup\P7app\daily_P7app_BACKUP_DBF__20221228_140306_%s_%p_%c'
tag daily_P7app_BACKUP
database
plus archivelog
filesperset 5
tag daily_P7app_BACKUP;
backup current controlfile
filesperset 5
format 'D:\Oracle\DB_Backup\P7app\daily_P7app_BACKUP_CF__20221228_140306_%s_%p_%c'
tag daily_P7app_BACKUP;
backup spfile
filesperset 5
format 'D:\Oracle\DB_Backup\P7app\daily_P7app_BACKUP_SP__20221228_140306_%s_%p_%c'
tag daily_P7app_BACKUP;
sql 'alter database backup controlfile to trace';
release channel c1;
release channel c2;
release channel c3;
}
delete noprompt obsolete;
delete noprompt expired backup;
The script assigns value of strretention based on the month end, year end.... but while generating the delete statement it is not printing the value of "stretention" hence the below statement is incomplete where it should be delete noprompt backup completed before 'sysdate - "value of stretention" tag daily_P7app_BACKUP; but unfortunately the value of stretention is not printed on the generated statement where it is an incomplete statement which is as;
delete noprompt backup completed before 'sysdate - tag daily_P7app_BACKUP;
release channel;
exit
Any idea why the value of a variable is missing?
I was expecting;
delete noprompt backup completed before 'sysdate -35';
but I got below incomplete statement with missing value of strretention;
delete noprompt backup completed before 'sysdate - ';
Upvotes: 0
Views: 42