Thursday, April 16, 2015

How to change the default location for archivelog backup copies in RMAN

The default location for archivelog backups is the FRA (if defined) or $OH/dbs.
However once you use 'format' you are overriding the default - so the only way you can do this is to first do the backup to the usual location using a specific tag eg 'ARCH' to idenity the archuivelog backups.
Then you can backup the backupsets with that tag eg

RMAN> backup copies 2 backupset from tag 'ARCH' format 'd:\temp\%U', 'd:\keep\%U' not backed up 2 times;

so you would use a shell script to generate a tag with a specific date - to ensure you are only backing up new archivelog backupsets - the 'not backed up 2 times' doubly ensures that a backupset is only backed up once :

RMAN> backup archivelog sequence 52 tag 'ARCH';

Starting backup at 15-apr-15 08:57:28
using channel ORA_DISK_1
...
piece handle=C:\APP\11G\FAST_RECOVERY_AREA\T11204\BACKUPSET\2015_04_15\O1_MF_ANNNN_ARCH_BLW6H8GH_.BKP tag=ARCH comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 15-apr-15 08:57:29

BS Key Size
------- ----------
182 5.81M <=== bskey 52

List of Archived Logs in backup set 182
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- ------------------ ---------- ---------
1 52 9213444 13-apr-15 16:09:34 9240678 14-apr-15 07:35:00

RMAN> backup copies 2 backupset from tag 'ARCH' format 'd:\temp\%U', 'd:\keep\%U' not backed up 1 times;

Starting backup at 15-apr-15 08:57:38
using channel ORA_DISK_1
skipping backup set key 179; already backed up 2 time(s)
skipping backup set key 181; already backed up 2 time(s)
skipping backup set key 182; already backed up 1 time(s) <========== original backup , so you need 'not backed up 2 times for this to work
Finished backup at 15-apr-15 08:57:39

RMAN> backup copies 2 backupset from tag 'ARCH' format 'd:\temp\%U', 'd:\keep\%U
' not backed up 2 times;

Starting backup at 15-apr-15 08:57:57
using channel ORA_DISK_1
skipping backup set key 179; already backed up 2 time(s)
skipping backup set key 181; already backed up 2 time(s)
channel ORA_DISK_1: input backup set: count=219, stamp=877078648, piece=1
channel ORA_DISK_1: starting piece 1 at 15-apr-15 08:57:57
channel ORA_DISK_1: backup piece C:\APP\11G\FAST_RECOVERY_AREA\T11204\BACKUPSET\2015_04_15\O1_MF_ANNNN_ARCH_BLW6H8GH_.BKP
piece handle=D:\TEMP\6RQ4EA3O_1_2 comment=NONE
piece handle=D:\KEEP\6RQ4EA3O_1_3 comment=NONE
channel ORA_DISK_1: finished piece 1 at 15-apr-15 08:57:58 with 2 copies
channel ORA_DISK_1: backup piece complete, elapsed time: 00:00:01
Finished backup at 15-apr-15 08:57:58

if you are creating multiple copies eg TWO copies, then each backup has 3 copies in total so you would need to us 'not backed up 3 times' 

No comments:

Post a Comment