文档章节

Backup / Restore Oracle DB

querychinesesto
 querychinesesto
发布于 2015/05/14 10:12
字数 781
阅读 26
收藏 0
  • Backup Oracle DB in NOARCHIVELOG mode In sqlplus console,
$ sqlplus / as sysdba (sqlplus /nolog then conn /as sysdba)
SQL> archive log list;
SQL> show parameter DB_RECOVERY_FILE_DEST;
SQL> alter system set db_recovery_file_dest='/flash_recovery_area' scope=both;
SQL> shutdown immediate;
SQL> startup mount;
 // at this time, run RMAN> backup database;
 // OR change archive log mode
SQL> alter database archivelog;
SQL> alter database open;
SQL> archive log list;
SQL> alter system switch logfile; ( OR alter system archive log current)
SQL> select operation, status, mbytes_processed, start_time, end_time from v$rman_status order by start_time;

If archivelog mode is enabled

RMAN> backup incremental level 0 database plus archivelog delete input;
OR
RMAN> backup as compressed backupset incremental level 0 database include current controlfile plus archivelog;
OR
RMAN> backup as compressed backupset incremental level 0 database include current controlfile plus archivelog delete all input; 
ADN
RMAN> backup incremental level 1 database plus archivelog delete input;

In rman prompt,

$ rman
RMAN> connect target /;
RMAN> list backup;
RMAN> list backup summary;
RMAN> backup as compressed backupset tag 'weeekly_prd01_tbls_bk_only' tablespace prd01;
RMAN> backup as compressed backupset database plus archivelog ;

RMAN> run {  # backup directly in noarchive mode
shutdown immediate;
startup mount;
backup database;
alter database open;
}
RMAN> show all;
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/tmp/backup/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/tmp/backup/dbkup_%Y%M%D_%U';
CONFIGURE MAXSETSIZE TO UNLIMITED;
CONFIGURE ENCRYPTION FOR DATABASE OFF;
CONFIGURE ENCRYPTION ALGORITHM 'AES128';
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE;
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_CHHDEV2.f';

Full version of backup

#!/usr/bin/ksh

DATABASE=CHHDEV2

RUNTIME=`date '+%H%M_%d%m%Y'`

BACKUPDIR=/tmp/backup

LOGFILE=${BACKUPDIR}/${ORACLE_SID}_${RUNTIME}.log

LEVEL=0

exec >> ${LOGFILE} 2>&1

$ORACLE_HOME/bin/rman msgno target / nocatalog <<EOF!

CONFIGURE RETENTION POLICY TO REDUNDANCY 3; # default 1

# CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 14 DAYS; # default 1

CONFIGURE BACKUP OPTIMIZATION ON; # default OFF

CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default

CONFIGURE CONTROLFILE AUTOBACKUP ON; # default OFF

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '${BACKUPDIR}/ora_cf%F'; # default '%F'

CONFIGURE DEVICE TYPE DISK PARALLELISM 3; # default 1

CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '${BACKUPDIR}/ora_df%t_s%s_s%p';

CONFIGURE MAXSETSIZE TO UNLIMITED; # default

CONFIGURE SNAPSHOT CONTROLFILE NAME TO '${BACKUPDIR}/snapcf_${DATABASE}.f';

SHOW ALL;

sql "alter system switch logfile";

CROSSCHECK ARCHIVELOG ALL;

# BACKUP AS COMPRESSED BACKUPSET INCREMENTAL LEVEL 0 DATABASE INCLUDE CURRENT CONTROLFILE PLUS ARCHIVELOG DELETE ALL INPUT;

# BACKUP AS COMPRESSED BACKUPSET DATABASE INCLUDE CURRENT CONTROLFILE PLUS ARCHIVELOG DELETE ALL INPUT;

# BACKUP DATABASE INCLUDE CURRENT CONTROLFILE PLUS ARCHIVELOG DELETE ALL INPUT;

# backup AS COMPRESSED BACKUPSET database include current controlfile format '${BACKUPDIR}/ora_df%t_s%s_s%p';

# backup AS COMPRESSED BACKUPSET archivelog UNTIL TIME '(SYSDATE - 1)' not backed up 1 times  format '${BACKUPDIR}/ora_arc%t_s%s_s%p';

# delete noprompt archivelog until time '(SYSDATE -1)' backed up 1 times to device type disk;

BACKUP AS COMPRESSED BACKUPSET INCREMENTAL LEVEL ${LEVEL} DATABASE INCLUDE CURRENT CONTROLFILE PLUS ARCHIVELOG;

DELETE NOPROMPT COPY OF ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-5';

sql "alter database backup controlfile to trace as ''${BACKUPDIR}/ctrlfile_${DATABASE}_${RUNTIME}''";

allocate channel for maintenance type disk;

delete noprompt obsolete device type disk;

CROSSCHECK BACKUP;

CROSSCHECK ARCHIVELOG ALL;

REPORT OBSOLETE;

DELETE FORCE NOPROMPT OBSOLETE;

DELETE FORCE NOPROMPT expired backup of archivelog all;

DELETE FORCE NOPROMPT expired backup;

LIST BACKUP OF DATABASE;

LIST BACKUP OF ARCHIVELOG ALL;

