Basic information and initial configuration
There are two ways to do this:
– excluding the database and copying physical files (so-called cold backup)
– using RMAN and do the backup without turning off the database (hot backup)
To make a hot backup, set the database to ARCHIVELOG mode. After this surgery files
Repeat logs before overwriting will be archived. Thanks to that we are sure that
will not be cleared during backup. We do this as follows:
– We log SQL * Plus as SYS to the database.
– We do  SHUTDOWN IMMEDIATE; (only once this is necessary).
– Start the database in MOUNT  mode  ( STARTUP MOUNT command  ).
– Invoke  ALTER DATABASE ARCHIVELOG;
– open database for users using  ALTER DATABASE OPEN ;
This step can be omitted, but this configuration will allow us to choose a different default location
save backup files. Oracle includes a Flash Recovery Area. It’s space
It contains backups for restoration. It is managed by the database engine, a
not the operating system. In it will be our backups. We are checking current
FRA location:
SELECT * FROM v $ recovery_file_dest;
If you want to change the available disk space, use the following command:
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE = 100G;
This parameter sets how much disk space can take up the maximum of archives and back archives.
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST = ‘c: \ FRA’;
This parameter sets where the disk has to be backed up.
After setting the above parameters, it is worth checking if everything was correct by us
set. So we choose the command:
SELECT * FROM v $ parameter WHERE NAME = ‘db_recovery_file_dest’;
SELECT * FROM v $ parameter WHERE NAME = ‘db_recovery_file_dest_size’;
 

