RMAN备份数据库与表空间

时间:2022-01-18 06:57:15

脚本:

数据库备份: backup database format=‘/u01/app/oracle/oradata/Backup/oradb_%d_%s.bak‘; 

表空间备份:backup tablespace EXAMPLE format=‘/u01/app/oracle/oradata/Backup/%d_%p_%t_%c.dbf‘;        或者

RMAN> run{

2> allocate channel ch_1 type disk;

3> backup tablespace EXAMPLE

4> format ‘/u01/app/oracle/oradata/Backup/%d_%p_%t_%c.dbf‘;

5> }

(一)、数据库全备份,这个数据量比较大

1.如果对整个数据库进行备份,则需要先关闭数据库,并启动到mount状态

[[email protected] oradata]$ rman target /

 RMAN备份数据库与表空间

 

 

2.RMAN> list backup of database;

 RMAN备份数据库与表空间

 

 

3.RMAN> shutdown immediate

 

database closed

database dismounted

Oracle instance shut down

 

4.RMAN> startup mount

 

connected to target database (not started)

Oracle instance started

database mounted

 

Total System Global Area    2755870720 bytes

 

Fixed Size                     2256432 bytes

Variable Size                671089104 bytes

Database Buffers            2063597568 bytes

Redo Buffers                  18927616 bytes

 

5.RMAN> backup database format=‘/u01/app/oracle/oradata/Backup/oradb_%d_%s.bak‘;

 RMAN备份数据库与表空间

6.RMAN> alter database open;

 

database opened

可以查看到备份的文件有两个,一个包括控制文件。一个包括数据文件

 RMAN备份数据库与表空间

 

 

 

(二)、表空间备份

查看数据库下的表空间,选择你要备份的表空间,以example为例

SQL> select tablespace_name from dba_data_files;

 

TABLESPACE_NAME

------------------------------

USERS

UNDOTBS1

SYSAUX

SYSTEM

EXAMPLE

TABLESPACETEST01

 

6 rows selected.

[[email protected] oradata]$ rman target sys/410526 nocatalog;

 

RMAN> run{

2> allocate channel ch_1 type disk;

3> backup tablespace EXAMPLE

4> format ‘/u01/app/oracle/oradata/Backup/%d_%p_%t_%c.dbf‘;

5> }

 RMAN备份数据库与表空间

 

 

RMAN> list backup of tablespace EXAMPLE;

 RMAN备份数据库与表空间