Oracle Database Backup

Source: Internet
Author: User

The ORACLE tutorial is about Oracle database backup. I. significance:
When we use a database, we always hope that the database content is reliable and correct. However, due to computer system faults (hardware faults, network faults, processes)
Faults and system faults) affect the operations of the database system, affect the correctness of the data in the database, or even damage the database, so that all or part of the data in the database is lost.
Loss. Therefore, when the above fault occurs, we hope to re-establish a complete database, which is called database recovery. The restoration subsystem is a database management system.
. The recovery process changes with the structure affected by the fault type.
Ii. Backup Methods
ORACLE databases have three standard backups. EXPORT/IMPORT (EXPORT/IMPORT), cold backup, hot backup.
Exporting backup is a logical backup. This method involves reading a series of database logs and writing them into files. The reading of these logs is not related to the location.
Cold backup and hot backup are physical backups (also known as low-level backups) that involve the files that make up the database, but do not consider the logical content.
The following describes the three backup methods and their features:
(1) EXPORT/IMPORT (EXPORT/IMPORT)
EXPORT/IMPORT is used to remove data from/into the database.
1. EXPORT backs up the data in the database into a binary system FILE called the "export dump file" and re-generates the database write
.
It has three modes:
A. User Mode: export data of all user objects and objects;
B. Table mode: export all or specified tables of the user;
C. entire database: export all objects in the database.
There are three types of backup:
A. complete export: backs up the entire database;
B. COMULATIVE ERPORT: Back up the data changed in the previous accumulation backup;
C. incremental (increamental export): The data changed after the last backup.
The EXPORT command can be performed interactively. For the specific meanings of each parameter, see the appendix.
When exporting a backup, we need to consider one issue, that is, the export consistency. During the export process, each read is read from a table.
It is started on its own when it is a feature, but the reading time of different tables is different. Therefore, when the export starts to read a table, the data in the table is the number of exported data.
In this way, when most tables are connected by internal and external keywords, changes to these associated tables during the export process will lead to inconsistent Export
To avoid this, we can arrange the export process without table operations. In addition, when the restrictep consistent option in ORACLE is
This ensures data consistency.

2. IMPORT:
The import process is the inverse process of the export. This command First reads the exported dump binary file and runs the file to restore the user and data of the object.
The method for executing the IMPORT command is related to the EXPORT scheme.
1. If the EXPORT implements the FULL mode scheme, all data objects, including tablespaces and data files, will be imported at the time of IMPORT.
But considering the physical layout of the database, it is useful to create tablespaces and users in advance.
2. If the EXPORT uses the INCREMENTAL/CUMULATIVE mode, you must set the tablespace, user, and data file in advance.
(2) Cold backup
Cold backup occurs when the database is shut down normally. When the database is shut down normally, it will provide us with a complete database.
Every file used by the database is backed up. These files include:
☆All data files
☆All Control Files
☆All online redo log files
☆Init. ORA file (optional)
It is worth noting that the cold backup must be completed when the database is closed. When the database is open, the execution of the database file system backup is invalid.
The general steps for cold backup are as follows:
1: Shut down the instance to be backed up normally );
2: Back up the entire database to a directory
3: Start the database
1: SQLDBA> connect internal
SQLDBA> shutdown normal
2: SQLDBA>! Cp <file> <backup directory>
Or
SQLDBA>! Tar cvf/dev/rmt/0/wwwdg/oracle
3: SQLDBA> startup

(3) Hot Backup (ACHIRELOG)
It takes 24 hours for the database to run, and new data can be added at any time. Data loss will affect the entire company. archivelog mode is used for physical backup.
? Set the database to automatic archivelog mode,
# Su-oracle
% Svrmgrl
Svrmgrl> connect internal
Svrmgrl> startup mount
Svrmgrl> alter database archivelog
Svrmgrl> shutdown
Svrmgrl> exit
% Vi initoracle7.ora
Add log_archive_start = true # if you want automatic archiving
Log_archive_dest = $ ORACLE_HOME/dbs/arch
Log_archive_format = log % s. arc
% Dbstart
% Ps-ef | grep arch
Oracle 1743 1 0 15:20:20? 0: 00 ora_arch_oracle7
Note: oracle database is in automatic archivelog mode

