Database Reference
In-Depth Information
The script generates a hotback.sql script. This script contains the commands for performing the hot backup.
Here is a listing of the hotback.sql script for a test database:
spo /u01/hbackup/O12C/hotlog.txt
select max(sequence#) from v$log;
alter database begin backup;
!cp /u01/dbfile/O12C/system01.dbf /u01/hbackup/O12C
!cp /u01/dbfile/O12C/sysaux01.dbf /u01/hbackup/O12C
!cp /u01/dbfile/O12C/undotbs01.dbf /u01/hbackup/O12C
!cp /u01/dbfile/O12C/users01.dbf /u01/hbackup/O12C
!cp /u01/dbfile/O12C/tools01.dbf /u01/hbackup/O12C
alter database end backup;
alter database backup controlfile to '/u01/hbackup/O12C/controlbk.ctl' reuse;
alter system archive log current;
select max(sequence#) from v$log;
select member from v$logfile;
spo off;
You can run this script manually from SQL*Plus, like this:
SQL> @hotback.sql
If the previous script fails on a statement before ALTER DATABASE END BACKUP is executed, you must take
your database (tablespaces) out of backup mode by manually running ALTER DATABASE END BACKUP from sQL*plus
(as the SYS user).
Caution
While you generate the hot backup script, it's prudent to generate a script that you can use to copy the data files
from a backup directory. You have to modify the hbdir variable in this script to match the location of the hot backups
for your environment. Here is a script that generates the copy commands:
#!/bin/bash
ORACLE_SID=O12C
ORACLE_HOME=/u01/app/oracle/product/12.1.0.1/db_1
PATH=$PATH:$ORACLE_HOME/bin
#
sqlplus -s <<EOF
/ as sysdba
set head off pages0 lines 132 verify off feed off trimsp on
define hbdir=/u01/hbackup/O12C/
define dbname=$ORACLE_SID
spo hotrest.sql
select '!cp ' || '&&hbdir' || substr(name,instr(name,'/',-1,1)+1)
|| ' ' || name from v\$datafile;
spo off;
EOF
#
exit 0
 
Search WWH ::




Custom Search