@@ -157,7 +157,7 @@ DATABASE_FILE=/root/xtrabackup.database.txt
157157
158158if [ " x${RESETDATABASE} " = " x1" ]; then
159159 # write the file containing the name of the DB xtrabackup should store data in
160- echo ${NEWDATABASENAME} > ${DATABASE_FILE}
160+ echo " ${NEWDATABASENAME} " > ${DATABASE_FILE}
161161 chmod 600 ${DATABASE_FILE}
162162fi
163163
@@ -199,31 +199,31 @@ EOF
199199# #############################################################
200200
201201_df () {
202- df -P -B 1K $1 | tail -n-1| awk ' {print $4}'
202+ df -P -B 1K " $1 " | tail -n-1| awk ' {print $4}'
203203}
204204
205205_df_h () {
206- df -Ph $1 | tail -n-1| awk ' {print $4}'
206+ df -Ph " $1 " | tail -n-1| awk ' {print $4}'
207207}
208208
209209_du_r () {
210- du -B 1K --max-depth=0 $1 | awk ' {print $1}'
210+ du -B 1K --max-depth=0 " $1 " | awk ' {print $1}'
211211}
212212
213213_du_h () {
214- du -h --max-depth=0 $1 | awk ' {print $1}'
214+ du -h --max-depth=0 " $1 " | awk ' {print $1}'
215215}
216216
217217_s_inf () {
218- echo " $( date +%Y-%m-%d_%H_%M_%S) xbackup $1 " | tee -a ${INF_FILE_WORK}
218+ echo " $( date +%Y-%m-%d_%H_%M_%S) xbackup $1 " | tee -a " ${INF_FILE_WORK} "
219219}
220220
221221_echo () {
222222 echo " $( date +%Y-%m-%d_%H_%M_%S) xbackup $1 "
223223}
224224
225225_d_inf () {
226- echo " $( date +%Y-%m-%d_%H_%M_%S) xbackup $1 " | tee -a ${INF_FILE_WORK}
226+ echo " $( date +%Y-%m-%d_%H_%M_%S) xbackup $1 " | tee -a " ${INF_FILE_WORK} "
227227 exit 1
228228}
229229
@@ -418,7 +418,7 @@ _s_inf "INFO: Backup type: ${BKP_TYPE}"
418418[ -d ${STOR_DIR} ] || \
419419 _d_inf " ERROR: STOR_DIR ${STOR_DIR} does not exist, \
420420 I will not create this automatically!"
421- [ -d ${WORK_DIR} ] || \
421+ [ -d " ${WORK_DIR} " ] || \
422422 _d_inf " ERROR: WORK_DIR ${WORK_DIR} does not exist, \
423423 I will not create this automatically!"
424424
466466#
467467if [ " ${BKP_TYPE} " = " incr" ]; then
468468 if [ -n " ${INC_BSEDIR} " ]; then
469- if [ ! -d ${WORK_DIR} /bkps/${INC_BSEDIR} ]; then
469+ if [ ! -d " ${WORK_DIR} " /bkps/" ${INC_BSEDIR} " ]; then
470470 _d_inf " ERROR: Specified incremental basedir ${WORK_DIR} /bkps/${_inc_basedir} does not exist." ;
471471 fi
472472
@@ -496,10 +496,10 @@ else
496496fi
497497
498498# Check for work directory
499- if [ ! -d ${WORK_DIR} ]; then _d_inf " ERROR: XtraBackup work directory does not exist" ; fi
499+ if [ ! -d " ${WORK_DIR} " ]; then _d_inf " ERROR: XtraBackup work directory does not exist" ; fi
500500
501- DATASIZE=$( _du_r ${DATADIR} )
502- DISKSPCE=$( _df ${WORK_DIR} )
501+ DATASIZE=$( _du_r " ${DATADIR} " )
502+ DISKSPCE=$( _df " ${WORK_DIR} " )
503503HASSPACE=$( echo " ${DATASIZE} ${DISKSPCE} " | awk ' {if($1 < $2) {print 1} else {print 0}}' )
504504NOSPACE=0
505505
514514# Keep track if any errors happen
515515_status=0
516516
517- cd ${WORK_DIR} /bkps/
517+ cd " ${WORK_DIR} " /bkps/
518518_s_inf " INFO: Backing up with: ${_ibx_bkp} "
519519${_ibx_bkp}
520520RETVAR=$?
@@ -536,11 +536,11 @@ echo
536536_echo " INFO: Syncing binary log snapshots"
537537if [ -n " ${_last_bkp} " ]; then
538538 _first_bkp_since=$( _sql_first_backup_elapsed)
539- > ${WORK_DIR} /bkps/binlog.index
539+ > " ${WORK_DIR} " /bkps/binlog.index
540540
541541 _echo " INFO: Getting a list of binary logs to copy"
542- for f in $( cat ${BNLGDIR} /${BNLGFMT} .index) ; do
543- echo $( basename ${f} ) >> ${WORK_DIR} /bkps/binlog.index
542+ for f in $( cat " ${BNLGDIR} " /${BNLGFMT} .index) ; do
543+ echo $( basename " ${f} " ) >> " ${WORK_DIR} " /bkps/binlog.index
544544 done
545545
546546 if [ " ${STOR_CMP} " = 1 ]; then
@@ -562,28 +562,28 @@ if [ -n "${_last_bkp}" ]; then
562562 if [ -n " ${_xbinlog_info} " -a -f " ${_xbinlog_info} " ]; then
563563 _echo " INFO: Found last binlog information ${_xbinlog_info} "
564564
565- _last_binlog=$( cat ${_xbinlog_info} | awk ' {print $1}' )
565+ _last_binlog=$( cat " ${_xbinlog_info} " | awk ' {print $1}' )
566566
567- cd ${BNLGDIR}
567+ cd " ${BNLGDIR} "
568568
569- for f in $( grep -A $( cat ${WORK_DIR} /bkps/binlog.index| wc -l) " ${_last_binlog} " ${WORK_DIR} /bkps/binlog.index) ; do
569+ for f in $( grep -A $( cat " ${WORK_DIR} " /bkps/binlog.index| wc -l) " ${_last_binlog} " " ${WORK_DIR} " /bkps/binlog.index) ; do
570570 if [ " ${STOR_CMP} " = 1 ]; then
571571 [ -f " ${_this_stor} /bnlg/${f} .tar.gz" ] && rm -rf " ${_this_stor} /bnlg/${f} .tar.gz"
572- tar czvf " ${_this_stor} /bnlg/${f} .tar.gz" ${f}
572+ tar czvf " ${_this_stor} /bnlg/${f} .tar.gz" " ${f} "
573573 else
574574 [ -f " ${_this_stor} /bnlg/${f} " ] && rm -rf " ${_this_stor} /bnlg/${f} "
575- cp -v ${f} " ${_this_stor} /bnlg/"
575+ cp -v " ${f} " " ${_this_stor} /bnlg/"
576576 fi
577577 done
578578
579579 if [ -f " ${_this_stor} /bnlg/${BNLGFMT} .index" ]; then rm -rf " ${_this_stor} /bnlg/${BNLGFMT} .index" ; fi
580- cp ${BNLGFMT} .index ${_this_stor} /bnlg/${BNLGFMT} .index
581- cd ${WORK_DIR} /bkps/
580+ cp ${BNLGFMT} .index " ${_this_stor} " /bnlg/${BNLGFMT} .index
581+ cd " ${WORK_DIR} " /bkps/
582582 fi
583583
584584 if [ -n " ${_first_bkp_since} " -a " ${_first_bkp_since} " -gt 0 ]; then
585585 _echo " INFO: Deleting archived binary logs older than ${_first_bkp_since} minutes ago"
586- find ${_this_stor} /bnlg/ -mmin +${_first_bkp_since} -exec rm -rf {} \;
586+ find " ${_this_stor} " /bnlg/ -mmin +" ${_first_bkp_since} " -exec rm -rf {} \;
587587 fi
588588fi
589589_echo " ... done"
@@ -596,12 +596,12 @@ if [ -n "${STOR_DIR}" ]; then
596596 echo
597597 _echo " INFO: Copying to immediate storage ${STOR_DIR} /bkps/"
598598 if [ " ${STOR_CMP} " = 1 ]; then
599- tar czvf ${STOR_DIR} /bkps/${CURDATE} .tar.gz ${CURDATE}
599+ tar czvf ${STOR_DIR} /bkps/" ${CURDATE} " .tar.gz " ${CURDATE} "
600600 ret=$?
601- [ -f ${_this_bkp} /xtrabackup_binlog_info ] \
602- && cp ${_this_bkp} /xtrabackup_binlog_info ${STOR_DIR} /bkps/${CURDATE} -xtrabackup_binlog_info.log
601+ [ -f " ${_this_bkp} " /xtrabackup_binlog_info ] \
602+ && cp " ${_this_bkp} " /xtrabackup_binlog_info ${STOR_DIR} /bkps/" ${CURDATE} " -xtrabackup_binlog_info.log
603603 else
604- cp -r ${_this_bkp} * ${STOR_DIR} /bkps/
604+ cp -r " ${_this_bkp} " * ${STOR_DIR} /bkps/
605605 ret=$?
606606 fi
607607
@@ -611,36 +611,36 @@ if [ -n "${STOR_DIR}" ]; then
611611 # Delete backup on work dir if no apply log is needed
612612 elif [ " x${APPLY_LOG} " = " x0" ]; then
613613 _echo " INFO: Cleaning up ${WORK_DIR} /bkps/"
614- cd ${WORK_DIR} /bkps/
614+ cd " ${WORK_DIR} " /bkps/
615615 if [ " x${STOR_CMP} " != " x1" ]; then
616616 _rxp=" ${CURDATE} [-info]?+.log"
617617 else
618618 _rxp=" ${CURDATE} [-info.log]?"
619619 fi
620620 _echo " \" ls | grep -Ev ${_rxp} \" "
621621 ls | grep -Ev " ${_rxp} "
622- for f in $( ls | grep -Ev ${_rxp} ) ; do rm -rf ${f} ; done
622+ for f in $( ls | grep -Ev " ${_rxp} " ) ; do rm -rf " ${f} " ; done
623623 # We also delete the previous incremental if the backup has been successful
624624 elif [ " ${BKP_TYPE} " = " incr" ]; then
625625 _echo " INFO: Deleting previous incremental ${WORK_DIR} /bkps/${_inc_basedir} "
626- rm -rf ${WORK_DIR} /bkps/${_inc_basedir} * ;
626+ rm -rf " ${WORK_DIR} " /bkps/" ${_inc_basedir} " * ;
627627 elif [ " ${BKP_TYPE} " = " full" ]; then
628- _echo " INFO: Deleting previous work backups $( find ${WORK_DIR} /bkps/ -maxdepth 1 -mindepth 1| grep -v ${CURDATE} | xargs) "
629- rm -rf $( find ${WORK_DIR} /bkps/ -maxdepth 1 -mindepth 1| grep -v ${CURDATE} | xargs)
628+ _echo " INFO: Deleting previous work backups $( find " ${WORK_DIR} " /bkps/ -maxdepth 1 -mindepth 1| grep -v " ${CURDATE} " | xargs) "
629+ rm -rf $( find " ${WORK_DIR} " /bkps/ -maxdepth 1 -mindepth 1| grep -v " ${CURDATE} " | xargs)
630630 fi
631631 _echo " ... done"
632632fi
633633
634634if [[ -n " ${RMTE_DIR} " && -n " ${RMTE_SSH} " ]]; then
635635 echo
636636 _echo " INFO: Syncing backup sets to remote ${RMTE_SSH} :${RMTE_DIR} /"
637- rsync -avzp --delete -e ssh ${STOR_DIR} / ${RMTE_SSH} : ${RMTE_DIR} /
637+ rsync -avzp --delete -e ssh ${STOR_DIR} / " ${RMTE_SSH} " : " ${RMTE_DIR} " /
638638 if [ " $? " -gt 0 ]; then _s_inf " WARNING: Failed to sync ${STOR_DIR} to ${RMTE_SSH} :${RMTE_DIR} /" ; fi
639639 _echo " ... done"
640640fi
641641
642642if [ " ${BKP_TYPE} " = " incr" ]; then
643- set -- $( _sql_incr_bsedir ${_week_no} )
643+ set -- $( _sql_incr_bsedir " ${_week_no} " )
644644 _incr_base=$1
645645 _incr_baseid=$2
646646 _incr_basedir=${_incr_base}
@@ -674,13 +674,13 @@ if [ "${status}" != 1 ]; then
674674 else
675675 _apply_to=" ${WORK_DIR} /bkps/P_${CURDATE} "
676676 # Check to make sure we have enough disk space to make a copy
677- _bu_size=$( _du_r ${_this_bkp} )
678- _du_left=$( _df ${WORK_DIR} )
677+ _bu_size=$( _du_r " ${_this_bkp} " )
678+ _du_left=$( _df " ${WORK_DIR} " )
679679 if [ " ${_bu_size} " -gt " ${_du_left} " ]; then
680680 _d_inf " ERROR: Apply to copy was specified, however there is not \
681681 enough disk space left on device." ;
682682 else
683- cp -r ${_this_bkp} ${_apply_to}
683+ cp -r " ${_this_bkp} " " ${_apply_to} "
684684 fi
685685
686686 _ibx_prep=" ${_ibx_prep} --apply-log --redo-only ${_apply_to} "
@@ -704,7 +704,7 @@ if [ "${RETVAR}" -gt 0 ]; then
704704 Something may have failed! Please prepare, I have not deleted the \
705705 new backup directory." ;
706706elif [ " x${STOR_CMP} " != " x1" ]; then
707- rm -rf ${_this_bkp}
707+ rm -rf " ${_this_bkp} "
708708fi
709709
710710# End, whether apply log is enabled
@@ -721,8 +721,8 @@ if [ "${BKP_TYPE}" = "incr" ]; then
721721else
722722 _incr_basedir=" NULL"
723723fi
724- [ -d " ${_this_bkp} " ] && _bu_size=$( _du_h ${_this_bkp} ) || _bu_size=$( _du_h ${_this_bkp_stored} )
725- _du_left=$( _df_h ${WORK_DIR} )
724+ [ -d " ${_this_bkp} " ] && _bu_size=$( _du_h " ${_this_bkp} " ) || _bu_size=$( _du_h " ${_this_bkp_stored} " )
725+ _du_left=$( _df_h " ${WORK_DIR} " )
726726
727727_sql_save_bkp " ${_started_at} " " ${_ends_at} " " ${_bu_size} " \
728728 " ${STOR_DIR} /bkps/${CURDATE} " " ${_incr_basedir} " \
@@ -733,11 +733,11 @@ _echo "INFO: Cleaning up previous backup files:"
733733# Find the ids of base backups first.
734734_prune_base=$( _sql_prune_base)
735735if [ -n " ${_prune_base} " ]; then
736- _prune_list=$( _sql_prune_list ${_prune_base} )
736+ _prune_list=$( _sql_prune_list " ${_prune_base} " )
737737 if [ -n " ${_prune_list} " ]; then
738738 _echo " INFO: Deleting backups: ${_prune_list} "
739- _sql_prune_rows ${_prune_base}
740- cd ${STOR_DIR} /bkps && rm -rf ${_prune_list}
739+ _sql_prune_rows " ${_prune_base} "
740+ cd ${STOR_DIR} /bkps && rm -rf " ${_prune_list} "
741741 fi
742742fi
743743_echo " ... done"
@@ -753,7 +753,7 @@ _s_inf "INFO: Remaining space available on backup device: ${_du_left}"
753753_s_inf " INFO: Logfile: ${LOG_FILE} "
754754[ " x${APPLY_LOG} " = " x1" ] && \
755755 _s_inf " INFO: Last full backup fully prepared (including incrementals): ${_last_full_prep} "
756- cp ${INF_FILE_WORK} ${INF_FILE_STOR}
756+ cp " ${INF_FILE_WORK} " " ${INF_FILE_STOR} "
757757echo
758758
759759rm -rf /tmp/xbackup.lock
0 commit comments