1、編寫產生備份指令碼的指令碼
#cold backcup
remark set sql*plus variable to manipulate output //注釋
set feedback off heading off verify off trimspool off echo off time off
set pagesize 0 linesize 200
remark set sql*plus user variable used in this script //注釋
define bakdir='/disk1/backup/anny/cold_bak' //備份檔案的存放位置
define bakscp='/disk1/backup/anny/cold_bak/cold_cmd.sql' //執行備份的指令碼,自動產生
prompt *** Spooling to &bakscp //輸出提示
remark create a command file with file backup commands
spool &bakscp
select 'host cp '|| name ||' &bakdir ' from v$datafile order by 1;
select 'host cp '|| name ||' &bakdir ' from v$controlfile order by 1;
spool off;
remark shutdown the database cleanly
shutdown immediate; ——冷備份需要關庫執行
remark run the copy file commands form the operating system
@&bakscp
remark start the database again
startup;
本文URL地址:http://www.bianceng.cn/database/Oracle/201410/45405.htm
2、執行該指令碼產生了一個指令碼cold_cmd.sql,並執行該指令碼進行冷備份
SQL> conn /as sysdba
Connected.
SQL> @/export/home/oracle/sqlplus/anny_cold_bak
SP2-0734: unknown command beginning "cold backc..." - rest of line ignored.
*** Spooling to /disk1/backup/anny/cold_bak/cold_cmd.sql ——一下是指令碼內容
host cp /u01/app/oracle/oradata/anny/index01.dbf /disk1/backup/anny/cold_bak
host cp /u01/app/oracle/oradata/anny/lx01.dbf /disk1/backup/anny/cold_bak
host cp /u01/app/oracle/oradata/anny/lx02.dbf /disk1/backup/anny/cold_bak
host cp /u01/app/oracle/oradata/anny/lx03.dbf /disk1/backup/anny/cold_bak
host cp /u01/app/oracle/oradata/anny/lx04.dbf /disk1/backup/anny/cold_bak
host cp /u01/app/oracle/oradata/anny/sysaux01.dbf /disk1/backup/anny/cold_bak
host cp /u01/app/oracle/oradata/anny/system01.dbf /disk1/backup/anny/cold_bak
host cp /u01/app/oracle/oradata/anny/text01.dbf /disk1/backup/anny/cold_bak
host cp /u01/app/oracle/oradata/anny/undotbs01.dbf /disk1/backup/anny/cold_bak
host cp /u01/app/oracle/oradata/anny/user01.dbf /disk1/backup/anny/cold_bak
host cp /disk1/oradata/anny/control02.ctl /disk1/backup/anny/cold_bak
host cp /disk2/oradata/anny/control03.ctl /disk1/backup/anny/cold_bak
host cp /u01/app/oracle/oradata/anny/control01.ctl /disk1/backup/anny/cold_bak
Database closed.
Database dismounted.
ORACLE instance shut down.
ORACLE instance started.
Total System Global Area 314572800 bytes
Fixed Size 1279964 bytes
Variable Size 58722340 bytes
Database Buffers 251658240 bytes
Redo Buffers 2912256 bytes
Database mounted.
Database opened.