Rman Backup/Restore

Source: Internet
Author: User

Fully prepared script
Cat rman_full.sh#!/bin/Bashexport oracle_base=/opt/Oracleexport Oracle_home= $ORACLE _base/product/11.2.0/Db_1export Oracle_sid=Orclexport Nls_lang=American_america. Al32utf8export PATH= $ORACLE _home/bin: $PATHrman Target/Log/opt/oracle/backup/rman_full.log append<<eofrun{allocate Channel C1 type disk;allocate channel C2 type Disk;backup database Filesperset4Format'/opt/oracle/backup/full_%d_%t_%s_%p'; SQL'alter system archive log current'; backup Archivelog all Format'/opt/oracle/backup/arch_%d_%t_%s_%p'Delete input;backup current controlfile format'/opt/oracle/backup/ctl_%d_%t_%s_%p'; crosscheck backup;crosscheck archivelog all;delete noprompt obsolete;delete noprompt expired Backup;delete NoPrompt expired Archivelog All;} EOF

Add script
[Email protected]/opt/sh A:xx: -&& -] #cat rman_arch.sh export oracle_base=/opt/Oracleexport Oracle_home= $ORACLE _base/product/11.2.0/Db_1export Oracle_sid=Orclexport Nls_lang=American_america. Al32utf8export PATH= $ORACLE _home/bin: $PATHrman Target/Log/opt/oracle/backup/rman_arch.log append<<eofrun{allocate Channel C1 type disk;allocate channel C2 type Disk;sql'alter system archive log current'; backup Archivelog all Format'/opt/oracle/backup/arch_%d_%t_%s_%p'Delete input;backup current controlfile format'/opt/oracle/backup/ctl_%d_%t_%s_%p'; crosscheck backup;crosscheck archivelog all;delete noprompt expired backup;delete noprompt expired archivelog all;} EOF

Recovery scripts
Export oracle_base=/opt/Oracleexport Oracle_home= $ORACLE _base/product/11.2.0/Db_1export Oracle_sid=Orclexport Nls_lang=American_america. Al32utf8export PATH= $ORACLE _home/bin: $PATHrman Target/Log/opt/oracle/backup/rman_arch.log append<<eofrun{allocate Channel C1 type disk;allocate channel C2 type Disk;sql'alter session set nls_date_format= "Yyyy-mm-dd hh24:mi:ss"';SetUntil time ='2011-10-19 22:21:38'; restore database;recover database;alter database open resetlogs;} EOF
Rman Backup/Recovery Step-up Rman backup step together
preparatory work1. Control_file_record_keep_time initialization Parameters The minimum number of days that the Rman metadata remains in the control file, which defaults to 7 days (that is, the backup data cannot be more than 7 days or the data is lost) $ sqlplus/ asSysdbasql> Alter systemSetControl_file_record_keep_time= -; SQL>show parameter control;2. Start Archive mode $ mkdir-p/opt/oracle/archdata #创建归档日志存放目录 $ sqlplus/ asSysdbasql>archive log list;           #查看归档日志状态Database log mode No Archive mode Automatic archival Disabled #关闭Archive destination /opt/oracle/archdataoldest Online log sequence3Current log sequence5SQL> Alter systemSetlog_archive_dest_1='Location=/opt/oracle/archdata'Scope=both; #更改归档日志存放目录SQL>SelectDest_name,destination,status,error fromV$archive_destwhereDest_name='log_archive_dest_1'; #查看归档日志存放目录重启数据库mount状态, open archive (all ALTER DATABASE operation is to modify the "control file" content) SQL>shutdown immediate; #关闭数据库SQL>startup Mount; #启动数据库到mount模式SQL>ALTER DATABASE archivelog; #开启归档模式SQL>ALTER DATABASE open; #启动数据库SQL> Alter systemSwitchlogfile; # just opened the archive has not generated the log, we manually switch the SQL>SelectSequence#,name,archived,applied fromV$archived_log; # Database Layer View archive log files Rman backup considerations 1 Backup Sequence backup data--"Backup archive data--"Control Document2. Backup to have log information Rman target/log/tmp/rman_full.log #登陆rman, redirect output log to/tmp/Rman_full.log rman environment variable setting Rman target/Show All; #查看所有配置 # The default configuration retention policy is a backup configure RETENTION policy to redundancy1; #default#配置恢复期窗口是90天, meaning to be able to recover to any day of the 90 days, the requirement is to keep a backup of at least 90 days ago and have all archived logs since then configure RETENTION POLICY to recovery Window of -Days ; CONFIGURE RETENTION POLICY Clear; #备份的设备类型默认是disk, disk type, CONFIGURE DEFAULT DEVICE type to disk; # default#这个是备份为磁带类型CONFIGURE DEFAULT DEVICE TYPE to STB, #自动备份控制文件CONFIGURE Controlfile autobackup on; Backup Please view full backup script

Rman Recovery Control File
 as Sysdba; SQL> shutdown immediate; SQL>/RMAN> list backupset; RMANfrom'xxxxx';  #xxxx是控制文件路径

Rman recovers data to a specified point in time
Original address: https://blog.csdn.net/u011364306/article/details/500136071. Modify the database time format SQL  set nls_date_format='yyyy-mm-dd hh24:mi:ss'; 2 . View database Time SQL Select  from dual;
3. Close the database and boot to mount mode
Shutdown immediate;
sql> startup Mount;
4. Restore the database See recovery script

Rman Backup/Restore

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.