Oracle backup tools, file naming formats, and rman operations

Source: Internet
Author: User

Oracle backup tools, file naming formats, and rman operations

I. Common tools:

Recovery Manager: rman can only perform Hot Standby (mount or open state)
Oracle Secure Backup
User-managed backup: cp/dd [if =/of =/blocksize =]

Ii. rman naming

The rman name cannot be repeated. % U is definitely not repeated.

% C Number of copies of backup slices

% D the day in the month (DD)

% M is in the month of the year (MM)

% F a unique name based on DBID, in the form of a c-IIIIIIIIII-YYYYMMDD-QQ,

% D database name where IIIIIIIIII is the DBID of the database, YYYYMMDD is the date, and QQ is a sequence of 1-256

% N Database Name, up to eight characters to the right

% U an eight-character name represents the backup set and Creation Time

% P Number of the backup credits in the backup set, starting from 1 to the number of files created

A unique file name of % U, representing % u _ % p _ % c

ID of the % s backup set

% T backup set Timestamp

% T year month day format (YYYYMMDD)

Iii. rman operations

-- Log on to rman
Rman target/
Rman target sys/passwork
Rman target sys/passwork nocatalog (control file Mode)
Rman target sys/passwork catalog (Restore directory)

-- View Parameters

RMAN> show all;
Configure retention policy to recovery window of 7 DAYS;
Configure backup optimization off; # default
Configure default device type to disk; # default
Configure controlfile autobackup off; # default
Configure controlfile autobackup format for device type disk to '% F'; # default
Configure device type disk parallelism 1 backup type to backupset; # default
Configure datafile backup copies for device type disk to 1; # default
Configure archivelog backup copies for device type disk to 1; # default
Configure maxsetsize to unlimited; # default
Configure encryption for database off; # default
Configure encryption algorithm 'aes128 '; # default
Configure archivelog deletion policy to none; # default
Configure snapshot controlfile name to '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_ORCL.f'; # default

Note: # default indicates that the configuration is still the initial default value. Go back to the default configure .. clear configuration.

1) configure retention policy ..
-- Used to determine which backups are not needed. There are three options:
A) redundancy 5
-- Indicates the number of backup sets in a data file. Five copies are provided here.
B) recovery window of 7 days
-- Indicates that you want the database to be restored to a few days ago
C) none
-- Indicates that the retention policy is not required.
Note: a) and B) are mutually exclusive.
.
2) configure backup optimization...
-Theoretically, backup optimization only applies to read-only or offline tablespaces. Of course, archive log files that have been backed up will also be skipped. The default value is off.

3) configure default device type ..
-- Specify the device type of the I/o operation: SBT or DISK. The default value is disk.

4) configure controlfile autobackup ..
-- When autobackup is not set to on, rman will automatically back up the control file for any backup operations.

5) configure controlfile autobackup format for device type disk to '% F'
-- Configure the path and format of the backup slice of the Control File
For example, configure controlfile autobackup format for device type disk to '/u01/app/oracle/backup/% F'

6) configure device type disk parallelism 1 BACKUP TYPE TO BACKUPSET

-- Configure the degree of parallelism for the database device type. The number of parallel threads determines the number of opened channels.

7) configure datafile backup copies for device type disk to 1

Configure archivelog backup copies for device type disk to 1
-- Whether to enable composite backup to generate a specified number of copies to a specified position in the specified I/o device. The default value is 1.
This configuration is only used for data files and archive files. It takes effect only when channels are automatically allocated!

8) CONFIGURE MAXSETSIZE TO UNLIMITED
-- Configure the size of the Backup set. Generally, maxpiecesize is configured to restrict the backup parts.

9) CONFIGURE ENCRYPTION FOR DATABASE OFF
-- Configure the encrypted backup set. Specific tablespace:
Configure encryption for tablespace users on;
If we execute set encryption on indentified by think only, this password is required for the backup created immediately after it can be restored normally.

10) configure encryption algorithm 'aes128'
-- Specify the encryption algorithm. The other one is 'aes256'

11) CONFIGURE ARCHIVELOG DELETION POLICY TO NONE
-- Specifies the deletion policy for the archive file. The default value is none, that is, it can be deleted after the archive backup is complete.
However, in the DG Environment, the DBA must ensure that the archive file is always saved on the primary end before the standby end receives the file successfully and applies it,
Therefore, when the DG Environment is set to: applied on standby

12) configure snapshot controlfile name to '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_ORCL.f'
-- Configure the storage path and file name of the snapshot file of the control file. This snapshot file is generated during Backup and used to control the read consistency of the file.
In addition, the configure exclude for tablespace <tablespace> [CLEAR] command is used to not back up the specified TABLESPACE to the backup set. This command is very useful FOR read-only tablespaces.

-- Modify the retention days
Use sqlplus to modify the number of days that backup information is retained in the control file
Show parameter control_file_record_keep_time

Alter system set control_file_record_keep_time = 30 scope = spfile
Shutdown immediate
Startup

-- Rman database cold backup
Shutdown immediate;
Startup mount;
Backup database format = '/u01/backup/rman/% d _ % T _ % s. Bak ';
Alter database open;
SQL 'alter system archive log current ';

-- Rman Database Hot Backup
Backup database format = '/u01/backup/rman/% d _ % T _ % s. Bak ';
SQL 'alter system archive log current ';

-- Backup tablespace
Backup tablespace emp;