Switch on the command line and type  RMAN .
Connection to the base
First of all, after RMAN is enabled  , we need to connect to the database. This is done
typing command:
CONNECT TARGET
or
CONNECT TARGET /
or
CONNECT TARGET SIGNATURES
Full backup
In order to perform a full backup of the database, we issue the command:
BACKUP DATABASE;
Since it is a full backup, it takes a long time. Wait patiently for the appearance
RMAN message. Our backup will appear in the Flash Recovery Area defined by us.
If we want our backup to be somewhere other than the default location, type the following command:
BACKUP DATABASE FORMAT ‘c: \ rman \ calabaza% u.bck’;
Tag  % u  is a unique number generated by Based on the date and time of creation, thanks
Every backup file will have a unique number.
These formats are several and can be woven into the file name. I present these basic:
% s  – backup number
% d  – database name
% D  – day
% M  – month
% Y  – year
% u  – unique value calculated based on all the above options
Such backups include data and a control file. If we want to backup with the files
The archived log of the repetition, we call the command:
BACKUP DATABASE PLUS ARCHIVELOG;
Backup compressed
Backup files take up a lot of space. So it should be compressed. There’s a possibility
compression using RMAN. RMAN uses an algorithm similar to that used by
ZIP archiving program.
Instead of  BACKUP DATABASE; write:
BACKUP AS COMPRESSED BACKUPSET DATABASE FORMAT
‘C: \ FRA \ full_compressed% u’;
Or, for example, with the log files (archived) of the repetition log:
BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG FORMAT
‘C: \ FRA \ full_compressed% u’;
This compression also applies to tablespace backups and incremental backups
and cumulative. True backup, if it is compressed, is done a lot
longer but takes up less space.
Incremental and cumulative backups
We do not always need to make a full backup. With the rest of us what for everyone
together if you can full backup do once, and then exploit occupying much
less space incremental backups.
definitions:
Full copy – a copy of all data files and control file
Incremental copy – means only copies of those data blocks that have changed since the last one
full or incremental backup.
Cumulative copy – a copy of all data blocks that have changed since the last one
Full (no longer incremental backup).
Incremental backup
Since version 10g Oracle supports two levels of incremental backup 0 and 1. incremental backup
0 is not physically different from a full backup, except that we can not
Perform normal incremental backups (level 1). So at least once we have to do it
command:
BACKUP INCREMENTAL LEVEL 0 DATABASE FORMAT ‘c: \ FRA \ increment_0_% u’;
to then be able to perform:
BACKUP INCREMENTAL LEVEL 1 DATABASE FORMAT ‘c: \ FRA \ increment_1_% u’;
The command of level 1 is already a normal incremental backup.
Cumulative backup
To perform a cumulative backup call the command:
BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;
It is often enough to make incremental copies, and once in a while (eg week) copy
cumulative. This way we can later get rid of incremental backups, and that’s it
Goes, have fewer files to store.
This tag can be combined with others previously known, for example:
BACKUP INCREMENTAL LEVEL 1 FORMAT ‘c: \ FRA \ inc_comp% u’ AS COMPRESSED
BACKUPSET DATABASE PLUS ARCHIVELOG;
Fast incremental backup
Normally incremental backups are implemented so that the last backup with data is compared
block after block. Instead, you can make Oracle create a list of changed blocks.
In this case, the backup will run much faster. Sorry, this option is only available
Standard and Enterprise versions.
First, let’s check if this option is not enabled:
SELECT * FROM v $ parameter WHERE NAME = ‘db_create_file_dest’;
If the value field is empty, it means that it was not previously set.
Create a directory where this list will be stored, and then type:
ALTER SYSTEM SET db_create_file_dest = ‘c: \ FRA \ fib’;
and enable this option:
ALTER DATABASE ENABLE BLOCK CHANGE TRACKING;
Backup tablespace
RMAN can also perform tablespace backups, data files, parameter files, control files.
Let’s first examine what we have in the tablespace:
SELECT * FROM DBA_TABLESPACES;
Backup command for selected tablespace:
BACKUP TABLESPACE USERS FORMAT ‘c: \ FRA \ users% u’;
The formatting clause is obviously optional. We may also want to save some tablespace,
Then we split them with commas:
BACKUP TABLESPACE USERS, SYSTEM FORMAT ‘c: \ FRA \ users_system% u’;
Or to compress them additionally:
BACKUP AS COMPRESSED BACKUP SITE TABLESPACE USERS FORMAT
‘C: \ FRA \ users_compressed% u’;
or do not have enough that compressed it’s still incremental (save space – disks sometimes
they end up):
BACKUP AS COMPRESSED BACKUPSET INCREMENTAL LEVEL 1 FORMAT
‘c: \ FRA \ users_comp_resources% u’ TABLESPACE USERS;
Backup parameter file
Command (format is optional):
BACKUP SPFILE FORMAT ‘c: \ FRA \ spfile% u’;
Backup control file
It is a good idea to make a separate copy of the control file. Why? As information about
Backups are stored in it. In full backups, there is also a copy of the file
but we will not be able to restore the backup if the control file goes down
damaged. In that case, it is much easier to recover the control file first and then the rest.
To perform this backup, type:
BACKUP CURRENT CONTROLFILE FORMAT ‘c: \ FRA \ controlfile% u’;
This copy of the control file (especially since it does not take up a lot of space) should be kept as fresh as possible.
Caring for it would be possible to commission the base engine:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
From now on, if any change affects the control file, this will be
Automatically backed up after changes. We may now want RMAN to backup the file
control other than the default. We call the command:
CONFIGURE CONTROLFILE AUTOBACKACK FORMAT FOR DEVICE TYPE DISK TO
‘D: \ FRA \ plikkontrolny% u’;
Back up archived replay log files
SELECT * FROM v $ datafile;
BACKUP AS DATAFILE COPY ‘c: \ app \ administrator \ oradata \ orcl \ users01.dbf’ FORMAT
‘C: \ FRA \ users.dbf’;
This command copies all blocks, occupied and empty. So if we have a definite
A lot of reserved tablespaces, the backup will take up a lot of unnecessary space
place.
Playing with RMAN
To start restoring the stuff we’re backing up from, back up the command console
line and then type  RMAN.
First of all, when you enable  RMAN and you need to connect to the database (as in
when creating backup files). So we are writing the command:
CONNECT TARGET
or
CONNECT TARGET /
or
CONNECT TARGET SIGNATURES
We can now restore what we previously backed up (database, tablespace, control file,
or archived logs of repetitions.
Restore database from full backup
We will start by restoring the full database from our backup. To do this we must first
Turn off the database, and then turn it into mount  mode  (we can do that by entering a list
command) :
RUN{
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
RESTORE DATABASE;
RECOVER DATABASE;
ALTER DATABASE OPEN;
}
RMAN will itself check which backup is the latter, regardless of whether we were doing the full
backup, incremental, or cumulative. Also, it will itself load the appropriate control file and
archive log.
Restoring the database to a specific point in time
We can restore the database to a specific point in time, for this purpose we turn off and then
Let’s start with the mount mode  :
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
We give to whom we want to restore the base:
run{
set until time “to_timestamp (’12: 00: 00 01-09-2017 ‘,’ hh24-mi-ss dd-mm-yyyy ‘)”;
restore database;
recover database;
}
Then run the database, reset archived logs:
ALTER DATABASE OPEN RESETLOGS;
Database validation and backups
In order to validate the database files we issue the command:
BACKUP VALIDATE DATABASE;
You can also perform validations for the base, including archivelogs:
BACKUP VALIDATE DATABASE PLUS ARCHIVELOG;
Important, this command does not backup!
To verify the last backup we made:
RESTORE DATABASE VALIDATE;
To verify the correct backup file with archives:
RESTORE ARCHIVELOG ALL VALIDATE;
Backup management
If you want to check our backups you can list them by typing:
LIST BACKUP;
It is sometimes a good idea to check that the files to which the backup relates are still present on the disk. To that
we call:
CROSSCHECK BACKUP;
If the above query shows an error (different from found to be ‘AVALIABLE’) then we can delete unnecessary backup files using the command:
DELETE EXPIRED BACKUP;
We can also delete outdated, unnecessary backups, such as obsolete:
DELETE OBSOLETE;
To set the backup policy, ie when backup files are considered obsolete by RMAN we need to modify the RETENTION POLICY parameter  . We have the ability to set the number of backups to be considered as current or time in days.
The setting for the number of days that the backup will be considered “important” is set by the command:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 3 DAYS;
The above command will set RMAN to be considered obsolete backup files created more than 3 days back.
The setting for the number of backups held is set by calling:
CONFIGURE RETENTION POLICY TO REDUNDANCY 3;
This command sets RMAN to the current last 3 backup files.
After listing backups ( LIST BACKUP ) we will see what number corresponds to the specific
backup file. Knowing this number, we can remove a specific backup using this
number:
DELETE BACKUPSET 69;
 
Restore tablespace
To restore the tablespace we have to disconnect it from the database using the OFFLINE command  Including
We can also use the list of commands:
RUN{
SQL ‘ALTER TABLESPACE USERS OFFLINE’;
RESTORE TABLESPACE USER;
RECOVER TABLESPACE USERS;
SQL ‘ALTER TABLESPACE USERS ONLINE’;
}
 
 
 
 
Restore the system tablespace
Here you can also use the list of commands. As it is a system tablespace, we are
forced to close the database and enter it into MOUNT mode  :
RUN{
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
RESTORE TABLESPACE SYSTEM, SYSAUX;
RECOVER TABLESPACE SYSTEM, SYSAUX;
ALTER DATABASE OPEN;
}
Restore control file
Restore the control file by adding RESETLOGS at the end of the command:
RUN{
SHUTDOWN IMMEDIATE;
STARTUP NOMOUNT;
RESTORE CONTROLFILE FROM AUTOBACKUP;
ALTER DATABASE MOUNT;
RESTORE DATABASE;
RECOVER DATABASE;
ALTER DATABASE OPEN RESETLOGS;
}

exercises

1. Perform a full backup compressed with archivelogs which may be the basis for

incremental backups.

2. Perform two incremental backups and one cumulative – all compressed together

with archivelogs.

3. Get rid of unnecessary backups.

4. Restore the SYSTEM tablespace.

5. Restore the entire database to the current time.

6. Restore the database to 3 hours ago.

Ask your trainer about the database corruption. Check what kind of damage it is and

return the instance to action.