Switch of rman backup recovery command

Source: Internet
Author: User

One switch command
1 switch command usage
Update the data file name to the data file name specified during image copy under rman
Update the data file name to the name specified by the set newname command.
 
2. Prerequisites for using the switch command
Rman must be connected to the target database
When you switch tablespaces, datafiles, and tempfiles, these files must be offline.
When you switch the entire database, the database cannot be open.
3. Notes
Switch... to copy command for rman Command Prompt
The switch does not have the command to copy, which is used in the run statement block.

4 syntax
Group 1
Switch dtabase to copy;
Switch datafile number | name to copy;
Switch tablespace name to copy;
Group 2
Switch datafile all;
Switch datafile number | name;
Switch tempfile all;

Recommended reading:

Basic Oracle tutorial-copying a database through RMAN

Reference for RMAN backup policy formulation

RMAN backup learning notes

Oracle Database Backup encryption RMAN Encryption

Example 2:
Example 1: Use switch datafile number to copy to update the location and name of the data file
RMAN> backup as copy datafile 8 format'/oracle/CRM/test. dbf ';
Starting backup at 2013-02-22 10:06:21
Using channel ORA_DISK_1
Using channel ORA_DISK_2
Channel ORA_DISK_1: starting datafile copy
Input datafile file number = 00008 name =/backup/test. dbf
Output file name =/oracle/CRM/test. dbf tag = TAG20130222T100621 RECID = 14 STAMP = 808049181
Channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2013-02-22 10:06:22
Starting Control File and SPFILE Autobackup at 2013-02-22 10:06:22
Piece handle =/backup/c-3599153036-20130222-01 comment = NONE
Finished Control File and SPFILE Autobackup at 2013-02-22 10:06:25

RMAN> SQL 'alter tablespace test offline ';
SQL statement: alter tablespace test offline
RMAN> switch datafile 8 to copy;
Datafile 8 switched to datafile copy "/oracle/CRM/test. dbf"

RMAN> report schema;
Report of database schema for database with db_unique_name CRM
List of Permanent Datafiles
======================================
File Size (MB) Tablespace RB segs Datafile Name
---------------------------------------------------------------
1 750 SYSTEM ***/oracle/CRM/system01.dbf
2 540 SYSAUX ***/oracle/CRM/sysaux01.dbf
3 100 UNDOTBS3 ***/oracle/CRM/undotbs3.dbf
4 1742 USERS ***/backup/users01.dbf
5 500 POS ***/oracle/CRM/pos. dbf
6 100 ERP ***/oracle/CRM/erp. dbf
7 5 USER01 ***/oracle/CRM/user01.dbf
8 0 TEST ***/oracle/CRM/test. dbf
List of Temporary Files
======================================
File Size (MB) Tablespace Maxsize (MB) Tempfile Name
---------------------------------------------------------------
1 218 TEMP 32767/oracle/CRM/temp01.dbf
2 3072 MYNEWTEMP 40960/oracle/CRM/newtemp. dbf

