目录
1、表空间备份
2、表空间还原
3、表空间恢复
4、增量还原恢复
1、表空间备份
表空间只能在联机状态下进行备份。
BACKUP TABLESPACE TBS BACKUPSET '/dm/backup/dm_bak/ts_bak_01';
完全备份
BACKUP TABLESPACE TBS FULL BACKUPSET '/dm/backup/dm_bak/ts_full_bak_01';
增量备份
BACKUP TABLESPACE TBS INCREMENT WITH BACKUPDIR '/dm/backup/dm_bak' BACKUPSET '/dm/backup/dm_bak/ts_increment_bak_02';
备份语句中指定的 INCREMENT 参数表示执行的备份类型为增量备份,不可省略。若要创建累积增量备份,还需要指定 CUMULATIVE 参数,否则缺省为差异增量备份。WITH BACKUPDIR 参数用来指定基备份集的搜索目录,如果基备份集不在默认备份目录或当前备份目录则该参数不可省略。
BASE ON BACKUPSET 参数用于增量备份中,用来指定基备份集路径。如果不指定该参数,会在备份搜索目录中搜索最近一次的完全备份或增量备份作为这次增量备份的基备份。
BACKUP TABLESPACE TBS BACKUPSET 'ts_full_bak_01';BACKUP TABLESPACE TBS INCREMENT BACKUPSET 'ts_increment_bak_01';BACKUP TABLESPACE TBS INCREMENT BASE ON BACKUPSET '/dm/backup/dm_bak/ts_full_bak_01' BACKUPSET '/dm/backup/dm_bak/ts_increment_bak_02';
上述示例中,增量备份 ts_increment_bak_02 若不指定备份集 ts_full_bak_01 作为基备份,那么默认会使用最近一次的备份集 ts_increment_bak_01 作为基备份。
2、表空间还原
表空间还原的目标库只能是备份集产生的源库,否则将报错。
RMAN>RESTORE DATABASE '/dm/data/DMDB/dm.ini' TABLESPACE TBS FROM BACKUPSET '/dm/backup/dm_bak/ts_full_bak_01';
3、表空间恢复
表空间恢复通过重做 REDO 日志,以将数据更新到一致状态。
RMAN>RECOVER DATABASE '/dm/data/DMDB/dm.ini' TABLESPACE TBS;
4、增量还原恢复
RESTORE DATABASE '/dm/data/DMDB/dm.ini' TABLESPACE TBS FROM BACKUPSET '/dm/backup/dm_bak/ts_increment_bak_02';RECOVER DATABASE '/dm/data/DMDB/dm.ini' TABLESPACE TBS;
SQL> BACKUP TABLESPACE TBS FULL BACKUPSET '/dm/backup/dm_bak/ts_full_bak_01';操作已执行已用时间: 00:00:02.961. 执行号:10105.SQL> create table test.tt (t int);操作已执行已用时间: 6.537(毫秒). 执行号:10106.SQL>SQL> BACKUP TABLESPACE TBS INCREMENT BASE ON BACKUPSET 'ts_full_bak_01' BACKUPSET 'ts_increment_bak_02';BACKUP TABLESPACE TBS INCREMENT BASE ON BACKUPSET 'ts_full_bak_01' BACKUPSET 'ts_increment_bak_02';[-10001]:[错误码:-127]无效的备份集目录[/dm/data/DMDB/bak/ts_full_bak_01].已用时间: 00:00:03.815. 执行号:0.SQL> BACKUP TABLESPACE TBS INCREMENT BASE ON BACKUPSET '/dm/backup/dm_bak/ts_full_bak_01' BACKUPSET '/dm/backup/dm_bak/ts_increment_bak_02';操作已执行已用时间: 00:00:07.704. 执行号:10108.SQL> exit[dmdba@localhost ~]$ dmrmandmrman V8RMAN> RESTORE DATABASE '/dm/data/DMDB/dm.ini' TABLESPACE TBS FROM BACKUPSET '/dm/backup/dm_bak/ts_full_bak_01';RESTORE DATABASE '/dm/data/DMDB/dm.ini' TABLESPACE TBS FROM BACKUPSET '/dm/backup/dm_bak/ts_full_bak_01';file dm.key not found, use default license!Database mode = 0, oguid = 0Normal of FASTNormal of DEFAULTNormal of RECYCLENormal of KEEPNormal of ROLLEP[0]'s cur_lsn[580682], file_lsn[580682][Percent:100.00%][Speed:0.00M/s][Cost:00:00:02][Remaining:00:00:00] restore successfully.time used: 00:00:02.413RMAN> RECOVER DATABASE '/dm/data/DMDB/dm.ini' TABLESPACE TBS FROM BACKUPSET '/dm/backup/dm_bak/ts_full_bak_01';[-8301]:SQL[RECOVER DATABASE '/dm/data/DMDB/dm.ini' TABLESPACE TBS FROM BACKUPSET '/dm/backup/dm_bak/ts_full_bak_01';]第[1]行,第[55]列[FROM]附近出现错误[-2007]:语法分析出错RMAN> RESTORE DATABASE '/dm/data/DMDB/dm.ini' TABLESPACE TBS FROM BACKUPSET '/dm/backup/dm_bak/ts_increment_bak_02';RESTORE DATABASE '/dm/data/DMDB/dm.ini' TABLESPACE TBS FROM BACKUPSET '/dm/backup/dm_bak/ts_increment_bak_02';Database mode = 0, oguid = 0Normal of FASTNormal of DEFAULTNormal of RECYCLENormal of KEEPNormal of ROLLEP[0]'s cur_lsn[580682], file_lsn[580682][Percent:100.00%][Speed:0.00M/s][Cost:00:00:02][Remaining:00:00:00] restore successfully.time used: 00:00:02.431RMAN> RECOVER DATABASE '/dm/data/DMDB/dm.ini' TABLESPACE TBS;RECOVER DATABASE '/dm/data/DMDB/dm.ini' TABLESPACE TBS;Database mode = 0, oguid = 0Normal of FASTNormal of DEFAULTNormal of RECYCLENormal of KEEPNormal of ROLLEP[0]'s cur_lsn[580682], file_lsn[580682]dres_backupset_recover_ts begin[Percent:100.00%][Speed:0.00PKG/s][Cost:00:00:00][Remaining:00:00:00] dres_backupset_recover_ts endrecover successfully.time used: 447.118(ms)RMAN>[dmdba@localhost ~]$ disql SYSDBA:5238密码:服务器[LOCALHOST:5238]:处于普通打开状态登录使用时间 : 4.995(ms)disql V8SQL> select * from test.tt;未选定行已用时间: 1.231(毫秒). 执行号:502.SQL> exit
达梦技术社区:https://eco.dameng.com/