文档章节

Backup / Restore Oracle DB

querychinesesto
 querychinesesto
发布于 2015/05/14 10:12
字数 781
阅读 25
收藏 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
修复由于主库NOLOGGING操作引起的备库ORA-01578和ORA-26040错误

修复由于主库NOLOGGING操作引起的备库ORA-01578和ORA-26040错误 ORA-01578和ORA-26040--NOLOGGING操作引起的坏块-错误解释和解决方案 : http://blog.itpub.net/26736162/viewspace-2152783/ ...

小麦苗
08/07
0
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

java并发备忘

不安全的“先检查后执行”,代码形式如下: if(条件满足){ //这里容易出现线程安全问题//doSomething}else{//doOther} 读取-修改-写入 原子操作:使用CAS技术,即首先从V中读取...

Funcy1122
今天
0
0
SpringBoot2.0 停机

最近新建了个SpringBoot2.0的项目,因为原来一直使用的是传统的Tomcat部署war包的形式,所以这次SpringBoot内置Tomcat部署jar包的时候遇到了很多问题。其中一个就是因为没有外置的Tomcat容器...

Canaan_
昨天
0
1
Confluence 6 外部参考

一个外部参考的意思是任何站点链接到你 Confluence 的实例。任何时候当 Confluence 的用户单击这个外部链接的时候,Confluence 可以记录这次单击为参考。 在默认的情况下,外部链接的参考链接...

honeymose
昨天
0
0
Android中的设计模式之抽象工厂模式

参考 《设计模式解析》 第十一章 Abstract Factory模式 《设计模式:可复用面向对象软件的基础 》3.1 Abstract Factory 抽象工厂 对象创建型模式 《Android源码设计模式解析与实战》第6章 创...

newtrek
昨天
0
0
Redis | 地理空间(GEO)的一个坑

Redis的地理空间(Geo)是个好东西,轻轻松松的就可以把地图描点的问题处理了, 最近却遇到一个坑...Redis采用的Msater-Slave模式, 运用GEORADIUS在salve读取对应的数据,新增了从节点但是从不返...

云迹
昨天
1
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部