Skip to content

Commit 2084cd5

Browse files
committed
MDEV-17973: Don't overwrite xtrabackup-v2/mariabackup SST logs by default
1 parent 1d72db4 commit 2084cd5

File tree

1 file changed

+70
-8
lines changed

1 file changed

+70
-8
lines changed

scripts/wsrep_sst_mariabackup.sh

Lines changed: 70 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ DATA="${WSREP_SST_OPT_DATA}"
9090
INFO_FILE="xtrabackup_galera_info"
9191
IST_FILE="xtrabackup_ist"
9292
MAGIC_FILE="${DATA}/${INFO_FILE}"
93+
INNOAPPLYLOG="${DATA}/mariabackup.prepare.log"
94+
INNOMOVELOG="${DATA}/mariabackup.move.log"
95+
INNOBACKUPLOG="${DATA}/mariabackup.backup.log"
9396

9497
# Setting the path for ss and ip
9598
export PATH="/usr/sbin:/sbin:$PATH"
@@ -356,6 +359,8 @@ read_cnf()
356359
ssyslog=$(parse_cnf sst sst-syslog 0)
357360
ssystag=$(parse_cnf mysqld_safe syslog-tag "${SST_SYSLOG_TAG:-}")
358361
ssystag+="-"
362+
sstlogarchive=$(parse_cnf sst sst-log-archive 1)
363+
sstlogarchivedir=$(parse_cnf sst sst-log-archive-dir "/tmp/sst_log_archive")
359364

360365
if [[ $speciald -eq 0 ]];then
361366
wsrep_log_error "sst-special-dirs equal to 0 is not supported, falling back to 1"
@@ -712,10 +717,68 @@ if [[ $ssyslog -eq 1 ]];then
712717
INNOBACKUP="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2> >(logger -p daemon.err -t ${ssystag}innobackupex-backup)"
713718
fi
714719

715-
else
716-
INNOAPPLY="${INNOBACKUPEX_BIN} --innobackupex $disver $iapts --apply-log \$rebuildcmd \${DATA} &>\${DATA}/innobackup.prepare.log"
717-
INNOMOVE="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} &>\${DATA}/innobackup.move.log"
718-
INNOBACKUP="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2>\${DATA}/innobackup.backup.log"
720+
else
721+
722+
if [[ "$sstlogarchive" -eq 1 ]]
723+
then
724+
ARCHIVETIMESTAMP=$(date "+%Y.%m.%d-%H.%M.%S")
725+
newfile=""
726+
727+
if [[ ! -z "$sstlogarchivedir" ]]
728+
then
729+
if [[ ! -d "$sstlogarchivedir" ]]
730+
then
731+
mkdir -p "$sstlogarchivedir"
732+
fi
733+
fi
734+
735+
if [ -e "${INNOAPPLYLOG}" ]
736+
then
737+
if [[ ! -z "$sstlogarchivedir" ]]
738+
then
739+
newfile=$sstlogarchivedir/$(basename "${INNOAPPLYLOG}").${ARCHIVETIMESTAMP}
740+
else
741+
newfile=${INNOAPPLYLOG}.${ARCHIVETIMESTAMP}
742+
fi
743+
744+
wsrep_log_info "Moving ${INNOAPPLYLOG} to ${newfile}"
745+
mv "${INNOAPPLYLOG}" "${newfile}"
746+
gzip "${newfile}"
747+
fi
748+
749+
if [ -e "${INNOMOVELOG}" ]
750+
then
751+
if [[ ! -z "$sstlogarchivedir" ]]
752+
then
753+
newfile=$sstlogarchivedir/$(basename "${INNOMOVELOG}").${ARCHIVETIMESTAMP}
754+
else
755+
newfile=${INNOMOVELOG}.${ARCHIVETIMESTAMP}
756+
fi
757+
758+
wsrep_log_info "Moving ${INNOMOVELOG} to ${newfile}"
759+
mv "${INNOMOVELOG}" "${newfile}"
760+
gzip "${newfile}"
761+
fi
762+
763+
if [ -e "${INNOBACKUPLOG}" ]
764+
then
765+
if [[ ! -z "$sstlogarchivedir" ]]
766+
then
767+
newfile=$sstlogarchivedir/$(basename "${INNOBACKUPLOG}").${ARCHIVETIMESTAMP}
768+
else
769+
newfile=${INNOBACKUPLOG}.${ARCHIVETIMESTAMP}
770+
fi
771+
772+
wsrep_log_info "Moving ${INNOBACKUPLOG} to ${newfile}"
773+
mv "${INNOBACKUPLOG}" "${newfile}"
774+
gzip "${newfile}"
775+
fi
776+
777+
fi
778+
779+
INNOAPPLY="${INNOBACKUPEX_BIN} --innobackupex $disver $iapts --apply-log \$rebuildcmd \${DATA} &> ${INNOAPPLYLOG}"
780+
INNOMOVE="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} &> ${INNOMOVELOG}"
781+
INNOBACKUP="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2> ${INNOBACKUPLOG}"
719782
fi
720783

721784
get_stream
@@ -812,7 +875,7 @@ then
812875

813876
if [ ${RC[0]} -ne 0 ]; then
814877
wsrep_log_error "${INNOBACKUPEX_BIN} finished with error: ${RC[0]}. " \
815-
"Check ${DATA}/innobackup.backup.log"
878+
"Check syslog or ${INNOBACKUPLOG} for details"
816879
exit 22
817880
elif [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then
818881
wsrep_log_error "$tcmd finished with error: ${RC[1]}"
@@ -1033,13 +1096,12 @@ then
10331096

10341097
if [ $? -ne 0 ];
10351098
then
1036-
wsrep_log_error "${INNOBACKUPEX_BIN} apply finished with errors. Check ${DATA}/innobackup.prepare.log"
1099+
wsrep_log_error "${INNOBACKUPEX_BIN} apply finished with errors. Check syslog or ${INNOAPPLYLOG} for details"
10371100
exit 22
10381101
fi
10391102

10401103
MAGIC_FILE="${TDATA}/${INFO_FILE}"
10411104
set +e
1042-
rm $TDATA/innobackup.prepare.log $TDATA/innobackup.move.log
10431105
set -e
10441106
wsrep_log_info "Moving the backup to ${TDATA}"
10451107
timeit "Xtrabackup move stage" "$INNOMOVE"
@@ -1049,7 +1111,7 @@ then
10491111
DATA=${TDATA}
10501112
else
10511113
wsrep_log_error "Move failed, keeping ${DATA} for further diagnosis"
1052-
wsrep_log_error "Check ${DATA}/innobackup.move.log for details"
1114+
wsrep_log_error "Check syslog or ${INNOMOVELOG} for details"
10531115
exit 22
10541116
fi
10551117

0 commit comments

Comments
 (0)