? Full offline entire database backup. After the database is initially completed, this backup is the basis for future backup. It provides all database-related
.
% Dbshut
% Cp/oracle/oradata/oracle7/system. dbf
/Oracle/oradata/oracle7/rbs. dbf
/Oracle/oradata/oracle7/temp. dbf
/Oracle/oradata/oracle7/tools. dbf
/Oracle/oradata/oracle7/users. dbf
/Oraclecle/app/oracle/product/7.3.2/dbs/application. dbf
/Oracle/app/oracle/product/7.3.2/dbs/apptmpsp. dbf
/Oracle/app/oracle/product/7.3.2/dbs/apprlbksp. dbf
/Oracle/oradata/oracle7/redooracle. log
/Oracle/oradata/oracle7/control1.ctl
/Oracle/oradata/oracle7/control2.ctl
/Oracle/oradata/oracle7/control3.ctl
<Backup directory>
% Dbstart
Note: The preceding *. dbf file is a data file, *. log file is a log file, and *. ctl file is a control file.
% Exit
% Tar uvf/dev/rmt/0 <backup files>
NOTE: If it is oracle 7.2, copy the corresponding data files, relog files, and control files.

6.3. perform partial online with archiving backups once a day.
# Su-oracle
% Svrmgrl
% Svrmgrl> connect internal
% Svrmgrl> alter tablespace billsp begin backup
% Svrmgrl> alter tablespace billtmpsp begin backup
% Svrmgrl> alter tablespace billrlbksp begin backup
% Svrmgrl> alter tablespace system begin backup
% Svrmgrl> alter tablespace rbs begin backup
% Svrmgrl> alter tablespace temp begin backup
% Svrmgrl> alter tablespace tools begin backup
% Svrmgrl> alter tablespace users begin backup
% Svrmgrl> host cp all datafile to the backup storage. # the file name ends with. dbf in step 1.
% Svrmgrl> alter tablespace billsp end backup
% Svrmgrl> alter tablespace billtmpsp end backup
% Svrmgrl> alter tablespace billrlbksp end

[1] [2] [3] Next page

The ORACLE tutorial is about Oracle database backup. Backup
% Svrmgrl> alter tablespace system end backup
% Svrmgrl> alter tablespace rbs end backup
% Svrmgrl> alter tablespace temp end backup
% Svrmgrl> alter tablespace tools end backup
% Svrmgrl> alter tablespace users end backup

Create an SQL file, as written above.

The billing system can recover to the point of failure when the failure occur.

