pt-archive

#archiver命令的安装路径

BASE_PATH=/usr/local/bin

定义 pt-archiver 参数变量

SOURCE_HOST=""

SOURCE_PORT=""

SOURCE_USER=""

SOURCE_PASSWORD=""

SOURCE_DATABASE=""

SOURCE_CHARSET="utf8"

SOURCE_PATH=""

SOURCE_LOG_PATH=""

#接受外部参数

START_DATE=$1

END_DATE=$2

获取当前系统时间

CURRENT_TIME= ( d a t e + " C U R R E N T D A T E = (date +"%Y-%m-%d %H:%M:%S") CURRENT_DATE= (date+"CURRENTDATE=(date +"%Y-%m-%d")

定义日志文件路径 "数据库名+日期"作为日志文件名

LOG_FILE= S O U R C E L O G P A T H " a r c h i v e r − SOURCE_LOG_PATH"archiver- SOURCELOGPATH"archiver−SOURCE_DATABASE-$(date +"%Y-%m-%d_%H-%M-%S").log"

每处理 $PROGRESS 行数据时输出进度报告

PROGRESS=10000

每个事务中处理的最大行数,用于控制事务的大小

TXN_SIZE=1000

每个查询中返回的记录数的限制

LIMIT=1000

归档间隔时间

INTERVAL_DAY=365

if [ ! -d S O U R C E P A T H SOURCE_PATH SOURCEPATHCURRENT_DATE ];then

mkdir S O U R C E P A T H SOURCE_PATH SOURCEPATHCURRENT_DATE

else

echo "文件夹已经存在"

fi

echo "开始归档" >> L O G F I L E e c h o " LOG_FILE echo " LOGFILEecho"LOG_FILE" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

开始备份 master表

echo "by_operation_master 开始备份: $START_DATE - END_DATE " \>\> L O G F I L E C O M M O N M A S T E R = " LOG_FILE COMMON_MASTER=" LOGFILECOMMONMASTER="BASE_PATH/pt-archiver --source h= S O U R C E H O S T , P = SOURCE_HOST,P= SOURCEHOST,P=SOURCE_PORT,u= S O U R C E U S E R , p = SOURCE_USER,p= SOURCEUSER,p=SOURCE_PASSWORD,D= S O U R C E D A T A B A S E , t = b y o p e r a t i o n m a s t e r − − w h e r e s ¨ c h e d u l e d d a t e t i m e b e t w e e n ′ SOURCE_DATABASE,t=by_operation_master --where \\"scheduled_date_time between ' SOURCEDATABASE,t=byoperationmaster−−wheres¨cheduleddatetimebetween′START_DATE' and 'KaTeX parse error: Expected group as argument to '\\"' at position 12: END_DATE'\\" ̲--charset=SOURCE_CHARSET --no-delete --statistics --progress= P R O G R E S S − − l i m i t = PROGRESS --limit= PROGRESS−−limit=LIMIT --txn-size=KaTeX parse error: Expected group as argument to '\\"' at end of input: ...SIZE --file=\\"SOURCE_PATH C U R R E N T D A T E / CURRENT_DATE/ CURRENTDATE/START_DATE-END_DATE-by_operation_master.txt""

echo "归档命令: $COMMON_MASTER" >> $LOG_FILE

echo -e "\n" >> $LOG_FILE

echo "归档执行中,请稍等..." >> $LOG_FILE

执行归档命令

eval $COMMON_MASTER >> $LOG_FILE

echo "表名: by_operation_master $START_DATE - $END_DATE 归档完成" >> $LOG_FILE

echo -e "\n\n\n" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

开始备份 by_operation_patient

echo "by_operation_patient 开始备份: $START_DATE - END_DATE " \>\> L O G F I L E C O M M O N M A S T E R = " LOG_FILE COMMON_MASTER=" LOGFILECOMMONMASTER="BASE_PATH/pt-archiver --source h= S O U R C E H O S T , P = SOURCE_HOST,P= SOURCEHOST,P=SOURCE_PORT,u= S O U R C E U S E R , p = SOURCE_USER,p= SOURCEUSER,p=SOURCE_PASSWORD,D= S O U R C E D A T A B A S E , t = b y o p e r a t i o n p a t i e n t − − w h e r e o ¨ p e r a t i o n i d i n ( s e l e c t o p e r a t i o n i d f r o m b y o p e r a t i o n m a s t e r w h e r e s c h e d u l e d d a t e t i m e b e t w e e n ′ SOURCE_DATABASE,t=by_operation_patient --where \\"operation_id in (select operation_id from by_operation_master where scheduled_date_time between ' SOURCEDATABASE,t=byoperationpatient−−whereo¨perationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetween′START_DATE' and 'KaTeX parse error: Expected group as argument to '\\"' at position 13: END_DATE')\\" ̲--charset=SOURCE_CHARSET --no-delete --statistics --progress= P R O G R E S S − − l i m i t = PROGRESS --limit= PROGRESS−−limit=LIMIT --txn-size=KaTeX parse error: Expected group as argument to '\\"' at end of input: ...SIZE --file=\\"SOURCE_PATH C U R R E N T D A T E / CURRENT_DATE/ CURRENTDATE/START_DATE-END_DATE-by_operation_patient.txt""

echo "归档命令: $COMMON_MASTER" >> $LOG_FILE

echo -e "\n" >> $LOG_FILE

echo "归档执行中,请稍等..." >> $LOG_FILE

执行归档命令

eval $COMMON_MASTER >> $LOG_FILE

echo "表名: by_operation_patient $START_DATE - $END_DATE 归档完成" >> $LOG_FILE

echo -e "\n\n\n" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

开始备份 by_operation_staff

echo "by_operation_staff 开始备份: $START_DATE - END_DATE " \>\> L O G F I L E C O M M O N M A S T E R = " LOG_FILE COMMON_MASTER=" LOGFILECOMMONMASTER="BASE_PATH/pt-archiver --source h= S O U R C E H O S T , P = SOURCE_HOST,P= SOURCEHOST,P=SOURCE_PORT,u= S O U R C E U S E R , p = SOURCE_USER,p= SOURCEUSER,p=SOURCE_PASSWORD,D= S O U R C E D A T A B A S E , t = b y o p e r a t i o n s t a f f − − w h e r e o ¨ p e r a t i o n i d i n ( s e l e c t o p e r a t i o n i d f r o m b y o p e r a t i o n m a s t e r w h e r e s c h e d u l e d d a t e t i m e b e t w e e n ′ SOURCE_DATABASE,t=by_operation_staff --where \\"operation_id in (select operation_id from by_operation_master where scheduled_date_time between ' SOURCEDATABASE,t=byoperationstaff−−whereo¨perationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetween′START_DATE' and 'KaTeX parse error: Expected group as argument to '\\"' at position 13: END_DATE')\\" ̲--charset=SOURCE_CHARSET --no-delete --statistics --progress= P R O G R E S S − − l i m i t = PROGRESS --limit= PROGRESS−−limit=LIMIT --txn-size=KaTeX parse error: Expected group as argument to '\\"' at end of input: ...SIZE --file=\\"SOURCE_PATH C U R R E N T D A T E / CURRENT_DATE/ CURRENTDATE/START_DATE-END_DATE-by_operation_staff.txt""

echo "归档命令: $COMMON_MASTER" >> $LOG_FILE

echo -e "\n" >> $LOG_FILE

echo "归档执行中,请稍等..." >> $LOG_FILE

执行归档命令

eval $COMMON_MASTER >> $LOG_FILE

echo "表名: by_operation_staff $START_DATE - $END_DATE 归档完成" >> $LOG_FILE

echo -e "\n\n\n" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

开始备份 by_operation_name

echo "by_operation_name 开始备份: $START_DATE - END_DATE " \>\> L O G F I L E C O M M O N M A S T E R = " LOG_FILE COMMON_MASTER=" LOGFILECOMMONMASTER="BASE_PATH/pt-archiver --source h= S O U R C E H O S T , P = SOURCE_HOST,P= SOURCEHOST,P=SOURCE_PORT,u= S O U R C E U S E R , p = SOURCE_USER,p= SOURCEUSER,p=SOURCE_PASSWORD,D= S O U R C E D A T A B A S E , t = b y o p e r a t i o n n a m e − − w h e r e o ¨ p e r a t i o n i d i n ( s e l e c t o p e r a t i o n i d f r o m b y o p e r a t i o n m a s t e r w h e r e s c h e d u l e d d a t e t i m e b e t w e e n ′ SOURCE_DATABASE,t=by_operation_name --where \\"operation_id in (select operation_id from by_operation_master where scheduled_date_time between ' SOURCEDATABASE,t=byoperationname−−whereo¨perationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetween′START_DATE' and 'KaTeX parse error: Expected group as argument to '\\"' at position 13: END_DATE')\\" ̲--charset=SOURCE_CHARSET --no-delete --statistics --progress= P R O G R E S S − − l i m i t = PROGRESS --limit= PROGRESS−−limit=LIMIT --txn-size=KaTeX parse error: Expected group as argument to '\\"' at end of input: ...SIZE --file=\\"SOURCE_PATH C U R R E N T D A T E / CURRENT_DATE/ CURRENTDATE/START_DATE-END_DATE-by_operation_name.txt""

echo "归档命令: $COMMON_MASTER" >> $LOG_FILE

echo -e "\n" >> $LOG_FILE

echo "归档执行中,请稍等..." >> $LOG_FILE

执行归档命令

eval $COMMON_MASTER >> $LOG_FILE

echo "表名: by_operation_name $START_DATE - $END_DATE 归档完成" >> $LOG_FILE

echo -e "\n\n\n" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

开始备份 by_operation_nursing_event

echo "by_operation_nursing_event 开始备份: $START_DATE - END_DATE " \>\> L O G F I L E C O M M O N M A S T E R = " LOG_FILE COMMON_MASTER=" LOGFILECOMMONMASTER="BASE_PATH/pt-archiver --source h= S O U R C E H O S T , P = SOURCE_HOST,P= SOURCEHOST,P=SOURCE_PORT,u= S O U R C E U S E R , p = SOURCE_USER,p= SOURCEUSER,p=SOURCE_PASSWORD,D= S O U R C E D A T A B A S E , t = b y o p e r a t i o n n u r s i n g e v e n t − − w h e r e o ¨ p e r a t i o n i d i n ( s e l e c t o p e r a t i o n i d f r o m b y o p e r a t i o n m a s t e r w h e r e s c h e d u l e d d a t e t i m e b e t w e e n ′ SOURCE_DATABASE,t=by_operation_nursing_event --where \\"operation_id in (select operation_id from by_operation_master where scheduled_date_time between ' SOURCEDATABASE,t=byoperationnursingevent−−whereo¨perationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetween′START_DATE' and 'KaTeX parse error: Expected group as argument to '\\"' at position 13: END_DATE')\\" ̲--charset=SOURCE_CHARSET --no-delete --statistics --progress= P R O G R E S S − − l i m i t = PROGRESS --limit= PROGRESS−−limit=LIMIT --txn-size=KaTeX parse error: Expected group as argument to '\\"' at end of input: ...SIZE --file=\\"SOURCE_PATH C U R R E N T D A T E / CURRENT_DATE/ CURRENTDATE/START_DATE-END_DATE-by_operation_nursing_event.txt""

echo "归档命令: $COMMON_MASTER" >> $LOG_FILE

echo -e "\n" >> $LOG_FILE

echo "归档执行中,请稍等..." >> $LOG_FILE

执行归档命令

eval $COMMON_MASTER >> $LOG_FILE

echo "表名: by_operation_nursing_event $START_DATE - $END_DATE 归档完成" >> $LOG_FILE

echo -e "\n\n\n" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

开始备份 by_record

echo "by_record 开始备份: $START_DATE - END_DATE " \>\> L O G F I L E C O M M O N M A S T E R = " LOG_FILE COMMON_MASTER=" LOGFILECOMMONMASTER="BASE_PATH/pt-archiver --source h= S O U R C E H O S T , P = SOURCE_HOST,P= SOURCEHOST,P=SOURCE_PORT,u= S O U R C E U S E R , p = SOURCE_USER,p= SOURCEUSER,p=SOURCE_PASSWORD,D= S O U R C E D A T A B A S E , t = b y r e c o r d − − w h e r e o ¨ p e r a t i o n i d i n ( s e l e c t o p e r a t i o n i d f r o m b y o p e r a t i o n m a s t e r w h e r e s c h e d u l e d d a t e t i m e b e t w e e n ′ SOURCE_DATABASE,t=by_record --where \\"operation_id in (select operation_id from by_operation_master where scheduled_date_time between ' SOURCEDATABASE,t=byrecord−−whereo¨perationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetween′START_DATE' and 'KaTeX parse error: Expected group as argument to '\\"' at position 13: END_DATE')\\" ̲--charset=SOURCE_CHARSET --no-delete --statistics --progress= P R O G R E S S − − l i m i t = PROGRESS --limit= PROGRESS−−limit=LIMIT --txn-size=KaTeX parse error: Expected group as argument to '\\"' at end of input: ...SIZE --file=\\"SOURCE_PATH C U R R E N T D A T E / CURRENT_DATE/ CURRENTDATE/START_DATE-END_DATE-by_record.txt""

echo "归档命令: $COMMON_MASTER" >> $LOG_FILE

echo -e "\n" >> $LOG_FILE

echo "归档执行中,请稍等..." >> $LOG_FILE

执行归档命令

eval $COMMON_MASTER >> $LOG_FILE

echo "表名: by_record $START_DATE - $END_DATE 归档完成" >> $LOG_FILE

echo -e "\n\n\n" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

开始备份 by_record_detail

echo "by_record_detail 开始备份: $START_DATE - END_DATE " \>\> L O G F I L E C O M M O N M A S T E R = " LOG_FILE COMMON_MASTER=" LOGFILECOMMONMASTER="BASE_PATH/pt-archiver --source h= S O U R C E H O S T , P = SOURCE_HOST,P= SOURCEHOST,P=SOURCE_PORT,u= S O U R C E U S E R , p = SOURCE_USER,p= SOURCEUSER,p=SOURCE_PASSWORD,D= S O U R C E D A T A B A S E , t = b y r e c o r d d e t a i l − − w h e r e r ¨ e c o r d i d i n ( s e l e c t r e c o r d i d f r o m b y r e c o r d w h e r e o p e r a t i o n i d i n ( s e l e c t o p e r a t i o n i d f r o m b y o p e r a t i o n m a s t e r w h e r e s c h e d u l e d d a t e t i m e b e t w e e n ′ SOURCE_DATABASE,t=by_record_detail --where \\"record_id in (select record_id from by_record where operation_id in (select operation_id from by_operation_master where scheduled_date_time between ' SOURCEDATABASE,t=byrecorddetail−−wherer¨ecordidin(selectrecordidfrombyrecordwhereoperationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetween′START_DATE' and 'KaTeX parse error: Expected group as argument to '\\"' at position 14: END_DATE'))\\" ̲--charset=SOURCE_CHARSET --no-delete --statistics --progress= P R O G R E S S − − l i m i t = PROGRESS --limit= PROGRESS−−limit=LIMIT --txn-size=KaTeX parse error: Expected group as argument to '\\"' at end of input: ...SIZE --file=\\"SOURCE_PATH C U R R E N T D A T E / CURRENT_DATE/ CURRENTDATE/START_DATE-END_DATE-by_record_detail.txt""

echo "归档命令: $COMMON_MASTER" >> $LOG_FILE

echo -e "\n" >> $LOG_FILE

echo "归档执行中,请稍等..." >> $LOG_FILE

执行归档命令

eval $COMMON_MASTER >> $LOG_FILE

echo "表名: by_record_detail $START_DATE - $END_DATE 归档完成" >> $LOG_FILE

echo -e "\n\n\n" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

开始备份 by_surgical_incision

echo "by_surgical_incision 开始备份: $START_DATE - END_DATE " \>\> L O G F I L E C O M M O N M A S T E R = " LOG_FILE COMMON_MASTER=" LOGFILECOMMONMASTER="BASE_PATH/pt-archiver --source h= S O U R C E H O S T , P = SOURCE_HOST,P= SOURCEHOST,P=SOURCE_PORT,u= S O U R C E U S E R , p = SOURCE_USER,p= SOURCEUSER,p=SOURCE_PASSWORD,D= S O U R C E D A T A B A S E , t = b y s u r g i c a l i n c i s i o n − − w h e r e o ¨ p e r a t i o n i d i n ( s e l e c t o p e r a t i o n i d f r o m b y o p e r a t i o n m a s t e r w h e r e s c h e d u l e d d a t e t i m e b e t w e e n ′ SOURCE_DATABASE,t=by_surgical_incision --where \\"operation_id in (select operation_id from by_operation_master where scheduled_date_time between ' SOURCEDATABASE,t=bysurgicalincision−−whereo¨perationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetween′START_DATE' and 'KaTeX parse error: Expected group as argument to '\\"' at position 13: END_DATE')\\" ̲--charset=SOURCE_CHARSET --no-delete --statistics --progress= P R O G R E S S − − l i m i t = PROGRESS --limit= PROGRESS−−limit=LIMIT --txn-size=KaTeX parse error: Expected group as argument to '\\"' at end of input: ...SIZE --file=\\"SOURCE_PATH C U R R E N T D A T E / CURRENT_DATE/ CURRENTDATE/START_DATE-END_DATE-by_surgical_incision.txt""

echo "归档命令: $COMMON_MASTER" >> $LOG_FILE

echo -e "\n" >> $LOG_FILE

echo "归档执行中,请稍等..." >> $LOG_FILE

执行归档命令

eval $COMMON_MASTER >> $LOG_FILE

echo "表名: by_surgical_incision $START_DATE - $END_DATE 归档完成" >> $LOG_FILE

echo -e "\n\n\n" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

开始备份 by_incision_instrument

echo "by_incision_instrument 开始备份: $START_DATE - END_DATE " \>\> L O G F I L E C O M M O N M A S T E R = " LOG_FILE COMMON_MASTER=" LOGFILECOMMONMASTER="BASE_PATH/pt-archiver --source h= S O U R C E H O S T , P = SOURCE_HOST,P= SOURCEHOST,P=SOURCE_PORT,u= S O U R C E U S E R , p = SOURCE_USER,p= SOURCEUSER,p=SOURCE_PASSWORD,D= S O U R C E D A T A B A S E , t = b y i n c i s i o n i n s t r u m e n t − − w h e r e i ¨ n c i s i o n i d i n ( s e l e c t i n c i s i o n i d f r o m b y s u r g i c a l i n c i s i o n w h e r e o p e r a t i o n i d i n ( s e l e c t o p e r a t i o n i d f r o m b y o p e r a t i o n m a s t e r w h e r e s c h e d u l e d d a t e t i m e b e t w e e n ′ SOURCE_DATABASE,t=by_incision_instrument --where \\"incision_id in (select incision_id from by_surgical_incision where operation_id in (select operation_id from by_operation_master where scheduled_date_time between ' SOURCEDATABASE,t=byincisioninstrument−−wherei¨ncisionidin(selectincisionidfrombysurgicalincisionwhereoperationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetween′START_DATE' and 'KaTeX parse error: Expected group as argument to '\\"' at position 14: END_DATE'))\\" ̲--charset=SOURCE_CHARSET --no-delete --statistics --progress= P R O G R E S S − − l i m i t = PROGRESS --limit= PROGRESS−−limit=LIMIT --txn-size=KaTeX parse error: Expected group as argument to '\\"' at end of input: ...SIZE --file=\\"SOURCE_PATH C U R R E N T D A T E / CURRENT_DATE/ CURRENTDATE/START_DATE-END_DATE-by_incision_instrument.txt""

echo "归档命令: $COMMON_MASTER" >> $LOG_FILE

echo -e "\n" >> $LOG_FILE

echo "归档执行中,请稍等..." >> $LOG_FILE

执行归档命令

eval $COMMON_MASTER >> $LOG_FILE

echo "表名: by_incision_instrument $START_DATE - $END_DATE 归档完成" >> $LOG_FILE

echo -e "\n\n\n" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

开始备份 by_incision_check_record

echo "by_incision_check_record 开始备份: $START_DATE - END_DATE " \>\> L O G F I L E C O M M O N M A S T E R = " LOG_FILE COMMON_MASTER=" LOGFILECOMMONMASTER="BASE_PATH/pt-archiver --source h= S O U R C E H O S T , P = SOURCE_HOST,P= SOURCEHOST,P=SOURCE_PORT,u= S O U R C E U S E R , p = SOURCE_USER,p= SOURCEUSER,p=SOURCE_PASSWORD,D= S O U R C E D A T A B A S E , t = b y i n c i s i o n c h e c k r e c o r d − − w h e r e i ¨ n c i s i o n i d i n ( s e l e c t i n c i s i o n i d f r o m b y s u r g i c a l i n c i s i o n w h e r e o p e r a t i o n i d i n ( s e l e c t o p e r a t i o n i d f r o m b y o p e r a t i o n m a s t e r w h e r e s c h e d u l e d d a t e t i m e b e t w e e n ′ SOURCE_DATABASE,t=by_incision_check_record --where \\"incision_id in (select incision_id from by_surgical_incision where operation_id in (select operation_id from by_operation_master where scheduled_date_time between ' SOURCEDATABASE,t=byincisioncheckrecord−−wherei¨ncisionidin(selectincisionidfrombysurgicalincisionwhereoperationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetween′START_DATE' and 'KaTeX parse error: Expected group as argument to '\\"' at position 14: END_DATE'))\\" ̲--charset=SOURCE_CHARSET --no-delete --statistics --progress= P R O G R E S S − − l i m i t = PROGRESS --limit= PROGRESS−−limit=LIMIT --txn-size=KaTeX parse error: Expected group as argument to '\\"' at end of input: ...SIZE --file=\\"SOURCE_PATH C U R R E N T D A T E / CURRENT_DATE/ CURRENTDATE/START_DATE-END_DATE-by_incision_check_record.txt""

echo "归档命令: $COMMON_MASTER" >> $LOG_FILE

echo -e "\n" >> $LOG_FILE

echo "归档执行中,请稍等..." >> $LOG_FILE

执行归档命令

eval $COMMON_MASTER >> $LOG_FILE

echo "表名: by_incision_check_record $START_DATE - $END_DATE 归档完成" >> $LOG_FILE

echo -e "\n\n\n" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

开始备份 by_incision_check_detail

echo "by_incision_check_detail 开始备份: $START_DATE - END_DATE " \>\> L O G F I L E C O M M O N M A S T E R = " LOG_FILE COMMON_MASTER=" LOGFILECOMMONMASTER="BASE_PATH/pt-archiver --source h= S O U R C E H O S T , P = SOURCE_HOST,P= SOURCEHOST,P=SOURCE_PORT,u= S O U R C E U S E R , p = SOURCE_USER,p= SOURCEUSER,p=SOURCE_PASSWORD,D= S O U R C E D A T A B A S E , t = b y i n c i s i o n c h e c k d e t a i l − − w h e r e c ¨ h e c k r e c o r d i d i n ( s e l e c t c h e c k r e c o r d i d f r o m b y i n c i s i o n c h e c k r e c o r d w h e r e i n c i s i o n i d i n ( s e l e c t i n c i s i o n i d f r o m b y s u r g i c a l i n c i s i o n w h e r e o p e r a t i o n i d i n ( s e l e c t o p e r a t i o n i d f r o m b y o p e r a t i o n m a s t e r w h e r e s c h e d u l e d d a t e t i m e b e t w e e n ′ SOURCE_DATABASE,t=by_incision_check_detail --where \\"check_record_id in (select check_record_id from by_incision_check_record where incision_id in (select incision_id from by_surgical_incision where operation_id in (select operation_id from by_operation_master where scheduled_date_time between ' SOURCEDATABASE,t=byincisioncheckdetail−−wherec¨heckrecordidin(selectcheckrecordidfrombyincisioncheckrecordwhereincisionidin(selectincisionidfrombysurgicalincisionwhereoperationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetween′START_DATE' and 'KaTeX parse error: Expected group as argument to '\\"' at position 15: END_DATE')))\\" ̲--charset=SOURCE_CHARSET --no-delete --statistics --progress= P R O G R E S S − − l i m i t = PROGRESS --limit= PROGRESS−−limit=LIMIT --txn-size=KaTeX parse error: Expected group as argument to '\\"' at end of input: ...SIZE --file=\\"SOURCE_PATH C U R R E N T D A T E / CURRENT_DATE/ CURRENTDATE/START_DATE-END_DATE-by_incision_check_detail.txt""

echo "归档命令: $COMMON_MASTER" >> $LOG_FILE

echo -e "\n" >> $LOG_FILE

echo "归档执行中,请稍等..." >> $LOG_FILE

执行归档命令

eval $COMMON_MASTER >> $LOG_FILE

echo "表名: by_incision_check_detail $START_DATE - $END_DATE 归档完成" >> $LOG_FILE

echo -e "\n\n\n" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

开始备份 by_operation_remark

echo "by_operation_remark 开始备份: $START_DATE - END_DATE " \>\> L O G F I L E C O M M O N M A S T E R = " LOG_FILE COMMON_MASTER=" LOGFILECOMMONMASTER="BASE_PATH/pt-archiver --source h= S O U R C E H O S T , P = SOURCE_HOST,P= SOURCEHOST,P=SOURCE_PORT,u= S O U R C E U S E R , p = SOURCE_USER,p= SOURCEUSER,p=SOURCE_PASSWORD,D= S O U R C E D A T A B A S E , t = b y o p e r a t i o n r e m a r k − − w h e r e i ¨ n c i s i o n i d i n ( s e l e c t i n c i s i o n i d f r o m b y s u r g i c a l i n c i s i o n w h e r e o p e r a t i o n i d i n ( s e l e c t o p e r a t i o n i d f r o m b y o p e r a t i o n m a s t e r w h e r e s c h e d u l e d d a t e t i m e b e t w e e n ′ SOURCE_DATABASE,t=by_operation_remark --where \\"incision_id in (select incision_id from by_surgical_incision where operation_id in (select operation_id from by_operation_master where scheduled_date_time between ' SOURCEDATABASE,t=byoperationremark−−wherei¨ncisionidin(selectincisionidfrombysurgicalincisionwhereoperationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetween′START_DATE' and 'KaTeX parse error: Expected group as argument to '\\"' at position 14: END_DATE'))\\" ̲--charset=SOURCE_CHARSET --no-delete --statistics --progress= P R O G R E S S − − l i m i t = PROGRESS --limit= PROGRESS−−limit=LIMIT --txn-size=KaTeX parse error: Expected group as argument to '\\"' at end of input: ...SIZE --file=\\"SOURCE_PATH C U R R E N T D A T E / CURRENT_DATE/ CURRENTDATE/START_DATE-END_DATE-by_operation_remark.txt""

echo "归档命令: $COMMON_MASTER" >> $LOG_FILE

echo -e "\n" >> $LOG_FILE

echo "归档执行中,请稍等..." >> $LOG_FILE

执行归档命令

eval $COMMON_MASTER >> $LOG_FILE

echo "表名: by_operation_remark $START_DATE - $END_DATE 归档完成" >> $LOG_FILE

echo -e "\n\n\n" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

开始备份 by_sign_record

echo "by_sign_record 开始备份: $START_DATE - END_DATE " \>\> L O G F I L E C O M M O N M A S T E R = " LOG_FILE COMMON_MASTER=" LOGFILECOMMONMASTER="BASE_PATH/pt-archiver --source h= S O U R C E H O S T , P = SOURCE_HOST,P= SOURCEHOST,P=SOURCE_PORT,u= S O U R C E U S E R , p = SOURCE_USER,p= SOURCEUSER,p=SOURCE_PASSWORD,D= S O U R C E D A T A B A S E , t = b y s i g n r e c o r d − − w h e r e b ¨ u s i n e s s i d i n ( s e l e c t r e c o r d i d f r o m b y r e c o r d w h e r e o p e r a t i o n i d i n ( s e l e c t o p e r a t i o n i d f r o m b y o p e r a t i o n m a s t e r w h e r e s c h e d u l e d d a t e t i m e b e t w e e n ′ SOURCE_DATABASE,t=by_sign_record --where \\"business_id in (select record_id from by_record where operation_id in (select operation_id from by_operation_master where scheduled_date_time between ' SOURCEDATABASE,t=bysignrecord−−whereb¨usinessidin(selectrecordidfrombyrecordwhereoperationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetween′START_DATE' and ' E N D D A T E ′ ) U N I O N s e l e c t i n c i s i o n i d f r o m b y s u r g i c a l i n c i s i o n w h e r e o p e r a t i o n i d i n ( s e l e c t o p e r a t i o n i d f r o m b y o p e r a t i o n m a s t e r w h e r e s c h e d u l e d d a t e t i m e b e t w e e n ′ END_DATE') UNION select incision_id from by_surgical_incision where operation_id in (select operation_id from by_operation_master where scheduled_date_time between ' ENDDATE′)UNIONselectincisionidfrombysurgicalincisionwhereoperationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetween′START_DATE' and ' E N D D A T E ′ ) U N I O N s e l e c t c h e c k r e c o r d i d f r o m b y i n c i s i o n c h e c k r e c o r d w h e r e i n c i s i o n i d i n ( s e l e c t i n c i s i o n i d f r o m b y s u r g i c a l i n c i s i o n w h e r e o p e r a t i o n i d i n ( s e l e c t o p e r a t i o n i d f r o m b y o p e r a t i o n m a s t e r w h e r e s c h e d u l e d d a t e t i m e b e t w e e n ′ END_DATE') UNION select check_record_id from by_incision_check_record where incision_id in (select incision_id from by_surgical_incision where operation_id in (select operation_id from by_operation_master where scheduled_date_time between ' ENDDATE′)UNIONselectcheckrecordidfrombyincisioncheckrecordwhereincisionidin(selectincisionidfrombysurgicalincisionwhereoperationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetween′START_DATE' and 'KaTeX parse error: Expected group as argument to '\\"' at position 15: END_DATE')))\\" ̲--charset=SOURCE_CHARSET --no-delete --statistics --progress= P R O G R E S S − − l i m i t = PROGRESS --limit= PROGRESS−−limit=LIMIT --txn-size=KaTeX parse error: Expected group as argument to '\\"' at end of input: ...SIZE --file=\\"SOURCE_PATH C U R R E N T D A T E / CURRENT_DATE/ CURRENTDATE/START_DATE-END_DATE-by_sign_record.txt""

echo "归档命令: $COMMON_MASTER" >> $LOG_FILE

echo -e "\n" >> $LOG_FILE

echo "归档执行中,请稍等..." >> $LOG_FILE

执行归档命令

eval $COMMON_MASTER >> $LOG_FILE

echo "表名: by_sign_record $START_DATE - $END_DATE 归档完成" >> $LOG_FILE

echo -e "\n\n\n" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

开始备份 by_ca_sign_record

echo "by_ca_sign_record 开始备份: $START_DATE - END_DATE " \>\> L O G F I L E C O M M O N M A S T E R = " LOG_FILE COMMON_MASTER=" LOGFILECOMMONMASTER="BASE_PATH/pt-archiver --source h= S O U R C E H O S T , P = SOURCE_HOST,P= SOURCEHOST,P=SOURCE_PORT,u= S O U R C E U S E R , p = SOURCE_USER,p= SOURCEUSER,p=SOURCE_PASSWORD,D= S O U R C E D A T A B A S E , t = b y c a s i g n r e c o r d − − w h e r e s ¨ i g n r e c o r d i d i n ( s e l e c t s i g n r e c o r d i d f r o m b y s i g n r e c o r d w h e r e b u s i n e s s i d i n ( s e l e c t r e c o r d i d f r o m b y r e c o r d w h e r e o p e r a t i o n i d i n ( s e l e c t o p e r a t i o n i d f r o m b y o p e r a t i o n m a s t e r w h e r e s c h e d u l e d d a t e t i m e b e t w e e n ′ SOURCE_DATABASE,t=by_ca_sign_record --where \\"sign_record_id in (select sign_record_id from by_sign_record where business_id in (select record_id from by_record where operation_id in (select operation_id from by_operation_master where scheduled_date_time between ' SOURCEDATABASE,t=bycasignrecord−−wheres¨ignrecordidin(selectsignrecordidfrombysignrecordwherebusinessidin(selectrecordidfrombyrecordwhereoperationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetween′START_DATE' and ' E N D D A T E ′ ) U N I O N s e l e c t i n c i s i o n i d f r o m b y s u r g i c a l i n c i s i o n w h e r e o p e r a t i o n i d i n ( s e l e c t o p e r a t i o n i d f r o m b y o p e r a t i o n m a s t e r w h e r e s c h e d u l e d d a t e t i m e b e t w e e n ′ END_DATE') UNION select incision_id from by_surgical_incision where operation_id in (select operation_id from by_operation_master where scheduled_date_time between ' ENDDATE′)UNIONselectincisionidfrombysurgicalincisionwhereoperationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetween′START_DATE' and ' E N D D A T E ′ ) U N I O N s e l e c t c h e c k r e c o r d i d f r o m b y i n c i s i o n c h e c k r e c o r d w h e r e i n c i s i o n i d i n ( s e l e c t i n c i s i o n i d f r o m b y s u r g i c a l i n c i s i o n w h e r e o p e r a t i o n i d i n ( s e l e c t o p e r a t i o n i d f r o m b y o p e r a t i o n m a s t e r w h e r e s c h e d u l e d d a t e t i m e b e t w e e n ′ END_DATE') UNION select check_record_id from by_incision_check_record where incision_id in (select incision_id from by_surgical_incision where operation_id in (select operation_id from by_operation_master where scheduled_date_time between ' ENDDATE′)UNIONselectcheckrecordidfrombyincisioncheckrecordwhereincisionidin(selectincisionidfrombysurgicalincisionwhereoperationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetween′START_DATE' and 'KaTeX parse error: Expected group as argument to '\\"' at position 16: END_DATE'))))\\" ̲--charset=SOURCE_CHARSET --no-delete --statistics --progress= P R O G R E S S − − l i m i t = PROGRESS --limit= PROGRESS−−limit=LIMIT --txn-size=KaTeX parse error: Expected group as argument to '\\"' at end of input: ...SIZE --file=\\"SOURCE_PATH C U R R E N T D A T E / CURRENT_DATE/ CURRENTDATE/START_DATE-END_DATE-by_ca_sign_record.txt""

echo "归档命令: $COMMON_MASTER" >> $LOG_FILE

echo -e "\n" >> $LOG_FILE

echo "归档执行中,请稍等..." >> $LOG_FILE

执行归档命令

eval $COMMON_MASTER >> $LOG_FILE

echo "表名: by_ca_sign_record $START_DATE - $END_DATE 归档完成" >> $LOG_FILE

echo -e "\n\n\n" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

开始备份 by_archived_record_log

echo "by_archived_record_log 开始备份: $START_DATE - END_DATE " \>\> L O G F I L E C O M M O N M A S T E R = " LOG_FILE COMMON_MASTER=" LOGFILECOMMONMASTER="BASE_PATH/pt-archiver --source h= S O U R C E H O S T , P = SOURCE_HOST,P= SOURCEHOST,P=SOURCE_PORT,u= S O U R C E U S E R , p = SOURCE_USER,p= SOURCEUSER,p=SOURCE_PASSWORD,D= S O U R C E D A T A B A S E , t = b y a r c h i v e d r e c o r d l o g − − w h e r e a ¨ r c h i v e d r e c o r d i d i n ( s e l e c t r e c o r d i d f r o m b y r e c o r d w h e r e o p e r a t i o n i d i n ( s e l e c t o p e r a t i o n i d f r o m b y o p e r a t i o n m a s t e r w h e r e s c h e d u l e d d a t e t i m e b e t w e e n ′ SOURCE_DATABASE,t=by_archived_record_log --where \\"archived_record_id in (select record_id from by_record where operation_id in (select operation_id from by_operation_master where scheduled_date_time between ' SOURCEDATABASE,t=byarchivedrecordlog−−wherea¨rchivedrecordidin(selectrecordidfrombyrecordwhereoperationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetween′START_DATE' and ' E N D D A T E ′ ) U N I O N s e l e c t o p e r a t i o n i d f r o m b y o p e r a t i o n m a s t e r w h e r e s c h e d u l e d d a t e t i m e b e t w e e n ′ END_DATE') UNION select operation_id from by_operation_master where scheduled_date_time between ' ENDDATE′)UNIONselectoperationidfrombyoperationmasterwherescheduleddatetimebetween′START_DATE' and 'KaTeX parse error: Expected group as argument to '\\"' at position 13: END_DATE')\\" ̲--charset=SOURCE_CHARSET --no-delete --statistics --progress= P R O G R E S S − − l i m i t = PROGRESS --limit= PROGRESS−−limit=LIMIT --txn-size=KaTeX parse error: Expected group as argument to '\\"' at end of input: ...SIZE --file=\\"SOURCE_PATH C U R R E N T D A T E / CURRENT_DATE/ CURRENTDATE/START_DATE-END_DATE-by_archived_record_log.txt""

echo "归档命令: $COMMON_MASTER" >> $LOG_FILE

echo -e "\n" >> $LOG_FILE

echo "归档执行中,请稍等..." >> $LOG_FILE

执行归档命令

eval $COMMON_MASTER >> $LOG_FILE

echo "表名: by_archived_record_log $START_DATE - $END_DATE 归档完成" >> $LOG_FILE

echo -e "\n\n\n" >> $LOG_FILE

echo "###############################################################" >> $LOG_FILE

echo "开始压缩" >> $LOG_FILE

#COMMON_TRA="tar -czf S T A R T D A T E − START_DATE- STARTDATE−END_DATE.tar.gz $CURRENT_DATE "

COMMON_TRA="pwd "

#eval $COMMON_TRA >> $LOG_FILE

echo "压缩完成" >> $LOG_FILE

相关推荐
zybsjn2 分钟前
如何产看SQL 查询的执行时间
数据库·sql
安迁岚2 分钟前
【SQL Server】华中农业大学空间数据库实验报告 实验二 数据库表
数据库·sql·mysql·oracle·实验报告
songqq273 分钟前
sql中判断一个字段是否包含一个数据的方法有哪些?
数据库·hive·sql
我是苏苏3 分钟前
数据库的使用02:SQLServer的连接字符串、备份、还原、SQL监视相关设置
数据库·sqlserver
zmd-zk3 分钟前
sql在hive和阿里云maxComputer的区别
数据库·hive·sql
小安运维日记4 分钟前
Linux云计算 |【第五阶段】PROJECT3-DAY1
linux·运维·安全·云计算
尸僵打怪兽15 分钟前
软考(中级-软件设计师)数据库篇(1101)
数据库·oracle·性能优化·软考
黑龙江亿林等保24 分钟前
阿里云ESC云服务器搭建指南
服务器·阿里云·云计算
愤怒的it菜鸟24 分钟前
2024文档透明加密软件最新推荐|10款好用的透明加密软件分享
大数据·运维·网络·安全·web安全
未来之窗软件服务25 分钟前
sqlserver
数据库·mysql