pt-archive

发布于:2024-11-04 ⋅ 阅读:(176) ⋅ 点赞:(0)

#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"archiverSOURCE_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=byoperationmasterwheres¨cheduleddatetimebetweenSTART_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= PROGRESSlimit=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=byoperationpatientwhereo¨perationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetweenSTART_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= PROGRESSlimit=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=byoperationstaffwhereo¨perationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetweenSTART_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= PROGRESSlimit=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=byoperationnamewhereo¨perationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetweenSTART_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= PROGRESSlimit=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=byoperationnursingeventwhereo¨perationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetweenSTART_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= PROGRESSlimit=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=byrecordwhereo¨perationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetweenSTART_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= PROGRESSlimit=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=byrecorddetailwherer¨ecordidin(selectrecordidfrombyrecordwhereoperationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetweenSTART_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= PROGRESSlimit=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=bysurgicalincisionwhereo¨perationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetweenSTART_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= PROGRESSlimit=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=byincisioninstrumentwherei¨ncisionidin(selectincisionidfrombysurgicalincisionwhereoperationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetweenSTART_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= PROGRESSlimit=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=byincisioncheckrecordwherei¨ncisionidin(selectincisionidfrombysurgicalincisionwhereoperationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetweenSTART_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= PROGRESSlimit=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=byincisioncheckdetailwherec¨heckrecordidin(selectcheckrecordidfrombyincisioncheckrecordwhereincisionidin(selectincisionidfrombysurgicalincisionwhereoperationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetweenSTART_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= PROGRESSlimit=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=byoperationremarkwherei¨ncisionidin(selectincisionidfrombysurgicalincisionwhereoperationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetweenSTART_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= PROGRESSlimit=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=bysignrecordwhereb¨usinessidin(selectrecordidfrombyrecordwhereoperationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetweenSTART_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(selectoperationidfrombyoperationmasterwherescheduleddatetimebetweenSTART_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(selectoperationidfrombyoperationmasterwherescheduleddatetimebetweenSTART_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= PROGRESSlimit=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=bycasignrecordwheres¨ignrecordidin(selectsignrecordidfrombysignrecordwherebusinessidin(selectrecordidfrombyrecordwhereoperationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetweenSTART_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(selectoperationidfrombyoperationmasterwherescheduleddatetimebetweenSTART_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(selectoperationidfrombyoperationmasterwherescheduleddatetimebetweenSTART_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= PROGRESSlimit=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=byarchivedrecordlogwherea¨rchivedrecordidin(selectrecordidfrombyrecordwhereoperationidin(selectoperationidfrombyoperationmasterwherescheduleddatetimebetweenSTART_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)UNIONselectoperationidfrombyoperationmasterwherescheduleddatetimebetweenSTART_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= PROGRESSlimit=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- STARTDATEEND_DATE.tar.gz $CURRENT_DATE "
COMMON_TRA="pwd "
#eval $COMMON_TRA >> $LOG_FILE
echo “压缩完成” >> $LOG_FILE