expdp导出单个用户shell脚本 aix和linux平台上

文章目录

  • 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








  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值