oracle_備份指令碼

wangzhensheng發表於2007-08-12

#!/usr/bin/sh
# ding yi huan jing bian liang
DATE=`date +%w`
DIR="/export/home/ORA_BAK"
BAK_CONF="${DIR}/bin"
RBAK_HOME="/manager/oracle/ORA_BAK"

export DATE DIR BAK_HOME

# export oracle dump file
dumpdb()
{
cd $DIR/DATA
$ORACLE_HOME/bin/exp file=$1_$DATE.dmp log=$1_$DATE.log compress=n
}

zip()
{
cd $DIR/DATA
if [ -f ${DIR}/DATA/$1_$DATE.dmp ] ; then
echo "$1 dmp is dump ... now compress ..."
rm -rf $DIR/DATA/$1_$DATE.dmp.Z
compress $1_$DATE.dmp
echo "database dmp compress OK...."
else
echo "$1 dmp isn't dump "
echo "datatbase dump not failed...."
fi
if [ -f ${DIR}/DATA/$1_$DATE.log ] ; then
echo "$1 log is dump ... now compress ..."
rm -rf $DIR/DATA/$1_$DATE.log.Z
compress $1_$DATE.log
echo "database log compress OK...."
else
echo "$1 log isn't dump "
echo "datatbase log not failed...."
fi
}

# remote copy
rscp()
{
scp ${DIR}/DATA/$3
}

rftp()
{
ftp -n<open $1
user $2 $3
bin
prom off
lcd ${DIR}/DATA
cd ${RBAK_HOME}/DATA
mput $4
close
bye
EOF
}


# loop execu export
#cd $DIR/DATA
while read LINE
do
dumpdb $LINE
zip $LINE
done

#IFS=":"
#while read username password
# do
# if [ "$password" == "" ] ; then
# #echo "UserName $username"
# continue
# else
# #echo "UserName $username" "PassWord $password"
# dumpdb ${username} ${password} ecom
# #echo ${username} ${password} ecom
# #zip $username
# fi
# done < $BAK_CONF/dbuser.list
#IFS=$SAVEDIFS

# copy datafile to backup host
rscp 192.168.0.140 oracle "*_${DATE}.*.Z"

rftp 192.168.1.236 oracle oracle123 "*$DATE.*"


================dbuser.list
username:password

[@more@]

#!/usr/bin/sh
# ding yi huan jing bian liang
DATE=`date +%w`
DIR="/export/home/ORA_BAK"
BAK_CONF="${DIR}/bin"
RBAK_HOME="/manager/oracle/ORA_BAK"

export DATE DIR BAK_HOME

# export oracle dump file
dumpdb()
{
cd $DIR/DATA
$ORACLE_HOME/bin/exp file=$1_$DATE.dmp log=$1_$DATE.log compress=n
}

zip()
{
cd $DIR/DATA
if [ -f ${DIR}/DATA/$1_$DATE.dmp ] ; then
echo "$1 dmp is dump ... now compress ..."
rm -rf $DIR/DATA/$1_$DATE.dmp.Z
compress $1_$DATE.dmp
echo "database dmp compress OK...."
else
echo "$1 dmp isn't dump "
echo "datatbase dump not failed...."
fi
if [ -f ${DIR}/DATA/$1_$DATE.log ] ; then
echo "$1 log is dump ... now compress ..."
rm -rf $DIR/DATA/$1_$DATE.log.Z
compress $1_$DATE.log
echo "database log compress OK...."
else
echo "$1 log isn't dump "
echo "datatbase log not failed...."
fi
}

# remote copy
rscp()
{
scp ${DIR}/DATA/$3
}

rftp()
{
ftp -n<open $1
user $2 $3
bin
prom off
lcd ${DIR}/DATA
cd ${RBAK_HOME}/DATA
mput $4
close
bye
EOF
}


# loop execu export
#cd $DIR/DATA
while read LINE
do
dumpdb $LINE
zip $LINE
done

#IFS=":"
#while read username password
# do
# if [ "$password" == "" ] ; then
# #echo "UserName $username"
# continue
# else
# #echo "UserName $username" "PassWord $password"
# dumpdb ${username} ${password} ecom
# #echo ${username} ${password} ecom
# #zip $username
# fi
# done < $BAK_CONF/dbuser.list
#IFS=$SAVEDIFS

# copy datafile to backup host
rscp 192.168.0.140 oracle "*_${DATE}.*.Z"

rftp 192.168.1.236 oracle oracle123 "*$DATE.*"


================dbuser.list
username:password

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

相關文章