腳本: 資料庫備份: backup database format='/u01/app/oracle/oradata/Backup/oradb_%d_%s.bak'; 表空間備份:backup tablespace EXAMPLE format='/u01/app/oracle/oradata/Ba ...
腳本:
資料庫備份: 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;