All technological notes.
| RMAN Command | Description |
|---|---|
host 'clear screen'; |
Clear screen |
host 'clear'; |
Clear screen |
show all; |
List all persistent settings |
show <setting>; |
Show a persistent setting |
configure <setting> <value>; |
Configure a persistent setting |
configure <setting> clear; |
Set a persistent setting back to default |
RESYNC CATALOG |
Execute catalog resynchronization |
BACKUP DATABASE |
Backup the entire database |
ALLOCATE CHANNEL |
Allocate a channel for executing a job command |
| RMAN Command | Description |
|---|---|
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF <days> DAYS; |
Configure the recovery window retention policy |
CONFIGURE RETENTION POLICY TO REDUNDANCY <copies>; |
Configure the redundancy retention policy |
CONFIGURE RETENTION POLICY TO NONE; |
Disable the retention policy |
Oracle Recovery Manager (RMAN)
RMAN uses
fast recovery area for backups.Oracle Secure Backup, so backups can be made to the tape drive and to the cloud. Backups can be performed to other designated locations, such as directly to disk.
fast recovery area and Oracle Secure BackupIn your Linux course environment, you have more than one local database.
. oraenv to set your environment variables.Invoke RMAN at the operating system command line and specify the appropriate options. Commonly used options are:
target: The connect-string for the target databasecatalog: The connect-string for a recovery catalognocatalog: Specifies there is no recovery catalog.
cmdfile: The name of an input command filelog: The name of the output message log fileThe RMAN invocation rman target / connects to the local database as the target.
# call oraenv script to set environment vairable
. oraenv
# rman connect to the local db with the sYSBACKUP privilege.
rman target "'/ as sysbackup'"

You can execute SQL commands and PL/SQL procedures from the RMAN command line.
The SQL keyword is optional, but you should use it to eliminate ambiguity, especially for a few commands that exist in both RMAN and SQL and have different uses.
DESCRIBE command provides the functionality of the SQL\*Plus DESCRIBE command. You can use the abbreviated version DESC or the spelled-out DESCRIBE to list the column definitions of a table or view.SELECT privileges on the object or connect in the SYSDBA mode.(sysdba 有全权限, 默认 sysbackup 没有 select any 权限)two basic types of RMAN commands: stand-alone and job commands.
Stand-alone commands
Job commands - usually grouped and executed sequentially inside a command block.
ALLOCATE CHANNEL.
RUN command block, such as BACKUP DATABASE.
You can execute stand-alone and job commands in interactive mode or batch mode. 两模式都可以
RMAN commands are of the following types:
Stand-alone command:
RMAN promptRUNJob command:
RUN commandSome commands can be executed as both types.
Unlike stand-alone commands, job commands must appear within the braces of a RUN command.
e.g.:

RMAN executes the job commands inside a RUN command block sequentially.
Persistent configuration settings
control file and in the recovery catalog database (if it exists).CONFIGURE command
used to configure persistent settings:
BACKUPSET or COPYcontrol filesarchive log deletion policySet the encryption and compression parameters to be used for backups
SET command
-- RMAN command to view all configuration settings
SHOW ALL;
-- sql command to display configuration settings that have been explicitly set.
SQL 'select * from V$RMAN_CONFIGURATION';
-- if no explicit settings, nothing returns.
V$RMAN_CONFIGURATION has a con_id value:
0 means the configuration applies to the entire CDB,1 means it applies to the root container only, and any other value means that it applies to the container ID of the PDB only.
Parallelism
BACKUP commands using that media manager.-- where <n> is the parallelism value.
CONFIGURE DEVICE TYPE <device> PARALLELISM <n>
SHOW command
SHOW CONTROLFILE AUTOBACKUP FORMAT;
SHOW EXCLUDE;
SHOW ALL;
SHOW AL
CONFIGURE command + CLEAR option:
CONFIGURE BACKUP OPTIMIZATION CLEAR;
CONFIGURE MAXSETSIZE CLEAR;
CONFIGURE DEFAULT DEVICE TYPE CLEAR;
DB_RECOVERY_FILE_DEST parameter specifies the default location for the fast recovery area. - View the parameter value by logging in to SQL*Plus and using the SHOW PARAMETER command.-- in sqlplus
show parameter db_recovery_file_dest
-- in rman
BACKUP DATABASE;


Include all datafiles of CDB and all PDBs, along with control file and parameter file will be backed up. By default, using backup set


~oracle/.bashrc file:export NLS_LANG=american_america.al32utf8export NLS_DATE_FORMAT="yyyy-mm-dd:hh24:mi:ss"# edite bash script
vi ~oracle/.bashrc
# apply bash script to export env var
. ~oracle/.bashrc
list backup;


-- Displays whether RMAN is configured to automatically back up the control file and server parameter file whenever a backup or copy operation is performed.
show controlfile autobackup;
-- Displays the retention policy settings for backups, which specify how long to keep backups and how they should be managed.
show retention policy;
-- Provides a summary report of the database schema, including information about the datafiles, tablespaces, and their sizes.
REPORT SCHEMA;

USERS tablespace in both the CDB and PDB1.BACKUP TABLESPACE users, PDB1:USERS;

Using SPOOL LOG TO <file>
Create a file for logging
-- do not use ~ for home,
-- rman will create the file
SPOOL LOG TO /tmp/test.log
-- will not display
List Backup
-- stop directing output to the file.
SPOOL LOG OFF