Example 2 Use switch tablespace name to copy to update the location and name of all data files in the tablespace
RMAN> backup as copy tablespace pos format '/oracle/% N % f. dbf ';
(% N indicates the tablespace name and % f indicates the absolute file number of the data file)
Starting backup at 2013-02-22 10:55:49
Using channel ORA_DISK_1
Using channel ORA_DISK_2
Channel ORA_DISK_1: starting datafile copy
Input datafile file number = 00005 name =/oracle/CRM/pos. dbf
Channel ORA_DISK_2: starting datafile copy
Input datafile file number = 00009 name =/oracle/CRM/pos2.dbf
Output file name =/oracle/POS9.dbf tag = tag20130222t1051_recid = 18 STAMP = 808052153
Channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:07
Output file name =/oracle/POS5.dbf tag = tag20130222t1051_recid = 19 STAMP = 808052179
Channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:36
Finished backup at 2013-02-22 10:56:25
Starting Control File and SPFILE Autobackup at 2013-02-22 10:56:25
Piece handle =/backup/c-3599153036-20130222-03 comment = NONE
Finished Control File and SPFILE Autobackup at 2013-02-22 10:56:28
RMAN> SQL 'alter tablespace pos offline ';
SQL statement: alter tablespace pos offline
RMAN> switch tablespace pos to copy;
Datafile 5 switched to datafile copy "/oracle/POS5.dbf"
Datafile 9 switched to datafile copy "/oracle/POS9.dbf"
RMAN> report schema;
Report of database schema for database with db_unique_name CRM
List of Permanent Datafiles
======================================
File Size (MB) Tablespace RB segs Datafile Name
---------------------------------------------------------------
1 750 SYSTEM ***/oracle/CRM/system01.dbf
2 540 SYSAUX ***/oracle/CRM/sysaux01.dbf
3 100 UNDOTBS3 ***/oracle/CRM/undotbs3.dbf
4 1742 USERS ***/backup/users01.dbf
5 0 POS ***/oracle/POS5.dbf
6 100 ERP ***/oracle/CRM/erp. dbf
7 5 USER01 ***/oracle/CRM/user01.dbf
8 0 TEST ***/oracle/CRM/test. dbf
9 0 POS ***/oracle/POS9.dbf
List of Temporary Files
======================================
File Size (MB) Tablespace Maxsize (MB) Tempfile Name
---------------------------------------------------------------
1 218 TEMP 32767/oracle/CRM/temp01.dbf
2 3072 MYNEWTEMP 40960/oracle/CRM/newtemp. dbf
Example 3 Use switch dtabase to copy to update the location and name of all data files in the database
RMAN> backup as copy database format'/oracle/CRM/test/% N % f. dbf ';
Starting backup at 2013-02-22 11:26:52
Allocated channel: ORA_DISK_1
Channel ORA_DISK_1: SID = 129 device type = DISK
Allocated channel: ORA_DISK_2
Channel ORA_DISK_2: SID = 192 device type = DISK
Channel ORA_DISK_1: starting datafile copy
Input datafile file number = 00004 name =/backup/users01.dbf
Channel ORA_DISK_2: starting datafile copy
Input datafile file number = 00001 name =/oracle/CRM/system01.dbf
Output file name =/oracle/CRM/test/SYSTEM1.dbf tag = TAG20130222T112653 RECID = 52 STAMP = 808054107
Channel ORA_DISK_2: datafile copy complete, elapsed time: 00:01:41
Channel ORA_DISK_2: starting datafile copy
Input datafile file number = 00002 name =/oracle/CRM/sysaux01.dbf
Output file name =/oracle/CRM/test/USERS4.dbf tag = TAG20130222T112653 RECID = 53 STAMP = 808054182
Channel ORA_DISK_1: datafile copy complete, elapsed time: 00:02:54
Channel ORA_DISK_1: starting datafile copy
Input datafile file number = 00005 name =/oracle/POS5.dbf
Output file name =/oracle/CRM/test/SYSAUX2.dbf tag = TAG20130222T112653 RECID = 54 STAMP = 808054193
Channel ORA_DISK_2: datafile copy complete, elapsed time: 00:01:11
Channel ORA_DISK_2: starting datafile copy
Input datafile file number = 00003 name =/oracle/CRM/undotbs3.dbf
Output file name =/oracle/CRM/test/UNDOTBS33.dbf tag= TAG20130222T112653 RECID = 55 STAMP = 808054203
Channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:16
Channel ORA_DISK_2: starting datafile copy
Input datafile file number = 00006 name =/oracle/CRM/erp. dbf
Output file name =/oracle/CRM/test/ERP6.dbf tag = TAG20130222T112653 RECID = 56 STAMP = 808054230
Channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:25
Channel ORA_DISK_2: starting datafile copy
Input datafile file number = 00009 name =/oracle/POS9.dbf
Output file name =/oracle/CRM/test/POS5.dbf tag = TAG20130222T112653 RECID = 57 STAMP = 808054247
Channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:58
Channel ORA_DISK_1: starting datafile copy
Input datafile file number = 00007 name =/oracle/CRM/user01.dbf
Output file name =/oracle/CRM/test/POS9.dbf tag = TAG20130222T112653 RECID = 58 STAMP = 808054247
Channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:08
Channel ORA_DISK_2: starting datafile copy
Input datafile file number = 00008 name =/oracle/CRM/test. dbf
Output file name =/oracle/CRM/test/USER017.dbf tag = TAG20130222T112653 RECID = 59 STAMP = 808054250
Channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:00
Output file name =/oracle/CRM/test/TEST8.dbf tag = TAG20130222T112653 RECID = 60 STAMP = 808054250
Channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2013-02-22 11:30:51
Starting Control File and SPFILE Autobackup at 2013-02-22 11:30:51
Piece handle =/backup/c-3599153036-20130222-06 comment = NONE
Finished Control File and SPFILE Autobackup at 2013-02-22 11:30:59
RMAN> switch database to copy;
Datafile 1 switched to datafile copy "/oracle/CRM/test/SYSTEM1.dbf"
Datafile 2 switched to datafile copy "/oracle/CRM/test/SYSAUX2.dbf"
Datafile 3 switched to datafile copy "/oracle/CRM/test/UNDOTBS33.dbf"
Datafile 4 switched to datafile copy "/oracle/CRM/test/USERS4.dbf"
Datafile 5 switched to datafile copy "/oracle/CRM/test/POS5.dbf"
Datafile 6 switched to datafile copy "/oracle/CRM/test/ERP6.dbf"
Datafile 7 switched to datafile copy "/oracle/CRM/test/USER017.dbf"
Datafile 8 switched to datafile copy "/oracle/CRM/test/TEST8.dbf"
Datafile 9 switched to datafile copy "/oracle/CRM/test/POS9.dbf"
RMAN> SQL 'alter database open ';
SQL statement: alter database open
SQL> select file #, name, status from v $ datafile;
FILE # NAME STATUS
---------------------------------------------------------
1/oracle/CRM/test/SYSTEM1.dbf SYSTEM
2/oracle/CRM/test/SYSAUX2.dbf ONLINE
3/oracle/CRM/test/UNDOTBS33.dbf ONLINE
4/oracle/CRM/test/USERS4.dbf ONLINE
5/oracle/CRM/test/POS5.dbf ONLINE
6/oracle/CRM/test/ERP6.dbf ONLINE
7/oracle/CRM/test/USER017.dbf ONLINE
8/oracle/CRM/test/TEST8.dbf ONLINE
9/oracle/CRM/test/POS9.dbf ONLINE

  • 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.