Cold/hot/logical backup and recovery

Source: Internet
Author: User

Cold/hot/logic is the most basic three types of backup and recovery in ORACLE, which is also the simplest and most primitive. They appeared before 8i, but it is inferior to the recovery manager RMAN, however, RMAN only appears after 8 I, and the STANDBY (data guard after 9i) that occurs at 8 I is a more advanced database backup and recovery.

................

For databases that are relatively small and not 7X24, using these three basic backups is sufficient to save data security, but it is not as good as RMAN. For databases that are oversized or 7X24, only STANDBY is used.

Next, let's talk about the three basic backup and recovery types. We will talk about them later in RMAN and STANDBY.

I. Logical backup and recovery

1. Backup. Is to use the exp program to export database objects, generally all are exported, Syntax: $ ORACLE_HOME/bin/exp system/manager @ prod file =/oracle/backup/oradata/expprod. dmp full = y log =/oracle/backup/log/explog. log

You can also export data in user/table mode.

$ ORACLE_HOME/bin/exp help = y

2. Restore. It is to use the imp program to import all objects from the backup file. Syntax:

$ ORACLE_HOME/bin/imp system/manager @ prod file =/oracle/backup/oradata/expprod. dmp full = y log =/oracle/backup/log/implog. log

Note: Some objects may need to be re-compiled for use after the import.

Logical backup and recovery are not suitable for large databases because of the slow speed. However, starting from 10 Gb, logical Backup provides two high-speed export/import methods: expdb and impdb, in either of the two ways, you must create a directory in the database: create or replace directory DMPDIR as '/oracle/backup/oradata'

After creating a directory, you can export/import the syntax like exp/imp:

$ ORACLE_HOME/bin/expdp system/manager DIRECTORY = dmpdir dumpfile = expdpprod. dmp full = y

DMPDIR is the directory object created in the database.

Ii. Cold backup and recovery

1. Backup. It is to close the database, and then use the COPY command of the operating system to COPY the data files, log files, control files, and initialization parameter files to the backup directory.

-- Back up all data files

Cp $ ORACLE_BASE/oradata/*. dbf/oracle/backup/oradata/*. dbf

-- Back up all log files

Cp $ ORACLE_BASE/oradata/*. log/oracle/backup/oradata/*. log

...

2. Restore. Close the target database and use the COPY command of the operating system to COPY data files, log files, control files, and initialization parameter files from the backup directory to the corresponding database directory.

-- Restore all data files

Cp/oracle/backup/oradata/*. dbf $ ORACLE_BASE/oradata/*. dbf

-- Restore all log files

Cp/oracle/backup/oradata/*. log $ ORACLE_BASE/oradata/*. log

...

Iii. hot backup and recovery

To use hot backup, first place the database in archive Mode

-- Use archive log list to check whether the database is in archive Mode

SQL> archive log list;

Database log mode No Archive Mode

Automatic archival Disabled

...

-- The database is not in archive mode. You must disable reload before modification.

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount;

ORACLE instance started.

Total System Global Area 171966464 bytes

Fixed Size 787988 bytes

Variable Size 145750508 bytes

Database Buffers 25165824 bytes

Redo Buffers 262144 bytes

Database mounted.

-- Change the database to archive Mode

SQL> alter database archivelog;

Database altered.

-- Use archive log list to check that the database is in archive mode.

SQL> archive log list;

Database log mode Archive Mode

Automatic archival Enabled

...

SQL> alter database open;

Database altered.

Now, the database is in archive mode and hot backup can be performed for the database.

1. Backup

-- Back up the tablespace (release the data file that locks the SCN)

Alter tablespace name begin backup

! Cp tablespace data file/oracle/backup/data/

Alter tablespace name end backup

...

-- Backup archiving logs

! Cp $ LOG_ARCHIVE_DEST/*/oracle/backup/log /*

-- Backup control file

Alter database backup controlfile to '/oracle/backup/ctlfile. Bak'

2. Recovery

-- Close the database

Shutdown immediate;

-- Restore data files and archive logs

! Cp oracle/backup/data/* $ ORACLE_BASE/oradata /*

! Cp oracle/backup/log/* $ ORACLE_BASE/oradata /*

-- Incomplete recovery

Startup mount

Recover database until time 'yyyy-mm-dd hh24: mi: ss ';

-- Open the database and reset the log

Alter database open resetlogs

Here, Hot Backup Recovery is a simple and Incomplete recovery, and there are several other Incomplete recovery; in addition to Incomplete recovery, there are also full recovery; incomplete recovery and full recovery are two different concepts.

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.