문제

Backup type: Image copy.

Scenario: I want to 1 full db + 6 incremental backup and keep last 7 days backup on storage.

Here is my script:

RUN {

allocate channel c1 device type disk format '/path/%U';

allocate channel c2 device type disk format '/path/%U';

allocate channel c3 device type disk format '/path/%U';

allocate channel c4 device type disk format '/path/%U';

allocate channel c5 device type disk format '/path/%U';

allocate channel c6 device type disk format '/path/%U';

allocate channel c7 device type disk format '/path/%U';

allocate channel c8 device type disk format '/path/%U';

CROSSCHECK ARCHIVELOG ALL;

CROSSCHECK BACKUP;

CROSSCHECK BACKUPSET;

CROSSCHECK COPY;

DELETE NOPROMPT EXPIRED ARCHIVELOG ALL;

DELETE NOPROMPT EXPIRED BACKUP;

DELETE NOPROMPT EXPIRED BACKUPSET;

DELETE NOPROMPT EXPIRED COPY;

BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'my_tag_01' DATABASE;

RECOVER COPY OF DATABASE WITH TAG 'my_tag_01';

DELETE NOPROMPT ARCHIVELOG UNTIL TIME 'SYSDATE-3';

BACKUP SPFILE FORMAT '/path/spfile_%T_%U';

BACKUP CURRENT CONTROLFILE FORMAT '/path/cfile_%T_%U';

}

exit

How can I design my script according my scenario?

Thank you so much.

Best regards,

도움이 되었습니까?

해결책

I assume you want something like this:

RUN
{
  RECOVER COPY OF DATABASE 
    WITH TAG 'incr_update' 
    UNTIL TIME 'SYSDATE - 7';
  BACKUP
    INCREMENTAL LEVEL 1 
    FOR RECOVER OF COPY WITH TAG 'incr_update'
    DATABASE;
}

The first run takes a level 0 backup (even if the backup statement has level 1) All the following backups are level 1 backup that contain only the differences to the previous backups. The recovery statement recovers until SYSDATE-7, that is until one week ago. After deleting all backups that aren't needed you have the following backups on disk:

  • a level 0 backup that is from 7 days ago
  • the daily level 1 backup of the last 6 days including today's backup
  • the archive log backups of the last seven days

I never tried out this strategy but I think a recovery window of 7 days is the appropriate policy.

For control files the following can be found in the Database Backup and Recovery User's Guide

Backing Up Control Files with RMAN

You can back up the control file when the database is mounted or open.

...

If the CONFIGURE CONTROLFILE AUTOBACKUP command is set to ON (by default it is OFF), then RMAN automatically backs up the control file and server parameter file after every backup and after database structural changes. The control file autobackup contains metadata about the previous backup, which is crucial for disaster recovery.

If the autobackup feature is not set, then you must manually back up the control file in one of the following ways:

  • Run BACKUP CURRENT CONTROLFILE.
  • Include a backup of the control file within any backup by using the INCLUDE CURRENT CONTROLFILE option of the BACKUP command.
  • Back up data file 1, because RMAN automatically includes the control file and server parameter file in backups of data file 1.

We do a backup of the whole database that contains a backup of data file 1, so it will contain a backup of a control file, too. But I recommend to enable the autobackup of the control file, too.

CONFIGURE CONTROLFILE AUTOBACKUP ON;

or

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE disk TO '/path/autobackup/%U';

You want to be able to recover to every point in time ind the last 7 days, so you should configure

CONFIGURE  RETENTION POLICY  TO RECOVERY WINDOW OF 7 DAYS;

This deletion policy also includes the backups of the archive log.

You can also configure the archive log deletion policy:

CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DEVICE TYPE disk;

This deletion policy is related to theog archiving destinations, not to the archive log backups. Usualy archiving is done to the "recovery_file_dest".

The archived log deletion policy applies to all log archiving destinations, including the fast recovery area. The policy does not apply to archived redo log files in backup sets.

Only archived redo log files in the fast recovery area are automatically deleted by the database. You can execute the BACKUP ... DELETE INPUT, DELETE ARCHIVELOG, or DELETE OBSOLETE commands to delete logs manually from log archiving destinations, including the recovery area. If FORCE is not specified on the deletion commands, then these deletion commands obey the archived log deletion policy. If FORCE is specified, then the deletion commands ignore the archived log deletion policy.

So finally you have the following scripts:

A configuration script that you have to run once:

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE disk TO '/path/autobackup/%U';
CONFIGURE  RETENTION POLICY  TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DEVICE TYPE disk;

a script for the daily backup:

RUN {
allocate channel c1 device type disk format '/path/%U';
allocate channel c2 device type disk format '/path/%U';
allocate channel c3 device type disk format '/path/%U';
allocate channel c4 device type disk format '/path/%U';
allocate channel c5 device type disk format '/path/%U';
allocate channel c6 device type disk format '/path/%U';
allocate channel c7 device type disk format '/path/%U';
allocate channel c8 device type disk format '/path/%U';
RECOVER COPY OF DATABASE 
  WITH TAG 'incr_update' 
  UNTIL TIME 'SYSDATE - 7';
BACKUP
  INCREMENTAL LEVEL 1 
  FOR RECOVER OF COPY WITH TAG 'incr_update'
DATABASE;    
BACKUP ARCHIVELOG ALL DELETE INPUT;
DELETE OBSOLETE;
}

and the following script for the frequent backup of the archive logs. Maybe you want to use less channels for the archive logs.

RUN {
allocate channel c1 device type disk format '/path/%U';
allocate channel c2 device type disk format '/path/%U';
allocate channel c3 device type disk format '/path/%U';
allocate channel c4 device type disk format '/path/%U';
allocate channel c5 device type disk format '/path/%U';
allocate channel c6 device type disk format '/path/%U';
allocate channel c7 device type disk format '/path/%U';
allocate channel c8 device type disk format '/path/%U';
BACKUP ARCHIVELOG ALL DELETE INPUT;
}

If you do not want the recovery following each backup than another way is the following strategy using incremental backups

Once a week run the following script to get a level 0 backup

BACKUP
  INCREMENTAL LEVEL 0
  DATABASE;

On every other day take a levele 1 backup

BACKUP
  INCREMENTAL LEVEL 1
  DATABASE;

or you can do a

BACKUP
  INCREMENTAL LEVEL 0 CUMULATIVE
  DATABASE;

Again you should specify a recovery windows for 7 days and frequently take archive log backups.

You avoid the recovery of the database copy after each backup, but now you need more space for your backup because now you have always two full backups on your backup space. Also the number of level 1 backups ist more than 6.

Assume that your retention policy is 7 days and you do your level 0 backup always on the same day at the same time (this is the way one usually does) , e.g. you start your backup always on Sunday at 12:00. Now we have Sunday the 29th, 12:00. We have already two level 0 backups on disk, one started on 22nd at 12:00 and one started at 15th at 12:00. If you want to restore the database now to the point in time 22nd, 12:00, this should be possible, because your retention policy is 7 days. But for this restore you need the backup of the 15th, because the backup didn't have finished (or even not started) on 22nd 12:00. So if you issue a 'DELETE OBSOLETE' command at 29th, 12:00, this will not delete that level 0 backup started at 15th, 12:00. And if you start a level 0 backup now, you will have three level 0 backups on disk. If you want to avoid this to save space you can think about using a recovery window of 6 days instead of 7 days. Then you can issue a DELETE OBSOLETE statement on 29th, 12:00, before you start the backup and the backup of taken on 15th will be removed.

So finally you will have these scripts:

A configuration script that you have to run once:

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE disk TO '/path/autobackup/%U';
CONFIGURE  RETENTION POLICY  TO RECOVERY WINDOW OF 6 DAYS;
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DEVICE TYPE disk;

A script for the weekly level 0 backup

RUN {
allocate channel c1 device type disk format '/path/%U';
allocate channel c2 device type disk format '/path/%U';
allocate channel c3 device type disk format '/path/%U';
allocate channel c4 device type disk format '/path/%U';
allocate channel c5 device type disk format '/path/%U';
allocate channel c6 device type disk format '/path/%U';
allocate channel c7 device type disk format '/path/%U';
allocate channel c8 device type disk format '/path/%U';
DELETE OBSOLETE;
BACKUP
  INCREMENTAL LEVEL 0
DATABASE PLUS ARCHIVELOG DELETE INPUT;    
}

a daily script (except for the day when the level 0 runs) for the level 1 backups:

RUN {
allocate channel c1 device type disk format '/path/%U';
allocate channel c2 device type disk format '/path/%U';
allocate channel c3 device type disk format '/path/%U';
allocate channel c4 device type disk format '/path/%U';
allocate channel c5 device type disk format '/path/%U';
allocate channel c6 device type disk format '/path/%U';
allocate channel c7 device type disk format '/path/%U';
allocate channel c8 device type disk format '/path/%U';
DELETE OBSOLETE;
BACKUP
  INCREMENTAL LEVEL 1
DATABASE PLUS ARCHIVELOG DELETE INPUT;    
}

and script for the archive log backups

RUN {
allocate channel c1 device type disk format '/path/%U';
allocate channel c2 device type disk format '/path/%U';
allocate channel c3 device type disk format '/path/%U';
allocate channel c4 device type disk format '/path/%U';
allocate channel c5 device type disk format '/path/%U';
allocate channel c6 device type disk format '/path/%U';
allocate channel c7 device type disk format '/path/%U';
allocate channel c8 device type disk format '/path/%U';
BACKUP ARCHIVELOG ALL DELETE INPUT;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 dba.stackexchange
scroll top