1) BACKUP DATABASE
BACKUP DATABASE;
RMAN> SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT'; # switches logs and archives all logs
By archiving the logs immediately after the backup, you ensure that you have a full set of archived logs through the time of the backup. This guarantees that you can perform media recovery after restoring this backup.
BACKUP AS COPY DATABASE; >>> using "as copy" claus to specify that copy all the datafiles bit-by-bit.
BACKUP AS COPY DEVICE TYPE DISK DATABASE;
BACKUP AS BACKUPSET DATABASE; >>> need to backup as backupset and here backup will be created in default destination BACKUP AS BACKUPSET DEVICE TYPE DISK DATABASE; BACKUP AS BACKUPSET DEVICE TYPE SBT DATABASE;
You can specify a FORMAT clause with the individual BACKUP command to direct the output to a specific location, as shown here:
BACKUP DATABASE FORMAT="/tmp/backup_%U";
%U is required in this instance to generate unique file names
You can also use the FORMAT clause to name an ASM disk group as backup destination, as shown in this example:
RMAN> BACKUP DATABASE FORMAT '+dgroup1'; # sets an ASM disk group
No %U is required in this instance, because ASM generates unique file names as needed.
To specify a tag to identify a group of backups, use the TAG clause of the BACKUP command. For example, enter:
RMAN> BACKUP DATABASE TAG = 'weekly_backup'; # gives the backup a tag identifier
2) BACKUP DATABASE PLUS ARCHIVELOG
RMAN> backup database plus archivelog;
> HOW THE ABOVE BACKUP WILL BE DONE BY RMAN :
A) Runs the ALTER SYSTEM ARCHIVE LOG CURRENT command
B) Runs BACKUP ARCHIVELOG ALL
C) Backs up the rest of the files specified in BACKUP COMMAND
D) Runs the ALTER SYSTEM ARCHIVE LOG CURRENT command
E) Backs up any remaining archived logs generated during the backup
This guarantees that datafile backups taken during the command are recoverable to a consistent state.
This BELOW example backs up the entire database and archived logs to the configured default backup destination (disk or tape), producing compressed backupsets:
BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG;
3)BACKUP DATAFILES
RMAN> BACKUP AS BACKUPSET DATAFILE '+DG1/devdb/datafile/system.256.757308329';
4) BACKUP ALL DATAFILES IN DATABASE
(bit-for-bit copies, created on disk)
RMAN> BACKUP AS COPY DATABASE;
You can specify the datafiles by name or number.
RMAN> BACKUP DEVICE TYPE sbt DATAFILE 1,2,3,4
5) BACKUP ARCHIVELOG
RMAN> BACKUP ARCHIVELOG ALL;
RMAN> BACKUP ARCHIVELOG COMPLETION TIME BETWEEN 'SYSDATE-28' AND 'SYSDATE-7';
RMAN> BACKUP ARCHIVELOG FROM TIME 'SYSDATE-30' UNTIL TIME 'SYSDATE-7';
Automatic Online Redo Log Switches During Backups of Archived Logs
When taking a backup of archived redo logs if the database is open, then before beginning the backup, RMAN will switch out of the current online redo log group, and all online redo logs that have not yet been archived.
This ensures that the backup contains all redo that was generated prior to the start of the command.
> RMAN selects only one copy of the archived redo log file to include in the backup set, even if your redo logs are being archived to multiple destinations
> Using BACKUP ARCHIVELOG with DELETE INPUT or DELETE ALL INPUT
----------------------------------------------------------------
> specify the DELETE INPUT or DELETE ALL INPUT clauses for the BACKUP ARCHIVELOG command to delete archived logs after they are backed up, eliminating the separate step of manually deleting the archived redo logs.
RMAN> BACKUP DEVICE TYPE sbt ARCHIVELOG ALL DELETE ALL INPUT;
> With DELETE INPUT, RMAN only deletes the specific copy of the archived redo log chosen for the backup set. With DELETE ALL INPUT, RMAN will delete each backed-up archived redo log file from all log archiving destinations.
> If you issue BACKUP ARCHIVELOG ALL or BACKUP ARCHIVELOG LIKE '...', and there are no archived redo log files to back up, then RMAN does not signal an error.
6)BACKUP TABLESPACE
You can use this command when the database is mounted or open.
RMAN> BACKUP TABLESPACE system;
RMAN> BACKUP TABLESPACE system, users, tools;
Oracle translates the tablespace name internally into a list of datafiles.
7) BACKUP CURRENT CONTROLFILE
RMAN> BACKUP CURRENT CONTROLFILE;
RMAN> BACKUP AS COPY CURRENT CONTROLFILE FORMAT '/tmp/control01.ctl';
8)BACKUP PARAMETER FILE
RMAN> BACKUP SPFILE;
9) BACKUP EVERYTHING
RMAN> BACKUP BACKUPSET ALL;
10)BACKUP VALIDATION ( no backup will be taken )
Backup Validation confirms that a backup could be run, by confirming that all database files exist and are free of physical and logical corruption, this does not generate any output.
RMAN> BACKUP VALIDATE DATABASE ARCHIVELOG ALL;
It will read all files that would be backed up in backing up the entire database and ensure that they are intact and not corrupted. All of the data blocks in the input files are validated, exactly as they are when a real backup takes place. This process can provide a useful integrity check for your database.
11) LIST BACKUP
RMAN> list backup;
The output of list backup displays information such as the name, level, completion time, and status of each backup.