oracle備份指令碼_user_password

wangzhensheng發表於2007-08-12

#!/bin/sh
#
DATE=`date +%w`
DIR="/export/home/oracle/ORA_BAK"
BAK_CONF="${DIR}/bin"
RBAK_HOME="/backup/orabackup"

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
IFS=":"
while read username password
do
if [ "$password" == "" ] ; then
#echo "UserName $username"
continue
else
#echo "UserName $username" "PassWord $password"
dumpdb ${username} ${password} $ORACLE_SID
#echo ${username} ${password} $ORACLE_SID
zip $username
fi
done < $BAK_CONF/dbuser.list
IFS=$SAVEDIFS


# copy datafile to backup host
#rftp 192.168.1.20 backup backup123 "*_${DATE}.*.Z"

============dbuser.list
user:password

[@more@]

#!/bin/sh
#
DATE=`date +%w`
DIR="/export/home/oracle/ORA_BAK"
BAK_CONF="${DIR}/bin"
RBAK_HOME="/backup/orabackup"

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
IFS=":"
while read username password
do
if [ "$password" == "" ] ; then
#echo "UserName $username"
continue
else
#echo "UserName $username" "PassWord $password"
dumpdb ${username} ${password} $ORACLE_SID
#echo ${username} ${password} $ORACLE_SID
zip $username
fi
done < $BAK_CONF/dbuser.list
IFS=$SAVEDIFS


# copy datafile to backup host
#rftp 192.168.1.20 backup backup123 "*_${DATE}.*.Z"

============dbuser.list
user:password

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

相關文章