RMAN备份数据库与表空间
脚本:
数据库备份: 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状态
[oracle@orcl oradata]$ rman target /
2.rman> list backup of database;
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';
6.rman> alter database open;
database opened
可以查看到备份的文件有两个,一个包括控制文件。一个包括数据文件
(二)、表空间备份
查看数据库下的表空间,选择你要备份的表空间,以example为例
sql> select tablespace_name from dba_data_files;
tablespace_name
------------------------------
users
undotbs1
sysaux
system
example
tablespacetest01
6 rows selected.
[oracle@orcl 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> list backup of tablespace example;
上一篇: 添加遮罩层