#!/bin/bash
#set -x
. /home/oracle/.bash_profile
export L_PRODUCT_PWD=XXX
#set -x
. /home/oracle/.bash_profile
export L_PRODUCT_PWD=XXX
export L_FILE_DATE=`date +%Y%m%d`
export L_FILE_DATE_D=`date -d -2days +%Y%m%d`
export L_OLD_DATE=`date -d -2days +%Y%m%d`
#**********************************************************************#
# #
# define work directory #
# L_WORK_DIR_ #
# |_bin #
# |_operlog #
# #
#**********************************************************************#
L_DIR_NAME=`dirname $0`
cd ${L_DIR_NAME}
cd ..
export L_WORK_DIR=$PWD
export L_BIN_DIR=${L_WORK_DIR}/bin
export L_LOG_DIR=${L_WORK_DIR}/operlog
export L_FILE_DATE_D=`date -d -2days +%Y%m%d`
export L_OLD_DATE=`date -d -2days +%Y%m%d`
#**********************************************************************#
# #
# define work directory #
# L_WORK_DIR_ #
# |_bin #
# |_operlog #
# #
#**********************************************************************#
L_DIR_NAME=`dirname $0`
cd ${L_DIR_NAME}
cd ..
export L_WORK_DIR=$PWD
export L_BIN_DIR=${L_WORK_DIR}/bin
export L_LOG_DIR=${L_WORK_DIR}/operlog
#************************************************************************#
# #
# drop user product and create the user product #
# #
#************************************************************************#
l_scn=`sqlplus '/as sysdba' < set feedback off
set pagesize 0
drop user product cascade;
create user product identified by $L_PRODUCT_PWD default tablespace product;
grant create view to product;
grant connect,resource to product;
GRANT READ,write ON DIRECTORY PRODUCT TO product;
exit;
!
`
# #
# drop user product and create the user product #
# #
#************************************************************************#
l_scn=`sqlplus '/as sysdba' < set feedback off
set pagesize 0
drop user product cascade;
create user product identified by $L_PRODUCT_PWD default tablespace product;
grant create view to product;
grant connect,resource to product;
GRANT READ,write ON DIRECTORY PRODUCT TO product;
exit;
!
`
#************************************************************************#
# #
# Begin import SMSG_LOGS's METADATA_ONLY #
# #
#************************************************************************#
echo "###########################################################"
echo "Begin import smsg_logs's metadata `date +%Y-%m-%d` `date +%T`"
rm /backup1/expdata_backup/dailybackup01.dmp.gz_$L_OLD_DATE
rm /backup1/expdata_backup/dailybackup02.dmp.gz_$L_OLD_DATE
rm /backup1/expdata_backup/dailybackup03.dmp.gz_$L_OLD_DATE
rm /backup1/expdata_backup/dailybackup04.dmp.gz_$L_OLD_DATE
rm /backup1/expdata_backup/dailybackup05.dmp.gz_$L_OLD_DATE
rm /backup1/expdata_backup/dailybackup06.dmp.gz_$L_OLD_DATE
rm /backup1/expdata_backup/dailybackup07.dmp.gz_$L_OLD_DATE
# #
# Begin import SMSG_LOGS's METADATA_ONLY #
# #
#************************************************************************#
echo "###########################################################"
echo "Begin import smsg_logs's metadata `date +%Y-%m-%d` `date +%T`"
rm /backup1/expdata_backup/dailybackup01.dmp.gz_$L_OLD_DATE
rm /backup1/expdata_backup/dailybackup02.dmp.gz_$L_OLD_DATE
rm /backup1/expdata_backup/dailybackup03.dmp.gz_$L_OLD_DATE
rm /backup1/expdata_backup/dailybackup04.dmp.gz_$L_OLD_DATE
rm /backup1/expdata_backup/dailybackup05.dmp.gz_$L_OLD_DATE
rm /backup1/expdata_backup/dailybackup06.dmp.gz_$L_OLD_DATE
rm /backup1/expdata_backup/dailybackup07.dmp.gz_$L_OLD_DATE
impdp product/$L_PRODUCT_PWD parfile=${L_BIN_DIR}/imp_smsg_logs_tab.par
cat /backup/expdata/imp_smsg_logs_tab.log>> ${L_LOG_DIR}/dailyimp.log
mv /backup/expdata/imp_smsg_logs_tab.log ${L_LOG_DIR}/imp_smsg_logs_tab.log_$L_FILE_DATE
echo "Finish import smsg_logs's metadata `date +%Y-%m-%d` `date +%T`"
echo "###########################################################"
#************************************************************************#
# #
# Begin import product's object except user_stat_info and attrs #
# #
#************************************************************************#
echo "###########################################################"
echo "Begin import schema product `date +%Y-%m-%d` `date +%T`"
impdp product/$L_PRODUCT_PWD parfile=${L_BIN_DIR}/imp_all_tab.par
cat /backup/expdata/imp_all_tab.log>> ${L_LOG_DIR}/dailyimp.log
mv /backup/expdata/imp_all_tab.log ${L_LOG_DIR}/imp_all_tab.log_$L_FILE_DATE
echo "Finish import schema product `date +%Y-%m-%d` `date +%T`"
echo "###########################################################"
# #
# Begin import product's object except user_stat_info and attrs #
# #
#************************************************************************#
echo "###########################################################"
echo "Begin import schema product `date +%Y-%m-%d` `date +%T`"
impdp product/$L_PRODUCT_PWD parfile=${L_BIN_DIR}/imp_all_tab.par
cat /backup/expdata/imp_all_tab.log>> ${L_LOG_DIR}/dailyimp.log
mv /backup/expdata/imp_all_tab.log ${L_LOG_DIR}/imp_all_tab.log_$L_FILE_DATE
echo "Finish import schema product `date +%Y-%m-%d` `date +%T`"
echo "###########################################################"
#************************************************************************#
# #
# Begin import ATTRS #
# #
#************************************************************************#
echo "###########################################################"
echo "Begin import ATTRS `date +%Y-%m-%d` `date +%T`"
impdp product/$L_PRODUCT_PWD parfile=${L_BIN_DIR}/imp_attrs_tab.par
cat /backup/expdata/imp_attrs_tab.log>> ${L_LOG_DIR}/dailyimp.log
mv /backup/expdata/imp_attrs_tab.log ${L_LOG_DIR}/imp_attrs_tab.log_$L_FILE_DATE
echo "Finish import ATTRS `date +%Y-%m-%d` `date +%T`"
echo "###########################################################"
# #
# Begin import ATTRS #
# #
#************************************************************************#
echo "###########################################################"
echo "Begin import ATTRS `date +%Y-%m-%d` `date +%T`"
impdp product/$L_PRODUCT_PWD parfile=${L_BIN_DIR}/imp_attrs_tab.par
cat /backup/expdata/imp_attrs_tab.log>> ${L_LOG_DIR}/dailyimp.log
mv /backup/expdata/imp_attrs_tab.log ${L_LOG_DIR}/imp_attrs_tab.log_$L_FILE_DATE
echo "Finish import ATTRS `date +%Y-%m-%d` `date +%T`"
echo "###########################################################"
#************************************************************************#
# #
# Begin import USER_STAT_INFO #
# #
#************************************************************************#
echo "###########################################################"
echo "Begin import USER_STAT_INFO `date +%Y-%m-%d` `date +%T`"
impdp product/$L_PRODUCT_PWD parfile=${L_BIN_DIR}/imp_user_stat_info_tab.par
cat /backup/expdata/imp_user_stat_info_tab.log>> ${L_LOG_DIR}/dailyimp.log
mv /backup/expdata/imp_user_stat_info_tab.log ${L_LOG_DIR}/imp_user_stat_info_tab.log_$L_FILE_DATE
echo "Finish import USER_STAT_INFO `date +%Y-%m-%d` `date +%T`"
echo "###########################################################"
# #
# Begin import USER_STAT_INFO #
# #
#************************************************************************#
echo "###########################################################"
echo "Begin import USER_STAT_INFO `date +%Y-%m-%d` `date +%T`"
impdp product/$L_PRODUCT_PWD parfile=${L_BIN_DIR}/imp_user_stat_info_tab.par
cat /backup/expdata/imp_user_stat_info_tab.log>> ${L_LOG_DIR}/dailyimp.log
mv /backup/expdata/imp_user_stat_info_tab.log ${L_LOG_DIR}/imp_user_stat_info_tab.log_$L_FILE_DATE
echo "Finish import USER_STAT_INFO `date +%Y-%m-%d` `date +%T`"
echo "###########################################################"
#************************************************************************#
# #
# Begin gzip and mv dmp files to /backup1/expdata_backup #
# #
#************************************************************************#
echo "###########################################################"
echo "Begin gzip and mv dmp files to /backup1/expdata_backup `date +%Y-%m-%d` `date +%T`"
gzip /backup/expdata/dailybackup01.dmp
gzip /backup/expdata/dailybackup02.dmp
gzip /backup/expdata/dailybackup03.dmp
gzip /backup/expdata/dailybackup04.dmp
gzip /backup/expdata/dailybackup05.dmp
gzip /backup/expdata/dailybackup06.dmp
gzip /backup/expdata/dailybackup07.dmp
# #
# Begin gzip and mv dmp files to /backup1/expdata_backup #
# #
#************************************************************************#
echo "###########################################################"
echo "Begin gzip and mv dmp files to /backup1/expdata_backup `date +%Y-%m-%d` `date +%T`"
gzip /backup/expdata/dailybackup01.dmp
gzip /backup/expdata/dailybackup02.dmp
gzip /backup/expdata/dailybackup03.dmp
gzip /backup/expdata/dailybackup04.dmp
gzip /backup/expdata/dailybackup05.dmp
gzip /backup/expdata/dailybackup06.dmp
gzip /backup/expdata/dailybackup07.dmp
mv /backup/expdata/dailybackup01.dmp.gz /backup1/expdata_backup/dailybackup01.dmp.gz_$L_FILE_DATE
mv /backup/expdata/dailybackup02.dmp.gz /backup1/expdata_backup/dailybackup02.dmp.gz_$L_FILE_DATE
mv /backup/expdata/dailybackup03.dmp.gz /backup1/expdata_backup/dailybackup03.dmp.gz_$L_FILE_DATE
mv /backup/expdata/dailybackup04.dmp.gz /backup1/expdata_backup/dailybackup04.dmp.gz_$L_FILE_DATE
mv /backup/expdata/dailybackup05.dmp.gz /backup1/expdata_backup/dailybackup05.dmp.gz_$L_FILE_DATE
mv /backup/expdata/dailybackup06.dmp.gz /backup1/expdata_backup/dailybackup06.dmp.gz_$L_FILE_DATE
mv /backup/expdata/dailybackup07.dmp.gz /backup1/expdata_backup/dailybackup07.dmp.gz_$L_FILE_DATE
mv /backup/expdata/dailybackup02.dmp.gz /backup1/expdata_backup/dailybackup02.dmp.gz_$L_FILE_DATE
mv /backup/expdata/dailybackup03.dmp.gz /backup1/expdata_backup/dailybackup03.dmp.gz_$L_FILE_DATE
mv /backup/expdata/dailybackup04.dmp.gz /backup1/expdata_backup/dailybackup04.dmp.gz_$L_FILE_DATE
mv /backup/expdata/dailybackup05.dmp.gz /backup1/expdata_backup/dailybackup05.dmp.gz_$L_FILE_DATE
mv /backup/expdata/dailybackup06.dmp.gz /backup1/expdata_backup/dailybackup06.dmp.gz_$L_FILE_DATE
mv /backup/expdata/dailybackup07.dmp.gz /backup1/expdata_backup/dailybackup07.dmp.gz_$L_FILE_DATE
echo "Finish gzip and mv dmp files to /backup1/expdata_backup `date +%Y-%m-%d` `date +%T`"
echo "Finish the importing. time is `date +%Y-%m-%d` `date +%T`"
echo "###########################################################"
echo "Finish the importing. time is `date +%Y-%m-%d` `date +%T`"
echo "###########################################################"
cat ${L_LOG_DIR}/dailybackup.log >> ${L_LOG_DIR}/dailyimp.log
cat /home/oracle/admin/dailyimp/operlog/dailyimp.log|mail -s "GUANGZHOU--Exporting and importing user product to backup database `date +%Y-%m-%d` `date +%T`"
oracle_ops@7500.com.cn
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27042095/viewspace-754617/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/27042095/viewspace-754617/