VII. Recovery of backup files:
7.1 Restore Files:
Recovery of the "/etc/passwd" File
(Put the correct tape
(Run the following command to restore the "/etc/passwd" File
# Rsh www mt-f/dev/rmt/0 rew
(Locate the latest tape and bring it to the nearest "/etc/passwd". For example, to find the "/etc/passwd" file on Wednesday, run the following command)
# Rsh www mt-f/dev/rmt/0n fsf 2
# Ufsrestore if www:/dev/rmt/0n
Ufsrestore> ls
.:
Etc/
Ufsrestore> cd etc
Ufsrestore> ls
./Etc:
Passwd
Ufsrestore> add passwd
Warnign:./etc: File exists
Ufsrestore> verbose
Verbose mode on
Ufsrestore> extract
Extract requested files
You have not read any volumes yet.
Unless you know which volume your file (s) are on you shoshould start witch the last volume and work to wards
The first.
Specify next volume #: 1
Extract file./etc/passwd
Add links
Set directory mode, ower, and times.
Set owner/mode '.'? (Yn) n
Directories already exit, set mode anyway? (Yn) y
Ufsrestore> quit
Hot Backup can be performed when the database is enabled. Generally, you can use the Alter command to change the tablespace status to start backup. After the backup is complete,
Restore the original status. Otherwise, the redo log will be mismatched, causing the database to completely overwrite the affected tablespace at the next startup. Hot Backup requirements:
1. for hot backup, the database must be operated in Archivelog mode. In SQLDBA state, use alter database archivelog | noarchivelog
To change the backup mode.
2. Hot Backup can only be performed when the database is not used or the usage is low.
3. Hot Backup requires a large amount of archival space.
In general, Oracle writes Online redo log files cyclically. When the first redo log file is filled up, write the second until the last and
After the last one is filled up, the background process LGWR will overwrite the first one. In Archivelog mode, the background process ARCH will
It is used as a copy. Generally, the redo log files of these documents are written into disks or tapes. If the disk space is sufficient, we recommend that you use a disk, which can be greatly reduced.
Less time required to complete the backup.
Before performing a hot backup, set log_archive_start In the config. ora file to true to set log_archive_dest
Specify the location of the archive redo log file:
Log_archive_dest =/wwwdg/oracle/arch
Log_archive_start = true
Once the database is running in the archivelog state, it can be backed up. The Hot Backup command file consists of three parts:
1. Data Files are backed up in one tablespace and one space:
A. Set the tablespace to the backup status.
B. Back up the data files in the tablespace.
C. Restore the tablespace to normal.
2. log files must be backed up and archived:
A. temporarily stop the archiving process
B. Files in the archive redo log target directory under log
C. Restart the archive process.
D. Back up the archived redo log file
3. Run the alter database backup controlfile command to back up and copy files.
Before the hot backup is run, the log_archive_dest directory may be full. In this case, you need to back up the directory, delete the file, and release the space. The procedure is as follows:
Steps:
1. Stop the archive process temporarily.
2. Record the files in the log_archive_dest directory.
3. Restart the archive process.
4. Back up the archive redo log file.
5. delete files in the directory.
Sqldba lmode = y <EOF arch1
Archive log stop;
Exit
EOF arch1
FILES = 'ls/wwwdg/oracle/arch *. dbf ';
Sqldba lmode = y <EOF arch2
Connect internal
Archive log start;
Exit
EOF arch2
Tar-rvf/dev/rmt/0 FILES
Rm-f $ FILES

The combination of logical backup and physical backup.
We have introduced three backup methods. During database backup, we should use the features of the three backup methods flexibly.
Features.

Method
Type
Recovery features
EXPORT
Logical type
Any database object can be restored to its export status.
Hudown
? Copy the latest copyes of datafile to the $ oracle_home/dbs directory.
? % Svrmgrl
? Svrmgrl> connect internal
... Svrmgrl> startup mount pfile = filename exclusive
? Svrmgrl> alter database recover;
Note: Data will be automatically restored to the point of failure;
? Svrmgrl> alter database open;
? When there are too many archive log files, you can delete the log ***. arc before current log sequence after partial backup.
# Su-oracle
% Svrmgrl
Svrmgrl> connect internal;
Svrmgrl> archive log list;
# The current log sequence is marked here. Suppose it is 360.
Svrmgrl> exit
$ Cd/billdg/oracle/app/oracle/product/7.3.2/dbs/arch
$ Rm ...... # delete the files before log360.arc, such as log359.arc, log358.arc.
Cold backup
Physical
The database can be shut down.
Hot Standby
Physical
The database can be restored to any time point.

When the database is relatively small and the processing service is also small, cold backup can be exported. It is enough to back up and export only one or two tables. Generally, it is better to back up the most
The final execution includes both logic and physical, and the export confirms the correctness of the database logic while the physical backup ensures the physical.
In addition, some storage media are required for backup, which should be managed
1: The media is numbered according to the backup content and date to avoid mistaken media during backup and recovery, resulting in loss of the original backup.
2: The media should be stored in a different location from the computer equipment to avoid damage to the backup and computer equipment in case of an accident in the computer room.

Appendix:
Tar command
Tar option [arguments] filename...
Option:
C: Create a New tarfile specified by the command line.
T: list the content in the tarfile.
X: Open the tarfile;
F: Use its filename or/dev/rmt/0 | 1
V: List restored file names;
P: Restore Files
Example:
# Tar cvf/dev/rmt/0/oracle
Backup/

Previous Page [1] [2] [3] Next page

The ORACLE tutorial is about Oracle database backup. All contents under root
# Tar tvf/dev/rmt/0
List all content on a tape
# Tar xvf/dev/rmt/0/oracle
Restore the content in the/oracle directory on the tape to the current directory.

Export options
Keyword content
USERID: username/password of the account that runs the Export command.
BUFFEER is used to obtain the buffer size of data rows.
FILE Export the name of the dump FILE
Whether the COMPRESS export should COMPRESS segments with fragments into a range, which will affect STORAGE
Clause,
When exporting GRANTS, do you want to export the authorization on the database object?
Does INDEXES need to export table INDEXES?
Whether the ROWS should export ROWS. If it is 'n', only the database is generated in the exported file.
Object DDL
Whether CONSSTRAINTS exports the old conventions of the table
If FULL is set to 'y', an entire database export operation will be executed.
The OWNER needs to export a series of database accounts, and then execute the USER export operations for these accounts
Work
TABLES to be exported. Execute the TABLE export operations for these TABLES.
RECORDLENGTH: the length of the exported file log (in bytes). The default value is usually used,
You have to pass the exported file in two different operating systems.
The type of the export operation that INCTYPE is executing (valid values include "COMPLETE" (default value ),
CUMULATIVE and IVCREMENTAL ")
A tag of the RECORD in the incremental export type to indicate whether logs are stored in the data dictionary.
Log export table in
The name of the parameter file to be exported. This file will contain all the input parameters
Item
ANALYZE indicates whether to write the statistics of the migrated object to the export dump file.
The CONSISTENT indicates whether to retain CONSISTENT read replication of all exported objects.
Name of the file to be written in the LOG export LOG
MLS indicates whether to export the MLS label
MLS_LABEL _ specifies the MLS label format

Import selected items
USERID: username/password of the account that runs the import command.
BUFFEER is used to obtain the buffer size of data rows.
Name of the FILE Import dump FILE
SHOW specifies whether the file content is displayed, rather than executed.
EGORE indicates whether errors are ignored when the 'create' command is executed. If
This parameter should be used when the imported object already exists.
If FULL is set to 'y', an entire database import operation will be executed.
FROMUSER has parameters only when FULL = N. It is a series of database accounts, its
The object should be read from the export dump file.
TOUSER: A series of database accounts. The objects deducted from the exported dump file will be imported to these accounts.
When importing GRANTS, do you want to import the authorization on the database object?
Does INDEXES need to import table INDEXES?
Whether the ROWS should import ROWS. If it is 'n', execute the database pair in the import File
Like DDL
If FULL is set to 'y', an entire database export operation will be executed.
TABLES
RECORDLENGTH refers to the length (in bytes) of the imported file logs. The default value is usually used,
Import files must be passed in two different operating systems
The type of the import operation that INCTYPE is executing (valid values include "COMPLETE" (default value ),
CUMULATIVE and IVCREMENTAL ")
The name of the parameter file to be passed to the import. This file will contain all the input parameters
Item
ANALYZE indicates whether to write the statistics of the migrated object to the import dump file.
Name of the file to be written into the LOG import LOG
Indicates whether to import the MLS label.

Hot Backup command file:
ORACLE_SID = oracle7
ORACLE_HOME =/wwwdg/oracle
Sqldba lmode = y <EOF arch1
Connect internal
Alter tablespace SYSTEM begin backup;
! Tar-cvf/dev/rmt/0/wwwdg/oracle/dbms/sys01.dbf
Alter tablespace SYSTEM end backup;

Alter tablespace BWT begin backup;
! Tar-cvf/dev/rmt/0/wwwdg/oracle/dbms/BWT1.dbf
Alter tablespace BWT end backup;

Archive log stop
Exit
EOF arch1
FILES = 'ls/wwwdg/oracle/arch *. dbf ';

Sqldba lmode = y <EOF arch2
Connect internal
Archive log start;
Exit
EOF arch2

Tar-rvf/dev/rmt/0 $ FILES
Rm-f $ files

Sqldba lmode = y <EOFarch3
Alter database backup controlfile
'/Wwwdg/oracle/dbms/bwtcontrfile. backup ';
Exit
EOF arch3

Tar-rvf/dev/rmt/0/wwwdg/oracle/bwt/bwtcontrofile. backup

Previous Page [1] [2] [3]

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.