文章目录
- expdp_schema_aix_and_linux.sh
#!/bin/sh
#
# $Header: expdp_schema_aix_and_linux.sh 22-OCT-2018 jia.zeng $
#
# NAME
# expdp_schema_aix_and_linux.sh - expdp schema shell script
#
# DESCRIPTION
#
# NOTES
#
# MODIFIED (MM/DD/YY)
# jia.zeng 22/OCT/2018
# jia.zeng 15/NOV/2018
ORACLE_HOME=`env | grep ORACLE_HOME | awk -F "=" '{print $2}'`
ORACLE_SID=`env | grep ORACLE_SID | awk -F "=" '{print $2}'`
usage() {
echo "=============================================================="
echo "Usage:sh $0 <schema_name> <directory_name> <parallel> <tnsnames>"
echo "<schema_name> is the name of schema which you want to expdp"
echo "<directory_name> is the name of directory which you want to expdp"
echo "<parallel> is the number of active workers for current job which you want to expdp"
echo "<tnsnames> is the tnsnames of pdb datebase which you want to expdp"
echo "=============================================================="
exit 1
}
test $# -lt 2 && usage
test $# -gt 4 && usage
test $# -eq 2 && parameter=2
test $# -eq 3 && parameter=3
test $# -eq 4 && parameter=4
echo "recent enviroment ORACLE_HOME is $ORACLE_HOME"
echo "recent enviroment ORACLE_SID is $ORACLE_SID"
if [ $parameter -eq 2 ] ;
then
echo "the number of parameters after shell script expdp_schema_aix_and_linux.sh are " $parameter
schema_name=$1
directory_name=$2
parallel=1
echo "This shell will expdp dmpfile of the following schema: $schema_name from database recent instance $ORACLE_SID into the directory:$directory_name at parallel: $parallel"
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#Aix usage:
read yes_or_no?"请核对:后的信息是否正确,正确请输入Y继续执行脚本,错误请输入N:"
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#Linux usage:
# read -p "请核对:后的信息是否正确,正确请输入Y继续执行脚本,错误请输入N:" yes_or_no
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if [ $yes_or_no = "Y" ] ;
then
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
read username?"请输入expdp使用的username:"
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#Linux usage:
# read -p "请输入expdp使用的username:" username
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if [ -n $username ] ;
then
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#Aix usage:
read password?"请输入expdp使用的password:"
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#Linux usage:
# read -p "请输入expdp使用的password:" password
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if [ -n $password ] ;
then
begin_time=`date +%Y%m%d_%k%M%S`
echo "This shell begin at $begin_time"
nohup expdp $username/$password directory=$directory_name dumpfile=$schema_name-`date +%Y%m%d_%k%M%S`_%U.dmp logfile=$schema_name-`date +%Y%m%d_%k%M%S`.log schemas=$schema_name parallel=$parallel compression=all &
end_time=`date +%Y%m%d_%k%M%S`
echo "This shell end at $end_time"
else
echo "错误,expdp使用的password为空"
end_time=`date +%Y%m%d_%k%M%S`
echo "This shell shutdown at $end_time"
exit 3
fi
else
echo "错误,expdp使用的username为空"
end_time=`date +%Y%m%d_%k%M%S`
echo "This shell shutdown at $end_time"
exit 2
fi
else
end_time=`date +%Y%m%d_%k%M%S`
echo "This shell shutdown at $end_time"
exit 0
fi
elif [ $parameter -eq 3 ] ;
then
echo "the number of parameters are " $parameter
schema_name=$1
directory_name=$2
parallel=$3
echo "This shell will expdp dmpfile of the following schema: $schema_name from database: recent instance $ORACLE_SID into the directory: $directory_name at parallel: $parallel"
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#Aix usage:
read yes_or_no?"请核对:后的信息是否正确,正确请输入Y继续执行脚本,错误请输入N:"
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#Linux usage:
# read -p "请核对:后的信息是否正确,正确请输入Y继续执行脚本,错误请输入N:" yes_or_no
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if [ $yes_or_no = "Y" ] ;
then
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
read username?"请输入expdp使用的username:"
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#Linux usage:
# read -p "请输入expdp使用的username:" username
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if [ -n $username ] ;
then
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#Aix usage:
read password?"请输入expdp使用的password:"
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#Linux usage:
# read -p "请输入expdp使用的password:" password
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if [ -n $password ] ;
then
begin_time=`date +%Y%m%d_%k%M%S`
echo "This shell begin at $begin_time"
nohup expdp $username/$password directory=$directory_name dumpfile=$schema_name-`date +%Y%m%d_%k%M%S`_%U.dmp logfile=$schema_name-`date +%Y%m%d_%k%M%S`.log schemas=$schema_name parallel=$parallel compression=all &
end_time=`date +%Y%m%d_%k%M%S`
echo "This shell end at $end_time"
else
echo "错误,expdp使用的password为空"
end_time=`date +%Y%m%d_%k%M%S`
echo "This shell shutdown at $end_time"
exit 3
fi
else
echo "错误,expdp使用的username为空"
end_time=`date +%Y%m%d_%k%M%S`
echo "This shell shutdown at $end_time"
exit 2
fi
else
end_time=`date +%Y%m%d_%k%M%S`
echo "This shell shutdown at $end_time"
exit 0
fi
else
echo "the number of parameters are " $parameter
schema_name=$1
directory_name=$2
parallel=$3
tnsnames=$4
echo "This shell will expdp dmpfile of the following schema: $schema_name from database:tnsnames $tnsnames into the directory $directory_name at parallel: $parallel"
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#Aix usage:
read yes_or_no?"请核对:后的信息是否正确,正确请输入Y继续执行脚本,错误请输入N:"
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#Linux usage:
# read -p "请核对:后的信息是否正确,正确请输入Y继续执行脚本,错误请输入N:" yes_or_no
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if [ $yes_or_no = "Y" ] ;
then
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
read username?"请输入expdp使用的username:"
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#Linux usage:
# read -p "请输入expdp使用的username:" username
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if [ -n $username ] ;
then
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#Aix usage:
read password?"请输入expdp使用的password:"
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#Linux usage:
# read -p "请输入expdp使用的password:" password
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if [ -n $password ] ;
then
begin_time=`date +%Y%m%d_%k%M%S`
echo "This shell begin at $begin_time"
nohup expdp $username/$password@$tnsnames directory=$directory_name dumpfile=$schema_name-`date +%Y%m%d_%k%M%S`_%U.dmp logfile=$schema_name-`date +%Y%m%d_%k%M%S`.log schemas=$schema_name parallel=$parallel compression=all &
end_time=`date +%Y%m%d_%k%M%S`
echo "This shell end at $end_time"
else
echo "错误,expdp使用的password为空"
end_time=`date +%Y%m%d_%k%M%S`
echo "This shell shutdown at $end_time"
exit 3
fi
else
echo "错误,expdp使用的username为空"
end_time=`date +%Y%m%d_%k%M%S`
echo "This shell shutdown at $end_time"
exit 2
fi
else
end_time=`date +%Y%m%d_%k%M%S`
echo "This shell shutdown at $end_time"
exit 0
fi
fi