Oracle使用資料泵定時備份多個schema的指令碼

zhenghaishu發表於2015-06-24

(1)建立匯出目錄
> sqlplus system/oracle
SQL> create directory dump_dir as '/home/oracle/dump';

Directory created.

2)編寫指令碼

指令碼存放位置:/home/oracle/

指令碼名稱:backup_logic.sh

指令碼內容:

#!/bin/bash

 

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1

export ORACLE_SID=zxin

export PATH=$PATH:$ORACLE_HOME/bin

 

EXPFILE=`date '+exp%Y%m%d.dmp'`

LOGFILE=`date '+exp%Y%m%d.log'`

 

expdp system/oracle directory=dump_dir dumpfile=$EXPFILE logfile=$LOGFILE schemas=pingchuan,zte;

 

3)執行指令碼

> cd /home/oracle/

> ./backup_logic.sh

Export: Release 10.2.0.1.0 - 64bit Production on 星期二, 23 6, 2015 18:26:12

 

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

 

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production

With the Partitioning, OLAP and Data Mining options

Starting "SYSTEM"."SYS_EXPORT_SCHEMA_01":  system/******** directory=dump_dir dumpfile=exp_2015062318.dmp logfile=exp_2015062318.log schemas=pingchuan,zte

Estimate in progress using BLOCKS method...

Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA

Total estimation using BLOCKS method: 192 KB

Processing object type SCHEMA_EXPORT/USER

Processing object type SCHEMA_EXPORT/SYSTEM_GRANT

Processing object type SCHEMA_EXPORT/ROLE_GRANT

Processing object type SCHEMA_EXPORT/DEFAULT_ROLE

Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA

Processing object type SCHEMA_EXPORT/TABLE/TABLE

Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

. . exported "PINGCHUAN"."TEST_TABLE"                    4.937 KB       1 rows

. . exported "PINGCHUAN"."TEST_TABLE2"                   4.937 KB       1 rows

. . exported "ZTE"."TEST_TABLE3"                         4.929 KB       1 rows

Master table "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded

******************************************************************************

Dump file set for SYSTEM.SYS_EXPORT_SCHEMA_01 is:

  /home/oracle/dump/exp_2015062318.dmp

Job "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully completed at 18:26:18

 

4)檢查結果

> cd /home/oracle/dump

> ls

exp20150623.dmp  exp20150623.log

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29485627/viewspace-1710095/,如需轉載,請註明出處,否則將追究法律責任。

相關文章