(1)创建导出目录
> sqlplus system/oracleSQL> 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 KB1 rows
. . exported "PINGCHUAN"."TEST_TABLE2"4.937 KB1 rows
. . exported "ZTE"."TEST_TABLE3"4.929 KB1 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.dmpexp20150623.log