-- Back up data files
Backup datafile '/u01/mytest. dbf ';
Backup datafile 5 format = '/u01/backup/rman/% N _ % s. dbf ';

-- Backup archiving logs
Backup archivelog all
Backup archivelog from time 'sysdate-1'
Backup archivelog from sequence 400
Backup archivelog all delete input
Backup archivelog from sequence 400 delete input

Format = '/u01/backup/rman/ar % T _ % s. arc' -- specify PATH % T date

-- Back up archive files from the past day
Backup format = '/u01/backup/rman/ar % d _ % s. arc'
Archivelog
From time = 'sysdate-1 'until time = 'sysdate ';

-- Back up data files and archive logs
Backup format = '/u01/backup/rman/t % d _ % s. Bak' tablespace emp plus archivelog;

-- Backup control file
Backup current controlfile format = '/u01/backup/rman/% d _ % s. ctl ';

-- Backup spfile
Backup spfile format = '/u01/backup/rman/spf % d _ % s. par ';

-- Compression backup set
Backup as compressed backupset tablespace emp;

-- Create a control file image copy
Copy current controlfile to '/u01/backup/rman/dbtest. ctl ';
Backup as copy format = '/u01/backup/rman/dbtest01.ctl' current controlfile;

-- Create a copy of the data file Image
Backup as copy format = '/u01/backup/rman/8. dbf' datafile 8;

-- Rman maintenance command
List backup -- list all backup information
List backup of database -- list database backups
List backup of tablespace emp -- list specified tablespace backups
List backup of datafile 5 -- list specified data file backups
List backup of controlfile -- list backup of Control Files
List backup of spfile -- list spfile backups
List archivelog all -- list archived logs
List backup of archivelog all -- list backups of archived logs

List backup of database summary -- list available backups
List backup of tablespace emp summary -- table space backup
List backup by file -- list backups by file type
List expired backup of archivelog all summary -- invalid backup

Report obsolete -- View expired
Delete obsolete -- delete expired

List recoverable backup of database -- list valid backups
List expired backup -- list invalid backups

List expired backup of archivelog all -- list invalid archive log backups
List expired backup of archivelog
Until sequence 5 -- list invalid archive log backups with the specified serial number
List expired backup of archivelog
Until time "to_date ('2017-6-30 ', 'yyyy-mm-dd ')"
-- List invalid archive log backup at a specified time

List copy -- list copies of image files
List copy of database
List copy of tablespace emp
List copy of datafile 6
List copy of archivelog all
List copy of controfile

Report schema
Report need backup -- list the data to be backed up
Report need backup days 2 database -- List data that has not been backed up for more than 2 days

Mount status
List incarnation;
Reset database to incarnation 980;


-- Delete invalid files
Delete invalid backup
Crosscheck backup (copy, archivelog all );
Delete expired backup (copy, archivelog all );

Delete invalid logs
Crosscheck archivelog all;
Delete expired archivelog all;

Crosscheck backup of tablespace sysaux -- checklist space backup
Crosscheck backup of datafile 2 -- check data file 2 backup
Crosscheck backup of controlfile -- check control file backup
Crosscheck backup of spfile -- check spfile
Crosscheck backup of copy -- check copy
Crosscheck backup completed after 'sysdate-2' -- backup 2 days before the current time

Crosscheck copy of database
Crosscheck copy of tablespace emp
Crosscheck copy of controlfile
Crosscheck copy of spfile

List backup summary -- get the primary key
Validate backupset 16 -- verify the validity of backup set 16
Change -- modify the backup status
Change backupset 16 unavailable
Change backupset 16 available
Change archivelog '/u01/backup/rman/***. log 'unavailable

Change backupset 16 delete -- delete backup set 16 (delete synchronously)
Delete expired backupset (archivelog all); -- the deletion fails.

Delete expired -- delete invalid backup
Delete obsolete -- delete a backup that is earlier than the backup policy date (expired)

-- Restore check
Restore database validate;
Validate backupset 218;

Restore database preview;
Restore tablespace users preview;
Restore datafile 5 preview;

-- Command Block
Run {
2> shutdown immediate;
3> startup mount;
4> allocate channel d1 type disk;
5> backup as backupset database
6> format = '/u01/backup/rman/% d _ % T. Bak ';
7> alter database open;
8> SQL 'alter system archive log current ';
9>}

Select * from v $ log;
Select * from v $ archived_log;
Select * from v $ backup_redolog;

-- Resume Consultant
List failure -- error diagnosis
Advise failure -- Suggestion
Repair failure -- repair (data files and control files)

-- Rename the data file under rman
Run {
2> SQL 'alter tablespace test_user offline ';
3> set newname for datafile '/u01/app/oracle/oradata/test_user.dbf'
4> to '/u01/app/oracle/oradata/test_user01.dbf ';
5> restore tablespace test_user;
6> switch datafile all;
7> recover tablespace test_user;
8> SQL 'alter tablespace test_user online ';
}

-- Move data files under rman
Run {
2> SQL 'alter tablespace test_user offline ';
3> set newname for datafile '/u01/app/oracle/oradata/test_user01.dbf'
4> to '/u01/app/oracle/oradata/dbtest/test_user01.dbf ';
5> restore tablespace test_user;
6> switch datafile all;
7> recover tablespace test_user;
8> SQL 'alter tablespace test_user online ';
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.