ORACLE12C data backup and recovery strategy

Source: Internet
Author: User
Tags dba

Not very familiar with Oracle, only simple startup, shutdown, Lsnrctl start and other commands, do not like Oracle, not good

Please amend username, password, oracle_sid,/path/to/dir and so on according to the actual situation

EXPDP fully prepared

Note EXPDP can only be fully prepared and cannot be incrementally backed up

Create a backup file to store the directory

--Create a backup store directory (directory to already exist) create or replace directory Dmp_dir as '/path/to/dir ';--grant Read,write on directory DM for user authorization P_dir to USERNAME; --View Catalog select * FROM all_directories;--or select * dba_directories;


--View Oracle_sid Select instance from V$thread;

EXPDP fully prepared database scripts

#!/bin/bashsource/home/oracle/.bash_profileexport Oracle_base=/path/to/oracle/baseexport ORACLE_HOME= $ORACLE _ Base/product/12.1.0/dbhome_1export oracle_sid=${oracle_sid}export path= $PATH: $HOME/bin: $ORACLE _home/binexport LD_ library_path= $ORACLE _home/lib:/usr/libdate= ' date +%y%m%d '; EXPDP uesrname/[email protected]acle_sid directory=DUMP_ DIR dumpfile=filename_$date.dmp Logfile=expdp_filename_$date.log

Reference Document: EXPDP Introduction very detailed

Official documents

IMPDP Data Recovery

--  Create tablespace and set self-growth (note modify tablespacename and path) (because the size of a tablespace file is limited, more than 100 g looks, so add multiple tablespace files) create tablespace  TABLESPACENAME  datafile   '/path/to/tablespace/tablespacename.dbf '  size 2g  autoextend on; alter tablespace TABLESPACENAME add datafile  '/path/to /TABLESPACE/TABLESPACENAME01.DBF '  size 2g autoextend on; --  Create user (environment and backup are the same) create user username identified by password default tablespace  tablespacename;--   Authorized User grant dba to username;--If the DBA authority is considered too large, only the required permissions are given grant  Execute on sys. Dbms_lock to username;grant execute on sys. Dbms_pipe to username;grant execute on sys. dbms_crypto to username;--  Create backup file directory (directory to already exist) create directory dump_dir as  ' /path/to/dir '; --  directory read/write authorization Grant read,write on directory dump_dir to USERNAME;--  recover data, if not modified tablespace name,  remap_tablespace do not need impdp username/[email  protected]${oracle_sid} directory=dump_dir dumpfile=filename_$date.dmp logfile=imp_ Filename_$date.log  remap_tablespace=old_tablespacename:tablespacename

Rman Incremental Backup

Understanding the gap is too big to be caught dead.

Rman Backing up data

Rman Recovery Data

Oracle RMAN Incremental backup Full recovery test

The following is the Rman incremental backup script (need to change oracle_sid and Dump_dir)

Incremental Backup Level
0: Equivalent full backup, back up the entire datafile blocks, can be used as the starting point of incremental backup;
1-4:2 backup modes at this level
Differential Incremental Backup: The backup includes a change block from level n or lower, n can be specified; Lower is a large number
Cumulative Incremental Backup: The backup includes a change block from level n-1 or lower, n can be specified
For example, a differential incremental backup is a block that the backup changes every day, while a cumulative incremental backup changes the blocks from the starting point to multiple days.

The backup effect is:

The week is a cycle, Sunday is the starting time, Sunday on the line of full-time, Monday, three cumulative incremental backup, Thursday differential incremental backup, Friday cumulative incremental backup, 1th per month will be cleared


#!/bin/bash
Source/home/oracle/.bash_profile
#ORACLE_SID =oracle_sid #改ORACLE_SID
#ORACLE_HOME = #ORACLE_HOME
echo "Oracle_sid = ${oracle_sid},oracle_home = $ORACLE _home"
Logfile= ' dirname $ '/orabkup.log
echo "See LogFile in" $LOGFILE
Date= ' Date +%y-%m-%d '
echo "----------------------------start Backup----------------------------------" >> $LOGFILE
Date >> $LOGFILE
#every 1th Day of month truncate the logfile
dy= ' Date +%d '
If [$dy-eq 1]; Then
Cat/dev/null > $LOGFILE
Fi
unset dy

week_daily= ' Date +%a '
Case ' $WEEK _daily ' in
"Mon")
bak_level=2;;
"Tue")
bak_level=2;;
"Wed")
bak_level=2;;
"Thu")
bak_level=1;;
"Fri")
bak_level=2;;
"Sat")
bak_level=2;;
"Sun")
Bak_level=0;;
"*")
Bak_level=error
Esac
echo "Today is $WEEK _daily, backup level is $BAK _level" >> $LOGFILE

$ORACLE _home/bin/rman target/1>> $LOGFILE <<eof
run{Allocate channel C1 device type disk;
Allocate channel C2 device type disk;
Allocate channel C3 device type disk;
Allocate channel C4 device type disk;
Crosscheck backup;
Backup as Compressed backupset
Incremental level $BAK _level tag ' ${oracle_sid}_lev_$bak_level '
Database include current controlfile format ' Dump_dir/${oracle_sid}_%u_%t.bak ';
Release channel C1;
Release channel C2;
Release channel C3;
Release channel C4;
SQL ' alter system archive log current ';
Delete noprompt expired backup;
Delete noprompt obsolete device type disk;
Crosscheck Archivelog All;
Delete noprompt expired archivelog all;
Delete noprompt Archivelog all completed before ' sysdate-7 ';
#exit
}
Eof

Date >> $LOGFILE
echo "---------------------------End Backup----------------------------------" >> $LOGFILE



ORACLE12C data backup and recovery strategy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.