Oracle database Backup and Recovery

Source: Internet
Author: User
Tags one table
When we use a database, we always want the contents of the database to be reliable and correct, but because of the calculation
Failure of the machine system (including machine failure, media failure, misoperation, etc.), the database may sometimes be destroyed,
How to recover data as soon as possible is a top priority. If you make a backup of your database at this time, then the number of restores
It seems to be easy. This shows that a good database backup is how important, the following author to ORACLE7
As an example, to describe the backup and recovery of the database. ORACLE databases have three standard backup methods that
Export/import (Export/import), cold backup, hot backup, respectively. Export backup is a logical backup, cold
Backup and hot backup is a physical backup.

----One, export/import (Export/import)

----The use of export can be extracted from the database, the use of import can be extracted from the data sent
Back to the Oracle database.

----1. Simple Export data (export) and imported data (import)

----Oracle supports three types of output:

----(1) Table method (t), the data for the specified table is exported.

----(2) User Way (U), all objects and data of the specified user are exported.

----(3) whole library (full) to export all objects in the database.

The process of----data export (import) is the reverse process of data import (export), and their data flow is not
With.

----2. Incremental Export/Import

----Incremental export is a common method of data backup that can only be implemented for the entire database and must be
Exported for system. When making this export, the system does not require any questions to be answered. The export file name defaults to
Export.dmp, if you do not want your output file to be named Export.dmp, you must indicate on the command line that you want to use the
's file name.

----Incremental export includes three types:

----(1) "Full" incremental export (Complete)

----Backup the entire database, for example:

----$exp System/manager inctype=complete file=990702.dmp

----(2) "Incremental" incremental export

----The data that was changed after the last backup was backed up. Like what:

----$exp System/manager inctype=incremental file=990702.dmp

----(3) "Cumulative" incremental export (cumulative)

----Cumulative export is simply exporting information that has changed in the database since the last "full" export. Like what


----$exp System/manager inctype=cumulative file=990702.dmp

----The database administrator can schedule a backup schedule, using data exported in three different ways to reasonably and efficiently
Complete.

----such as database backup tasks can be arranged as follows:

----Monday: Full export (A)

----Tuesday: Incremental export (B)

----Wednesday: Incremental export (C)

----Thursday: Incremental export (D)

----Friday: Cumulative export (E)

----Saturday: Incremental export (F)

----Sunday: Incremental export (G)

----If the database is accidentally compromised in Sunday, the database administrator can restore the database by following these steps


----The first step: to regenerate the database structure with command create DB;

----Step Two: Create a large enough additional back segment.

----Step Three: Full incremental import a:

----$imp System./manager inctype= rectore full=y file=a

----Step Fourth: Cumulative incremental import E:

----$imp System/manager inctype= rectore full=y FILE =e

----Step Fifth: Recent incremental import F:

----$imp System/manager inctype=restore full=y file=f

----Two, cold backup

----Cold backup occurs when the database has been shut down properly, and will provide us with a complete
The entire database. Cold backup is a way of copying critical files to a different location. For backing up Oracle information
, cold backup is the quickest and safest way to do this. The advantages of cold backup are:

----1. is a very fast backup method (just copy the file)

----2. Easy to archive (simple copy)

----3. Easy to recover to a point in time (just copy the file back)

----4. Can be combined with the archiving method to restore the "latest state" of the database.

----5. Low maintenance, high safety.

----But cold backups also have the following disadvantages:

----1. When used alone, it can only provide a recovery at a point in time.

----2. In the process of implementing a backup, the database must be backed up without any other work. Other words
During a cold backup, the database must be off state.

----3. If disk space is limited, it can only be copied to other external storage devices such as tape, which can be slow.

----4. You cannot restore by table or by user.

----if possible (primarily for efficiency), you should back up the information to disk and then start the database (using
User can work) and copy the backed-up information to the tape (the database can work as well as the copy). Cold
Files that must be copied in the backup include:

----1. All data files

----2. All control files

----3. All online redo log files

----4. Init.ora file (optional).

----It is worth noting that cold backups must be done in the case of a database shutdown, when the database is open
, performing a database file system backup is not valid

----Below is a complete example of doing a cold backup:

----(1) Close database $sqldba lmode=y

----SQLDBA >connect internal;

----SQLDBA >shutdown normal;

----(2) Backup all time files, redo log files, control files, initialization parameters with copy command
File

----SQLDBA >! CP < file > < backup directory >

----(3) Restart Oracle database

----$SQLDBA Lmode=y

----SQLDBA >connect internal;

----SQLDBA >startup;

----Three, hot backup

----Hot backup is a way to back up data in Archivelog mode when the database is running. The
So if you have a cold backup last night and there are today's hot backup files, in the event of a problem, you can
To use this information to recover more information. Hot backup requires the database to operate in Archivelog mode and requires
A lot of file space. Once the database is running in Archivelog state, it can be backed up. The life of a hot backup
Make the file consist of three parts:

----1. The data file is backed up in a tablespace in one table space.

----(1) Set table space to backup state

----(2) data files for the backup table space

----(3) Restore the table space to a normal state

----2. Back up the archive log file.

----(1) Temporarily stop the archive process

----(2) Log the files in the archive redo log target directory

----(3) Restart the archive process

----(4) Backup archived redo log files

----3. Backing up copy files with the ALTER DATABASE backup Controlfile command

The advantages of----hot backup are:

----1. Can be backed up at the table space or data file level for short backup time.

----2. The database is still available for backup.

----3. Can reach a second level recovery (revert to a point in time).

----4. Almost all database entities can be recovered.

----5. Recovery is quick and, in most cases, restored when the database is still working.

The disadvantages of----hot backup are:

----1. There is no mistake, otherwise the consequence is serious.

----2. If a hot backup is unsuccessful, the resulting results are not available for point-in-time recovery.

----3. Because it is difficult to maintain, so be particularly careful, do not allow "failure to end &rdquo
Related Article

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.