pdb备份和恢复

 

1.备份单个pdb

run
{
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
allocate channel ch3 device type disk;
backup as compressed backupset full filesperset 10 pluggable database pdb1 format '/u01/rmanbak/pdbbak/pdb1_fullbk_%d_%s_%u_%T.bak';
sql 'alter system archive log current';
backup as compressed backupset archivelog all format '/u01/rmanbak/pdbbak/daily_arch_%d_%s_%u_%T.bak' delete input;
backup current controlfile format '/u01/rmanbak/pdbbak/daily_ctl_%d_%s_%u_%T.bak';
backup spfile format '/u01/rmanbak/pdbbak/daily_spfile_%d_%s_%u_%T.bak';
release channel ch1;
release channel ch2;
release channel ch3;
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt obsolete;
}

 

2.备份多个pdb

run
{
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
allocate channel ch3 device type disk;
backup as compressed backupset full filesperset 10 pluggable database pdb1,pdb2 format '/u01/rmanbak/pdbbak/pdb1_pdb2_fullbk_%d_%s_%u_%T.bak';
sql 'alter system archive log current';
backup as compressed backupset archivelog all format '/u01/rmanbak/pdbbak/daily_arch_%d_%s_%u_%T.bak' delete input;
backup current controlfile format '/u01/rmanbak/pdbbak/daily_ctl_%d_%s_%u_%T.bak';
backup spfile format '/u01/rmanbak/pdbbak/daily_spfile_%d_%s_%u_%T.bak';
release channel ch1;
release channel ch2;
release channel ch3;
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt obsolete;
}

 

3.完全恢复某个pdb

模拟删除pdb1下的数据文件
先关闭pdb1
SQL> alter pluggable database pdb1 close;

Pluggable database altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB                            READ WRITE NO
         4 PDB1                           MOUNTED
         5 PDB2                           READ WRITE NO

删除pdb1目录下的数据文件
[oracle@localhost pdb1]$ pwd
/u01/app/oracle/oradata/ORA19C/pdb1
[oracle@localhost pdb1]$ rm *.dbf

[oracle@localhost pdb1]$ ls
[oracle@localhost pdb1]$ 


进行恢复
[oracle@localhost ~]$ rman target /
restore pluggable database pdb1;
recover pluggable database pdb1;

打开pdb1
SQL> alter pluggable database pdb1 open;

Pluggable database altered.

 

posted @ 2023-04-12 09:48  slnngk  阅读(125)  评论(0)    收藏  举报