RMAN backup script writing format and precautions

Source: Internet
Author: User

I. The rman database can be stored in two locations
1. control files of the target database;
2. Restore the directory;

2. There are two types of storage records in the control file
1. records the history of archived log files and the metadata of rman backups that can be deleted (records the data at the backup set location)
2. Record data files and online log file lists cannot be deleted.
If you need to store new records in the control file, you can delete the detachable parts to provide free space.
Note: If the metadata backed up by rman is deleted, the backup data of rman is meaningless. Therefore, the metadata backed up by rman is very important.

3. Set initialization parameters
Controlfile_record_keep_time determines which part of the control file can be deleted. This parameter is set to seven days by default, indicating that the control file is always deleted for the last seven days, backup information seven days ago, and archive log records are deleted, if it is set to zero, the table does not delete the history, the growth of the control file will be out of control, so the rman backup cycle cannot exceed seven days.

Iv. rman backup sequence to ensure no data loss
1. database data files
2. Archiving logs
3. Control File
4. parameter file

-------------------------------------- Recommended reading --------------------------------------

RMAN: Configure an archive log deletion policy

Basic Oracle tutorial-copying a database through RMAN

Reference for RMAN backup policy formulation

RMAN backup learning notes

Oracle Database Backup encryption RMAN Encryption

-------------------------------------- Split line --------------------------------------

5. Experiment 1
After the backup is complete, delete the control file and use the previous control file to restore the database.
RMAN> run {
2> allocate channel c1 type disk;
3> allocate channel c2 type disk;
4> backup database filesperset 2 format'/u02/backup/full _ % d _ % t _ % s _ % P ';
5> backup current controlfile format '/u02/backup/ctl _ % d _ % t _ % s _ % P ';
6> SQL 'alter system archive log current ';
7> SQL 'alter system archive log current ';
8> SQL 'alter system archive log current ';
9> backup archivelog all format'/u02/backup/log _ % d _ % t _ % s _ % P' delete input;
10>}
After the backup is complete, delete the control file used. We use the previous control file for restoration. can we restore and open the database?
RMAN> restore controlfile from '/u02/backup/ctl_ORCL_843148742_17_1 ';
RMAN> alter database mount;
RMAN> recover database;
RMAN-00571: ========================================================== ==============================
RMAN-00569: ==================== error message stack follows ==========================
RMAN-00571: ========================================================== ==============================
RMAN-03002: failure of recover command at 03/25/2014 16:08:31
RMAN-06054: media recovery requesting unknown log: thread 1 seq 37 lowscn 1157615
Note: We are prompted that the log file seq37 is missing!
This backup solution is incorrect! We may not be able to find the backup level of our log files. If it is on disk, it is not too difficult, but it is troublesome to bring the database!
Open another session:
RMAN> catalog backuppiece '/u02/backup/log_ORCL_843148747_18_1 ';
Cataloged backuppiece
Backup piece handle =/u02/backup/log_ORCL_843148747_18_1 recid = 14 stamp = 843150418
RMAN> catalog backuppiece '/u02/backup/log_ORCL_843148747_19_1 ';
Cataloged backuppiece
Backup piece handle =/u02/backup/log_ORCL_843148747_19_1 recid = 15 stamp = 843150442
RMAN> catalog backuppiece '/u02/backup/log_ORCL_843148749_20_1 ';
Cataloged backuppiece
Backup piece handle =/u02/backup/log_ORCL_843148749_20_1 recid = 16 stamp = 843150457
RMAN>
Return to the previous session:
RMAN> recover database;
Starting recover at 25-MAR-14
Using channel ORA_DISK_1
Starting media recovery
If we back up the control file before backing up the archive log, the archive information in the control file will not be recorded (the name and storage location of the backup archive information)

6. Back up all databases
Orale] $ rman target/log/tmp/rman_full.log
RMAN> configure controlfile autobackup on;
RMAN> configure controlfile autobackup format for device type sbt_tape to '% F ';
Note: When you add or delete a data file, the control file is automatically backed up during physical operations on the database, so that the database may be suspended.
RMAN> configure controlfile autobackup format for device type disk to '% F'; k to' % F'; Note: physical operation backup to disk
Run {
Allocate channel c1 type sbt_tape; back up the control file to the warehouse.
Backup database;
}
If automatic backup of the control file is enabled in rman, it is still the backup script. After archiving backup is completed, the control file is still backed up.
Run {
2> allocate channel c1 type disk;
3> allocate channel c2 type disk;
4> backup database filesperset 2 format'/u02/backup/full _ % d _ % t _ % s _ % P ';
5> backup current controlfile format '/u02/backup/ctl _ % d _ % t _ % s _ % P ';
6> SQL 'alter system archive log current ';
7> SQL 'alter system archive log current ';
8> SQL 'alter system archive log current ';
9> backup archivelog all format'/u02/backup/log _ % d _ % t _ % s _ % P' delete input;
10>}
VII. Rman Log
During rman backup, there is a log output option. During backup, oracle indicates an option, but for us, there must be a log for backup.
1. Backup script format
% C: number of copies of the backup slice
% D: Database Name
% D: The day of the month.
% M: The month of the year.
% N: name of the database, which is a maximum of 8 characters added to the right
% U: an 8-character name, representing the backup set and Creation Time
% P: Backup credits of the Backup set, starting from 1 to the number of files created
% U: a unique name % u _ % p _ % c
% S: Backup ID
% T: Backup Timestamp
% T: year month day format (YYYY-MM-DD)

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • Next Page

Related Article

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.