"Rookie Entry" single-instance database backup operation (-)

Source: Internet
Author: User

Test environment:

OS version: Red Hat Enterprise Linux Server Release 5.4 (Tikanga)

DB version: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0-production

Full-Library Cold backup:

Files that need to be backed up include: data files, control files, log files, parameter files

1. View the location where you want to back up files

Sql> select name from v$datafile union ALL select name from V$controlfile

2 UNION ALL select member from V$logfile;


NAME

--------------------------------------------------------------------------------

/u01/oracle/oradata/orcl/system01.dbf

/u01/oracle/oradata/orcl/undotbs01.dbf

/u01/oracle/oradata/orcl/sysaux01.dbf

/u01/oracle/oradata/orcl/users01.dbf

/u01/oracle/oradata/orcl/control01.ctl

/u01/oracle/oradata/orcl/control02.ctl

/u01/oracle/oradata/orcl/control03.ctl

/u01/oracle/oradata/orcl/redo03.log

/u01/oracle/oradata/orcl/redo02.log

/u01/oracle/oradata/orcl/redo01.log


Rows selected.


Sql> Show parameter SPFile;


NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

SPFile String/u01/oracle/db_1/dbs/spfileorcl.ora

2. Create a directory where the backup files are stored

[Email protected] oracle]$ mkdir ORCL_BK

3. Close the database and copy the files that need to be backed up to the specified directory

sql> shutdown Immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

[Email protected] orcl]$ pwd

/u01/oracle/oradata/orcl

[email protected] orcl]$ LL

Total 944856

-RW-R-----1 Oracle oinstall 7061504 Oct 23:39 control01.ctl

-RW-R-----1 Oracle oinstall 7061504 Oct 23:39 control02.ctl

-RW-R-----1 Oracle oinstall 7061504 Oct 23:39 control03.ctl

-RW-R-----1 Oracle oinstall 52429312 Oct 23:39 redo01.log

-RW-R-----1 Oracle oinstall 52429312 Oct 22:39 redo02.log

-RW-R-----1 Oracle oinstall 52429312 Oct 22:50 redo03.log

-RW-R-----1 Oracle oinstall 251666432 Oct 23:39 sysaux01.dbf

-RW-R-----1 Oracle oinstall 503324672 Oct 23:39 system01.dbf

-RW-R-----1 Oracle oinstall 20979712 Jul 22:00 temp01.dbf

-RW-R-----1 Oracle oinstall 26222592 Oct 23:39 undotbs01.dbf

-RW-R-----1 Oracle oinstall 5251072 Oct 23:39 users01.dbf

[[email protected] orcl]$ CP */u01/oracle/orcl_bk/

[Email protected] orcl_bk]$ cp/u01/oracle/db_1/dbs/spfileorcl.ora/u01/oracle/orcl_bk/

[Email protected] orcl]$ cd/u01/oracle/orcl_bk/

[email protected] orcl_bk]$ LL

Total 944856

-RW-R-----1 Oracle oinstall 7061504 Oct 23:40 control01.ctl

-RW-R-----1 Oracle oinstall 7061504 Oct 23:40 control02.ctl

-RW-R-----1 Oracle oinstall 7061504 Oct 23:40 control03.ctl

-RW-R-----1 Oracle oinstall 52429312 Oct 23:40 redo01.log

-RW-R-----1 Oracle oinstall 52429312 Oct 23:40 redo02.log

-RW-R-----1 Oracle oinstall 52429312 Oct 23:40 redo03.log

-RW-R-----1 Oracle oinstall 2560 Oct 23:42 Spfileorcl.ora

-RW-R-----1 Oracle oinstall 251666432 Oct 23:41 sysaux01.dbf

-RW-R-----1 Oracle oinstall 503324672 Oct 23:41 system01.dbf

-RW-R-----1 Oracle oinstall 20979712 Oct 23:41 temp01.dbf

-RW-R-----1 Oracle oinstall 26222592 Oct 23:41 undotbs01.dbf

-RW-R-----1 Oracle oinstall 5251072 Oct 23:41 users01.dbf

Hot backup:

1. Setting the database in archive mode

[[email protected] oracle]$ mkdir arch_dir--Create an archive path

[[email protected] oracle]$ mkdir ORCL_BK2--Create backup path

[Email protected] oracle]$ pwd

/u01/oracle

Sql> alter system set log_archive_dest_1= ' Location=/u01/oracle/arch_dir ' Scope=both;


System altered.


sql> shutdown Immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

sql> startup Mount;

ORACLE instance started.


Total System Global area 167772160 bytes

Fixed Size 1218316 bytes

Variable Size 71305460 bytes

Database buffers 92274688 bytes

Redo buffers 2973696 bytes

Database mounted.

sql> ALTER DATABASE open;


Database altered.

sql> archive log list;

Database Log Mode Archive mode

Automatic Archival Enabled

Archive Destination/u01/oracle/arch_dir

Oldest online log sequence 3

Next Log sequence to archive 5

Current log Sequence 5

sql> alter system switch logfile;


System altered.

2. Back up the required files

sql> ALTER DATABASE begin backup; --Inform the database of upcoming hot spares

Database altered.

1) Backup data file, online log file

[email protected] orcl]$ CP *.log/u01/oracle/orcl_bk2/

[email protected] orcl]$ CP *.dbf/u01/oracle/orcl_bk2/

2) Back up the control file (in one of two ways)

To generate a backup of the trace file:

sql> ALTER DATABASE backup Controlfile to trace as '/u01/oracle/orcl_bk2/control.trace ' reuse;


Database altered.

binary files for the resulting backup:

sql> ALTER DATABASE backup Controlfile to '/u01/oracle/orcl_bk2/control.bak ' reuse;


Database altered.

3) Backup parameter file

sql> create pfile= '/u01/oracle/orcl_bk2/initorcl.ora ' from SPFile;


File created.

sql> ALTER DATABASE end backup; --Inform the database of the hot standby end


Database altered.

Annotations: If you are backing up a tablespace, first place the tablespace in the offline state

Rman Backup:

Backup script:

[email protected] rman_sh]$ cat bkfull.sh

#!/bin/bash

# name:bkfull.sh

# DATE:2014/10/23

# Desc:backup Incremental Level 0 database with Rman

#this script would execute in the end of each Sunday

Export Oracle_base=/u01/oracle

Export Oracle_home=/u01/oracle/db_1

Export ORACLE_SID=ORCL

Export path= $ORACLE _home/bin: $PATH

Export Lang=en_us

Export Nls_lang=american_america. Al32utf8

Rman target/<< Eof_rman

run{

Configure retention policy to recovery windows of 7 days;

Configure Controlfile autobackup on;

Allocate channel C1 type disk;

Backup incremental Level 0 tag ' db0 ' format

'/u01/oracle/rman_bk/db_file/db0_%d_%t_%s ' database skip inaccessible

Include current controlfile;

Backup Archivelog all format '/u01/oracle/rman_bk/log/log_%u ' Delete all input;

Crosscheck backup;

Delete noprompt expired backup;

Delete NoPrompt obsolete;

Release channel C1;

}

#end

This article is from the "Dayonger Growth notes" blog, so be sure to keep this source http://dayonger.blog.51cto.com/9385723/1566964

"Rookie Entry" single-instance database backup operation (-)

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.