LIST BACKUP;

release channel;

EXIT

EOF!

exit

  • Store Oracle DB
RMAN> SET DBID 70161972;
RMAN> RUN {
    startup force nomount;
    SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/tmp/backup/%F';
    RESTORE CONTROLFILE to '/tmp/controlfile' FROM AUTOBACKUP;
    RESTORE SPFILE to pfile '/tmp/pfile' FROM AUTOBACKUP;
    //OR
    restore controlfile from autobackup;
    restore spfile from autobackup;
    
    SET ARCHIVELOG DESTINATION TO '/tmp/temp_restore';
    RESTORE ARCHIVELOG ALL;

    startup mount;
    restore database;
    recover database;
    sql 'alter database open RESETLOGS'; 
    }

Reference:
https://support.software.dell.com/netvault-backup/kb/140173
http://dbaworkshop.blogspot.hk/2012/07/how-to-backup-database-in-noarchivelog_31.html
http://ss64.com/ora/rman_backup.html
http://www.dba-oracle.com/t_rman_incremental_backups.htm
http://www.dba-oracle.com/concepts/rman_recovery_database_spfile.htm
http://www.dba-oracle.com/concepts/rman.htm
http://www.dba-oracle.com/concepts/rman_online_offline_backups.htm
http://www.dba-village.com/village/dvp_forum.OpenThread?ThreadIdA=44077&DestinationA=RSS
http://docs.oracle.com/cd/E11882_01/backup.112/e10642/rcmadvre.htm
http://docs.oracle.com/cd/B19306_01/backup.102/b14192/recov004.htm#i1032364

© 著作权归作者所有

共有 人打赏支持
querychinesesto
粉丝 7
博文 122
码字总数 37779
作品 0
广州
程序员
12c 验证RMAN加密备份

日常工作中,经常会遇到需要备份,然后异机恢复数据,提供测试数据。为了保证数据的安全性,建议大家加密备份。 测试环境:Oracle 12c R1 RAC环境 1.备份脚本如下: 2.删除一个数据文件用来做...

roidba
2017/12/08
0
0
rman还原oracle数据库.

用rman备份了数据库,不指定时间点还原的时候没有问题但是一指定时间点就报错,麻烦各位大神给小弟点意见: 不指定时间还原命令: run { sql 'alter tablespace MLSBACKUPDATA offline for recov...

carson王
2016/06/21
74
0
RMAN实例入门,备份与恢复

本文用step by step的方式介绍一下RMAN的入门使用,通常保存备份目录的目录数据库和目标数据库应该在不同的机器上,这里两个数据库在同一台机器上. 在listener.ora中加入 (SID_DESC = (GLOBAL_...

晨曦之光
2012/04/25
329
0
Oracle 11g单实例RMAN恢复到Oracle 11g RAC

一、环境说明 操作系统版本: RHEL 6.5 x64 1. 源数据库服务器 Oracle版本: Oracle 11g 11.2.0.4 64位(单机) OracleSID: orcl dbname : orcl 背景:一台生产oracle10g(10.2.0.5)数据库计划迁...

koumm
2017/09/17
0
0
ORACLE 11G RAC ASM磁盘全部丢失后的恢复

故障描述 (1)存储故障导致ASM磁盘丢失。 (2)CRS因为OCR和VOTEDISK的丢失,除了OHAS还联机外,CLUSTERWARE服务都已经停止 操作步骤 一、恢复OCR和VOTEDISK (1) 在所有RAC节点上停止CRS服务...

liuzhuqing
08/16
0
0

没有更多内容

加载失败,请刷新页面

加载更多

WinDbg

参考来自:http://www.cnit.net.cn/?id=225 SRV*C:\Symbols*http://msdl.microsoft.com/download/symbols ctrl + d to open dump_file Microsoft (R) Windows Debugger Version 6.12.0002.633......

xueyuse0012
今天
2
0
OSChina 周五乱弹 —— 想不想把92年的萝莉退货

Osc乱弹歌单(2018)请戳(这里) 【今日歌曲】 @罗马的王:分享松澤由美的单曲《地球ぎ》 很久没看圣斗士星矢了 《地球ぎ》- 松澤由美 手机党少年们想听歌,请使劲儿戳(这里) @开源中国首...

小小编辑
今天
14
1
springBoot条件配置

本篇介绍下,如何通过springboot的条件配置,控制Bean的创建 介绍下开发环境 JDK版本1.8 springboot版本是1.5.2 开发工具为 intellij idea(2018.2) 开发环境为 15款MacBook Pro 前言 很多时候,...

贺小五
今天
1
0
javascript source map 的使用

之前发现VS.NET会为压缩的js文添加一个与文件名同名的.map文件,一直没有搞懂他是用来做什么的,直接删除掉运行时浏览器又会报错,后来google了一直才真正搞懂了这个小小的map文件背后的巨大...

粒子数反转
昨天
1
0
谈谈如何学Linux和它在如今社会的影响

昨天,还在农耕脑力社会,今天已经人工智能技术、大数据、信息技术的科技社会了,高速开展并迅速浸透到当今科技社会的各个方面,Linux日益成为人们信息时代的到来,更加考验我们对信息的处理程...

linux-tao
昨天
3
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部