Oracle Tutorial: User-managed backup

Source: Internet
Author: User

SQL> host operating system commands; execute operating system commands in SQL * plus.
User-managed backup
Full backup:
Data files, control files, redo logs, or archive files (optional), parameter files, and password files

Obtain database file information for backup
V $ datafile
Select name, status from v $ datafile;
V $ controlfile
Select name from v $ controlfile;
V $ logfile
Select member from v $ logfile;
DBA_DATA_FILES
Select file_name, tablespace_name from dba_data_files;

Query the tablespace corresponding to the data file
Select t. name tablespace, f. name datafile
From v $ tablespace t, v $ datafile f
Where t. ts # = f. ts #
Order by t. name;

In non-archive mode, only cold backup is allowed (Database Backup is disabled). In archive mode, cold backup and hot backup are supported.

Cold backup script (in linux)
Set feedback off heading off verify off trimspool off
Set pagesize 0 linesize 200
Define dir = '/tmp/wb'
Define ws = '/tmp/ws. SQL'
Spool & ws
Select '! Cp '| name |' & dir' from v $ datafile order by 1; // order by 1: sort by the first column
Select '! Cp '| member |' & dir' from v $ logfile order by 1;
Select '! Cp '| name |' & dir' from v $ controlfile order by 1;
Select '! Cp '| name |' & dir' from v $ tempfile order by 1;
Spool off
Shutdown immediate
@ & Ws
Startup

Hot Standby:
Data files, control files, archive files, parameter files, and password files

Hot Standby tablespace Trilogy
1. alter tablespace xxwz begin backup;
2. Back up the data files corresponding to the tablespace
3. alter tablespace xxwz end backup;
It is best to back up archive and control files.

The alter tablespace xxwz begin backup statement does three things.
1. The tablespace is checkpoint.
2. the SCN in the header of the data file corresponding to the tablespace stops growing.
3. The entire changed data block will be written into the redo log.

SQL> select dbms_rowid.rowid_block_number (rowid) blk, name from bbk; Use PL/SQL to view the block location of the record;
$ Dd if = example. dbf ibs = 8192 skip = 1011 count = 2 | string; copy an object with the specified size.

V $ backup

When the Hot Standby tablespace is suddenly powered off, the database can only start to the mount state. Use v $ backup to query the backup status and end the tablespace being backed up. Alter database datafile 'xxx. dbf' end backup or alter database end backup.

Backup of read-only tablespace
Alter tablespace xxx read only; set to read-only, the control file is changed
Back up data files and control files;

Backup of Hot Standby control files (when control files are changed)
Alter database backup controlfile to 'd:/xxxx. ctl ';
Or
Alter database backup controlfile to trace as 'd:/xxx. SQL '; some information is lost.

Use DBVERIFY to check whether the backup file is damaged
Dbv file = xxwz_data.dbf feedback = 100 // check the data file
Damage Detection table
First use select segment_name, tablespace_id, header_file, header_block from sys_dba_segs where segment_name like '% FRUIT %'; FRUIT is the table name, in upper case
Use dbv userid = sys/sys segment_id = 4.3.395/4 as tablespace_id, 3 as, header_file, and 395 as header_block.

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.