Questions On Rman
Questions On Rman
RMAN currently only allows one retention policy. The retention policy
should be set to 14 days.
RMAN> configure retention policy to recovery window of 14 days;
Step 2: Move the backups from disk to tape to meet the specified disk
retention policy. This must be done manually.
The following command will move the backups from disk to tape and
delete the original backup copy from disk.
First, we identify the oldest full backup (i.e. full or level 0 backupset, or
image copy) of every file that is not obsolete, as defined by the
retention policy (either REDUNDANCY or RECOVERY WINDOW). Every
older full backup is obsolete.
Then, all archived logs and level > 0 incremental backups that are
older than the oldest non-obsolete full backup are also considered to
be obsolete, because there is no longer any full backup to which they
could possibly apply.
Note that a level > 0 backup performs much the same function as an
archived log - it causes a full backup to move forward in time, so those
backups are treated in the same manner as archived logs for the
purposes of retention. Incremental backups are not restored using the
restore command, they are restored using the recover command if it
will cause fewer archive logs to be needed during recovery. When you
restore it is always only from full or level 0 incremental backups of
the datafiles.
But there could be situations where you would be looking for different
kind of retention policies.Such kind of a situation is explained below.
EXAMPLE
========
QUESTION
=========
ANSWER
=========
For all your daily backups maintain a normal retention policy i.e
This retention policy is always common for all backups . But since you
have to retain the weekly backups for 365 days and monthly backups
for 700 days .
Therefore for the weekly and monthly backups we will be going for "
KEEP " option .
You can exempt a backup from the retention policy by using the KEEP
option with the BACKUP command
when you create the backup, or the KEEP option of the CHANGE
command to exempt an existing backup.
Note that backups exempted from the retention policy are still fully
valid backups, which can be
used in restore and recovery operations like any other if RMAN judges
them to be the best choice
available.
You can change the exempt status of a backup using the CHANGE...
KEEP and CHANGE... NOKEEP
commands. The NOKEEP option (default) indicates that the backup is
not immune from the configured
retention policy.
You can specify the LOGS option to save archived logs for a possible
incomplete recovery of the
long-term backup. When LOGS is specified, all logs more recent than
the backup are kept as long as
the backup is kept. In other words, KEEP UNTIL TIME... LOGS means
that RMAN will keep all logs
required to recover the backup as long as the backup is kept. If you
specify NOLOGS, then RMAN
does not keep the logs required to recover the backup. Note that if you
use KEEP UNTIL TIME...
with an inconsistent backup, you must use the LOGS option, or that
backup will become unusable
when the logs required to recover it are deleted as obsolete.
You can specify an end date using the UNTIL clause, or either specify
that the backup should be
kept FOREVER. If you specify UNTIL, then RMAN will not mark the
backup as obsolete until after the
UNTIL date has passed. Note that it is an error to specify KEEP
FOREVER with the LOGS option, as
this would require keeping all redo logs forever.
EXAMPLE:
=========
+ For weekly and monthly backups you can take the backups in this
way :
Specify the until time as needed depending upon whether the backup
is weekly or monthly .
For the rest of your daily backups you can have the normal retention
policy of 32 days .
We can have different conditions due which the backups would not
become obsolete. They are :
Example
---------
run {
allocate channel oem_disk_backup device type disk;
RECOVER COPY OF DATABASE with tag 'ORA$OEM_LEVEL_0 until time
'sysdate-8' ';
backup incremental level 1 cumulative copies=1 for recover of copy
with tag 'ORA$OEM_LEVEL_0' database;
}
NOTE
======
To check the backups are good or not there are two options :
Example:
Want to restore and recover the database till time '10:23, 05-
November-2007 then you have to use the below command to
accomplish this :
Step 1: The below command just gives the report of backups that are
used to do the restore and recover :
run
{
set until time "to_date('2007-05-10:23:00:00','yyyy-dd-
mm:hh24:mi:ss')";
restore database preview;
}
The Restore ... Preview identifies the backups (backup sets or image
copies, on disk or sequential media like tapes) required to carry out a
given restore operation, based on the information in the RMAN
repository. Use RESTORE... PREVIEW when planning your restore and
recovery operation, to ensure that all required backups are available or
to identify situations.
The restore database preview gives a report of all the backup pieces
and archivelogs that are required to restore/recover the database.
Make a note of the start sequence and end sequence of archivelogs
and the same will be used in the next step
Step 2: Then run the below command to check the backup pieces are
good :
run
{
allocate channel c1 type disk;
set until time "to_date('2007-05-10:23:00:00','yyyy-dd-
mm:hh24:mi:ss')";
restore database validate;
}
The above command will read the backup pieces/Copies which has
datafiles and if finds any error it will report at the RMAN prompt.
RMAN> run
{
allocate channel c1 type disk;
restore archivelog from sequence xxx until sequence yyy validate;
}
Replace the xxx, yyy with the start and end archivelog sequence
reported by restore database preview command ran in the step 1.
The RESTORE ... VALIDATE command test whether you can restore from
your backups. You can test the availability of usable backups for any
desired RESTORE operation, or test the contents of a specific backup
for use in RESTORE operations. The contents of the backups are
actually read and validated for corruption to ensure that the objects to
be restored can be restored from them.
How to change Flash Recovery Area to a new location ?
If you need to move the Flash Recovery Area of your database
to a new location,
invoke SQL*Plus to change the DB_RECOVERY_FILE_DEST
initialization parameter.
For example:
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST='+disk1' SCOPE=BOTH
SID='*';
After you change this parameter, all new Flash Recovery Area
files will be
created in the new location.
The permanent files (control files and online redolog
files), flashback logs
and transient files can be left in the old Flash Recovery
Area location. The
database will delete the transient files from the old Flash
Recovery Area
location as they become eligible for deletion.
For the FLASHBACK logfiles to be able to to pick up the new
'db_recovery_file_dest' location,
the flashback option needs to be toggled off and on.
This can be done like this:
Shutdown the Database
Startup mount the Database:
SQL> startup mount;
Toggle the Flashback off:
SQL> alter database flashback off;
Toggle the Flashback on:
SQL> alter database flashback on;
Open the Database:
SQL> alter database open;
If you need to actually move your current permanent files,
transient files, to the new Flash Recovery Area, then follow
the following steps:
1) To move the existing backupsets and archived redo log
files,use the following
command:
RMAN> BACKUP AS COPY ARCHIVELOG ALL DELETE INPUT;
RMAN> BACKUP DEVICE TYPE DISK BACKUPSET ALL DELETE INPUT;
2) To move the datafile copies. Run the below command for
each datafile copy:
RMAN> BACKUP AS COPY DATAFILECOPY <name> DELETE INPUT;
where the <name> is the datafilecopy name in the old
recovery area.
3) To move the controlfile from the old Flash Recovery Area
to new one.
Change the location in the parameter CONTROL_FILES to the
new location
and restart the instance in NOMOUNT.
RMAN> RESTORE CONTROLFILE FROM
'filename_of_old_control_file';
4) To move the online redo logs. Use the commands to add a a
log file stored in
the new Flash Recovery Area and drop the logfile in the
old Flash Recovery Area
for each redo log group.
SQL> alter database add logfile size 100M;
SQL> alter database drop logfile 'name of the old redo
log';
Oracle will clean up transient files remaining in the old
Flash Recovery Area
location as they become eligible for deletion.
Relation between RMAN retention period
and control_file_record_keep_time
Backup retention policy is the rule to set regarding which backups must
be retained (whether on disk or other backup media) to meet the
recovery and other requirements.
Formula
For e.g.