summaryrefslogtreecommitdiff
path: root/scripts/wsrep_sst_mariabackup.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/wsrep_sst_mariabackup.sh')
-rw-r--r--scripts/wsrep_sst_mariabackup.sh292
1 files changed, 157 insertions, 135 deletions
diff --git a/scripts/wsrep_sst_mariabackup.sh b/scripts/wsrep_sst_mariabackup.sh
index b429a9effd5..4bca785fcad 100644
--- a/scripts/wsrep_sst_mariabackup.sh
+++ b/scripts/wsrep_sst_mariabackup.sh
@@ -20,10 +20,11 @@
# https://mariadb.com/kb/en/mariabackup-overview/
# Make sure to read that before proceeding!
+OS="$(uname)"
+
. $(dirname "$0")/wsrep_sst_common
wsrep_check_datadir
-OS="$(uname)"
ealgo=""
eformat=""
ekey=""
@@ -34,7 +35,7 @@ ssyslog=""
ssystag=""
BACKUP_PID=""
tcert=""
-tpath=0
+tcap=""
tpem=""
tkey=""
tmode="DISABLED"
@@ -88,14 +89,14 @@ readonly SECRET_TAG="secret"
# For backup locks it is 1 sent by joiner
sst_ver=1
-if [ -n "$(command -v pv)" ] && pv --help | grep -qw -- '-F'; then
+if [ -n "$(commandex pv)" ] && pv --help | grep -qw -- '-F'; then
pvopts="$pvopts $pvformat"
fi
pcmd="pv $pvopts"
declare -a RC
-BACKUP_BIN="$(command -v mariabackup)"
-if [ ! -x "$BACKUP_BIN" ]; then
+BACKUP_BIN=$(commandex 'mariabackup')
+if [ -z "$BACKUP_BIN" ]; then
wsrep_log_error 'mariabackup binary not found in path'
exit 42
fi
@@ -145,14 +146,14 @@ get_keys()
if [ $encrypt -eq 0 ]; then
if [ -n "$ealgo" -o -n "$ekey" -o -n "$ekeyfile" ]; then
- wsrep_log_error "Options for encryption are specified, " \
+ wsrep_log_error "Options for encryption are specified," \
"but encryption itself is disabled. SST may fail."
fi
return
fi
if [ $sfmt = 'tar' ]; then
- wsrep_log_info "NOTE: key-based encryption (encrypt=1) " \
+ wsrep_log_info "NOTE: key-based encryption (encrypt=1)" \
"cannot be enabled with tar format"
encrypt=-1
return
@@ -165,16 +166,18 @@ get_keys()
exit 3
fi
- if [ -z "$ekey" -a ! -r "$ekeyfile" ]; then
- wsrep_log_error "FATAL: Either key must be specified " \
- "or keyfile must be readable"
- exit 3
+ if [ -z "$ekey" ]; then
+ if [ ! -r "$ekeyfile" ]; then
+ wsrep_log_error "FATAL: Either key must be specified" \
+ "or keyfile must be readable"
+ exit 3
+ fi
fi
if [ "$eformat" = 'openssl' ]; then
get_openssl
if [ -z "$OPENSSL_BINARY" ]; then
- wsrep_log_error "If encryption using the openssl is enabled, " \
+ wsrep_log_error "If encryption using the openssl is enabled," \
"then you need to install openssl"
exit 2
fi
@@ -192,12 +195,12 @@ get_keys()
ecmd="$ecmd -k '$ekey'"
fi
elif [ "$eformat" = 'xbcrypt' ]; then
- if [ -z "$(command -v xbcrypt)" ]; then
- wsrep_log_error "If encryption using the xbcrypt is enabled, " \
+ if [ -z "$(commandex xbcrypt)" ]; then
+ wsrep_log_error "If encryption using the xbcrypt is enabled," \
"then you need to install xbcrypt"
exit 2
fi
- wsrep_log_info "NOTE: xbcrypt-based encryption, " \
+ wsrep_log_info "NOTE: xbcrypt-based encryption," \
"supported only from Xtrabackup 2.1.4"
if [ -z "$ekey" ]; then
ecmd="xbcrypt --encrypt-algo='$ealgo' --encrypt-key-file='$ekeyfile'"
@@ -342,40 +345,34 @@ get_transfer()
CN_option=",commonname=''"
if [ $encrypt -eq 2 ]; then
- wsrep_log_info "Using openssl based encryption with socat: with crt and pem"
- if [ -z "$tpem" -o -z "$tcert" ]; then
+ wsrep_log_info \
+ "Using openssl based encryption with socat: with crt and pem"
+ if [ -z "$tpem" -o -z "$tcert$tcap" ]; then
wsrep_log_error \
"Both PEM file and CRT file (or path) are required"
exit 22
fi
- if [ ! -r "$tpem" -o ! -r "$tcert" ]; then
- wsrep_log_error \
- "Both PEM file and CRT file (or path) must be readable"
- exit 22
+ verify_ca_matches_cert "$tpem" "$tcert" "$tcap"
+ tcmd="$tcmd,cert='$tpem'"
+ if [ -n "$tcert" ]; then
+ tcmd="$tcmd,cafile='$tcert'"
fi
- verify_ca_matches_cert "$tcert" "$tpem" $tpath
- if [ $tpath -eq 0 ]; then
- tcmd="$tcmd,cert='$tpem',cafile='$tcert'"
- else
- tcmd="$tcmd,cert='$tpem',capath='$tcert'"
+ if [ -n "$tcap" ]; then
+ tcmd="$tcmd,capath='$tcap'"
fi
stagemsg="$stagemsg-OpenSSL-Encrypted-2"
- wsrep_log_info "$action with cert=$tpem, ca=$tcert"
+ wsrep_log_info "$action with cert='$tpem', ca='$tcert', capath='$tcap'"
elif [ $encrypt -eq 3 -o $encrypt -eq 4 ]; then
- wsrep_log_info "Using openssl based encryption with socat: with key and crt"
+ wsrep_log_info \
+ "Using openssl based encryption with socat: with key and crt"
if [ -z "$tpem" -o -z "$tkey" ]; then
- wsrep_log_error "Both certificate file (or path) " \
- "and key file are required"
- exit 22
- fi
- if [ ! -r "$tpem" -o ! -r "$tkey" ]; then
- wsrep_log_error "Both certificate file (or path) " \
- "and key file must be readable"
+ wsrep_log_error "Both the certificate file (or path) and" \
+ "the key file are required"
exit 22
fi
verify_cert_matches_key "$tpem" "$tkey"
stagemsg="$stagemsg-OpenSSL-Encrypted-3"
- if [ -z "$tcert" ]; then
+ if [ -z "$tcert$tcap" ]; then
if [ $encrypt -eq 4 ]; then
wsrep_log_error \
"Peer certificate file (or path) required if encrypt=4"
@@ -384,14 +381,11 @@ get_transfer()
# no verification
CN_option=""
tcmd="$tcmd,cert='$tpem',key='$tkey',verify=0"
- wsrep_log_info "$action with cert=$tpem, key=$tkey, verify=0"
+ wsrep_log_info \
+ "$action with cert='$tpem', key='$tkey', verify=0"
else
# CA verification
- if [ ! -r "$tcert" ]; then
- wsrep_log_error "Certificate file or path must be readable"
- exit 22
- fi
- verify_ca_matches_cert "$tcert" "$tpem" $tpath
+ verify_ca_matches_cert "$tpem" "$tcert" "$tcap"
if [ -n "$WSREP_SST_OPT_REMOTE_USER" ]; then
CN_option=",commonname='$WSREP_SST_OPT_REMOTE_USER'"
elif [ "$WSREP_SST_OPT_ROLE" = 'joiner' -o $encrypt -eq 4 ]
@@ -402,12 +396,15 @@ get_transfer()
else
CN_option=",commonname='$WSREP_SST_OPT_HOST_UNESCAPED'"
fi
- if [ $tpath -eq 0 ]; then
- tcmd="$tcmd,cert='$tpem',key='$tkey',cafile='$tcert'"
- else
- tcmd="$tcmd,cert='$tpem',key='$tkey',capath='$tcert'"
+ tcmd="$tcmd,cert='$tpem',key='$tkey'"
+ if [ -n "$tcert" ]; then
+ tcmd="$tcmd,cafile='$tcert'"
+ fi
+ if [ -n "$tcap" ]; then
+ tcmd="$tcmd,capath='$tcap'"
fi
- wsrep_log_info "$action with cert=$tpem, key=$tkey, ca=$tcert"
+ wsrep_log_info "$action with cert='$tpem', key='$tkey'," \
+ "ca='$tcert', capath='$tcap'"
fi
else
wsrep_log_info "Unknown encryption mode: encrypt=$encrypt"
@@ -425,7 +422,9 @@ get_transfer()
get_footprint()
{
pushd "$WSREP_SST_OPT_DATA" 1>/dev/null
- payload=$(find . -regex '.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' -type f -print0 | du --files0-from=- --block-size=1 -c -s | awk 'END { print $1 }')
+ payload=$(find . -regex '.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' \
+ -type f -print0 | du --files0-from=- --block-size=1 -c -s | \
+ awk 'END { print $1 }')
if [ "$compress" != 'none' ]; then
# QuickLZ has around 50% compression ratio
# When compression/compaction used, the progress is only an approximate.
@@ -438,7 +437,7 @@ get_footprint()
adjust_progress()
{
- if [ -z "$(command -v pv)" ]; then
+ if [ -z "$(commandex pv)" ]; then
wsrep_log_error "pv not found in path: $PATH"
wsrep_log_error "Disabling all progress/rate-limiting"
pcmd=""
@@ -470,33 +469,42 @@ check_server_ssl_config()
{
# backward-compatible behavior:
tcert=$(parse_cnf 'sst' 'tca')
+ tcap=$(parse_cnf 'sst' 'tcapath')
tpem=$(parse_cnf 'sst' 'tcert')
tkey=$(parse_cnf 'sst' 'tkey')
# reading new ssl configuration options:
local tcert2=$(parse_cnf "$encgroups" 'ssl-ca')
+ local tcap2=$(parse_cnf "$encgroups" 'ssl-capath')
local tpem2=$(parse_cnf "$encgroups" 'ssl-cert')
local tkey2=$(parse_cnf "$encgroups" 'ssl-key')
# if there are no old options, then we take new ones:
- if [ -z "$tcert" -a -z "$tpem" -a -z "$tkey" ]; then
+ if [ -z "$tcert" -a -z "$tcap" -a -z "$tpem" -a -z "$tkey" ]; then
tcert="$tcert2"
+ tcap="$tcap2"
tpem="$tpem2"
tkey="$tkey2"
# checking for presence of the new-style SSL configuration:
- elif [ -n "$tcert2" -o -n "$tpem2" -o -n "$tkey2" ]; then
+ elif [ -n "$tcert2" -o -n "$tcap2" -o -n "$tpem2" -o -n "$tkey2" ]; then
if [ "$tcert" != "$tcert2" -o \
+ "$tcap" != "$tcap2" -o \
"$tpem" != "$tpem2" -o \
"$tkey" != "$tkey2" ]
then
- wsrep_log_info "new ssl configuration options (ssl-ca, ssl-cert " \
- "and ssl-key) are ignored by SST due to presence " \
- "of the tca, tcert and/or tkey in the [sst] section"
+ wsrep_log_info \
+ "new ssl configuration options (ssl-ca[path], ssl-cert" \
+ "and ssl-key) are ignored by SST due to presence" \
+ "of the tca[path], tcert and/or tkey in the [sst] section"
fi
fi
if [ -n "$tcert" ]; then
- tcert=$(trim_string "$tcert")
- if [ "${tcert%/}" != "$tcert" ]; then
- tpath=1
- fi
+ tcert=$(trim_string "$tcert")
+ if [ "${tcert%/}" != "$tcert" ] || [ -d "$tcert" ]; then
+ tcap="$tcert"
+ tcert=""
+ fi
+ fi
+ if [ -n "$tcap" ]; then
+ tcap=$(trim_string "$tcap")
fi
}
@@ -506,10 +514,10 @@ read_cnf()
tfmt=$(parse_cnf sst transferfmt 'socat')
encrypt=$(parse_cnf "$encgroups" 'encrypt' 0)
- tmode=$(parse_cnf "$encgroups" 'ssl-mode' 'DISABLED' | tr [:lower:] [:upper:])
+ tmode=$(parse_cnf "$encgroups" 'ssl-mode' 'DISABLED' | \
+ tr [:lower:] [:upper:])
- if [ $encrypt -eq 0 -o $encrypt -ge 2 ]
- then
+ if [ $encrypt -eq 0 -o $encrypt -ge 2 ]; then
if [ "$tmode" != 'DISABLED' -o $encrypt -ge 2 ]; then
check_server_ssl_config
fi
@@ -517,11 +525,13 @@ read_cnf()
if [ 0 -eq $encrypt -a -n "$tpem" -a -n "$tkey" ]
then
encrypt=3 # enable cert/key SSL encyption
-
# avoid CA verification if not set explicitly:
- # nodes may happen to have different CA if self-generated
- # zeroing up tcert does the trick
- [ "${tmode#VERIFY}" != "$tmode" ] || tcert=""
+ # nodes may happen to have different CA if self-generated,
+ # zeroing up tcert and tcap does the trick:
+ if [ "${tmode#VERIFY}" = "$tmode" ]; then
+ tcert=""
+ tcap=""
+ fi
fi
fi
elif [ $encrypt -eq 1 ]; then
@@ -535,8 +545,9 @@ read_cnf()
fi
fi
- wsrep_log_info "SSL configuration: CA='$tcert', CERT='$tpem'," \
- "KEY='$tkey', MODE='$tmode', encrypt='$encrypt'"
+ wsrep_log_info "SSL configuration: CA='$tcert', CAPATH='$tcap'," \
+ "CERT='$tpem', KEY='$tkey', MODE='$tmode'," \
+ "encrypt='$encrypt'"
sockopt=$(parse_cnf sst sockopt "")
progress=$(parse_cnf sst progress "")
@@ -561,7 +572,8 @@ read_cnf()
sstlogarchivedir=$(parse_cnf sst sst-log-archive-dir '/tmp/sst_log_archive')
if [ $speciald -eq 0 ]; then
- wsrep_log_error "sst-special-dirs equal to 0 is not supported, falling back to 1"
+ wsrep_log_error \
+ "sst-special-dirs equal to 0 is not supported, falling back to 1"
speciald=1
fi
@@ -589,7 +601,7 @@ get_stream()
{
if [ "$sfmt" = 'mbstream' -o "$sfmt" = 'xbstream' ]; then
sfmt='mbstream'
- STREAM_BIN="$(command -v mbstream)"
+ local STREAM_BIN=$(commandex "$sfmt")
if [ -z "$STREAM_BIN" ]; then
wsrep_log_error "Streaming with $sfmt, but $sfmt not found in path"
exit 42
@@ -621,7 +633,7 @@ cleanup_at_exit()
# Since this is invoked just after exit NNN
local estatus=$?
if [ $estatus -ne 0 ]; then
- wsrep_log_error "Cleanup after exit with status:$estatus"
+ wsrep_log_error "Cleanup after exit with status: $estatus"
fi
if [ "$WSREP_SST_OPT_ROLE" = 'joiner' ]; then
@@ -630,7 +642,8 @@ cleanup_at_exit()
else
if [ -n "$BACKUP_PID" ]; then
if check_pid "$BACKUP_PID" 1; then
- wsrep_log_error "mariabackup process is still running. Killing..."
+ wsrep_log_error \
+ "mariabackup process is still running. Killing..."
cleanup_pid $CHECK_PID "$BACKUP_PID"
fi
fi
@@ -638,8 +651,8 @@ cleanup_at_exit()
fi
if [ -n "$progress" -a -p "$progress" ]; then
- wsrep_log_info "Cleaning up fifo file $progress"
- rm -f "$progress" || true
+ wsrep_log_info "Cleaning up fifo file: $progress"
+ rm -f "$progress" || :
fi
wsrep_log_info "Cleaning up temporary directories"
@@ -649,8 +662,8 @@ cleanup_at_exit()
[ -d "$STATDIR" ] && rm -rf "$STATDIR"
fi
else
- [ -n "$xtmpdir" -a -d "$xtmpdir" ] && rm -rf "$xtmpdir" || true
- [ -n "$itmpdir" -a -d "$itmpdir" ] && rm -rf "$itmpdir" || true
+ [ -n "$xtmpdir" -a -d "$xtmpdir" ] && rm -rf "$xtmpdir" || :
+ [ -n "$itmpdir" -a -d "$itmpdir" ] && rm -rf "$itmpdir" || :
fi
# Final cleanup
@@ -662,7 +675,7 @@ cleanup_at_exit()
# This means a signal was delivered to the process.
# So, more cleanup.
if [ $estatus -ge 128 ]; then
- kill -KILL -- -$$ || true
+ kill -KILL -- -$$ || :
fi
fi
@@ -738,7 +751,7 @@ recv_joiner()
local ltcmd="$tcmd"
if [ $tmt -gt 0 ]; then
- if [ -n "$(command -v timeout)" ]; then
+ if [ -n "$(commandex timeout)" ]; then
if timeout --help | grep -qw -- '-k'; then
ltcmd="timeout -k $(( tmt+10 )) $tmt $tcmd"
else
@@ -760,14 +773,14 @@ recv_joiner()
popd 1>/dev/null
if [ ${RC[0]} -eq 124 ]; then
- wsrep_log_error "Possible timeout in receiving first data from " \
+ wsrep_log_error "Possible timeout in receiving first data from" \
"donor in gtid stage: exit codes: ${RC[@]}"
exit 32
fi
for ecode in "${RC[@]}"; do
if [ $ecode -ne 0 ]; then
- wsrep_log_error "Error while getting data from donor node: " \
+ wsrep_log_error "Error while getting data from donor node:" \
"exit codes: ${RC[@]}"
exit 32
fi
@@ -776,7 +789,7 @@ recv_joiner()
if [ $checkf -eq 1 ]; then
if [ ! -r "$MAGIC_FILE" ]; then
# this message should cause joiner to abort
- wsrep_log_error "receiving process ended without creating " \
+ wsrep_log_error "receiving process ended without creating" \
"'$MAGIC_FILE'"
wsrep_log_info "Contents of datadir"
wsrep_log_info $(ls -l "$dir/"*)
@@ -784,10 +797,11 @@ recv_joiner()
fi
# check donor supplied secret
- SECRET=$(grep -F -- "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | cut -d ' ' -f 2)
+ SECRET=$(grep -F -- "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | \
+ cut -d ' ' -f 2)
if [ "$SECRET" != "$MY_SECRET" ]; then
wsrep_log_error "Donor does not know my secret!"
- wsrep_log_info "Donor:'$SECRET', my:'$MY_SECRET'"
+ wsrep_log_info "Donor: '$SECRET', my: '$MY_SECRET'"
exit 32
fi
@@ -810,7 +824,7 @@ send_donor()
for ecode in "${RC[@]}"; do
if [ $ecode -ne 0 ]; then
- wsrep_log_error "Error while sending data to joiner node: " \
+ wsrep_log_error "Error while sending data to joiner node:" \
"exit codes: ${RC[@]}"
exit 32
fi
@@ -823,7 +837,9 @@ monitor_process()
while true ; do
if ! ps -p "$WSREP_SST_OPT_PARENT" >/dev/null 2>&1; then
- wsrep_log_error "Parent mysqld process (PID: $WSREP_SST_OPT_PARENT) terminated unexpectedly."
+ wsrep_log_error \
+ "Parent mysqld process (PID: $WSREP_SST_OPT_PARENT)" \
+ "terminated unexpectedly."
kill -- -"$WSREP_SST_OPT_PARENT"
exit 32
fi
@@ -845,7 +861,7 @@ read_cnf
setup_ports
if "$BACKUP_BIN" --help 2>/dev/null | grep -qw -- '--version-check'; then
- disver='--no-version-check'
+ disver=' --no-version-check'
fi
# if no command line argument and INNODB_DATA_HOME_DIR environment variable
@@ -867,7 +883,7 @@ INNODB_DATA_HOME_DIR=$(pwd -P)
cd "$OLD_PWD"
if [ $ssyslog -eq 1 ]; then
- if [ -n "$(command -v logger)" ]; then
+ if [ -n "$(commandex logger)" ]; then
wsrep_log_info "Logging all stderr of SST/mariabackup to syslog"
exec 2> >(logger -p daemon.err -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE)
@@ -898,10 +914,8 @@ else
fi
fi
- if [ -e "$INNOAPPLYLOG" ]
- then
- if [ -n "$sstlogarchivedir" ]
- then
+ if [ -e "$INNOAPPLYLOG" ]; then
+ if [ -n "$sstlogarchivedir" ]; then
newfile=$(basename "$INNOAPPLYLOG")
newfile="$sstlogarchivedir/$newfile.$ARCHIVETIMESTAMP"
else
@@ -912,10 +926,8 @@ else
gzip "$newfile"
fi
- if [ -e "$INNOMOVELOG" ]
- then
- if [ -n "$sstlogarchivedir" ]
- then
+ if [ -e "$INNOMOVELOG" ]; then
+ if [ -n "$sstlogarchivedir" ]; then
newfile=$(basename "$INNOMOVELOG")
newfile="$sstlogarchivedir/$newfile.$ARCHIVETIMESTAMP"
else
@@ -926,10 +938,8 @@ else
gzip "$newfile"
fi
- if [ -e "$INNOBACKUPLOG" ]
- then
- if [ -n "$sstlogarchivedir" ]
- then
+ if [ -e "$INNOBACKUPLOG" ]; then
+ if [ -n "$sstlogarchivedir" ]; then
newfile=$(basename "$INNOBACKUPLOG")
newfile="$sstlogarchivedir/$newfile.$ARCHIVETIMESTAMP"
else
@@ -949,15 +959,15 @@ setup_commands()
{
local mysqld_args=""
if [ -n "$WSREP_SST_OPT_MYSQLD" ]; then
- mysqld_args="--mysqld-args $WSREP_SST_OPT_MYSQLD"
+ mysqld_args=" --mysqld-args $WSREP_SST_OPT_MYSQLD"
fi
- if [ -z "$INNODB_FORCE_RECOVERY" ]; then
- INNOAPPLY="$BACKUP_BIN --prepare $disver $iapts $INNOEXTRA --target-dir='$DATA' --datadir='$DATA' $mysqld_args $INNOAPPLY"
- else
- INNOAPPLY="$BACKUP_BIN --prepare $disver $iapts $INNOEXTRA --innodb-force-recovery=$INNODB_FORCE_RECOVERY --target-dir='$DATA' --datadir='$DATA' $mysqld_args $INNOAPPLY"
+ local recovery=""
+ if [ -n "$INNODB_FORCE_RECOVERY" ]; then
+ recovery=" --innodb-force-recovery=$INNODB_FORCE_RECOVERY"
fi
- INNOMOVE="$BACKUP_BIN $WSREP_SST_OPT_CONF --move-back $disver $impts --force-non-empty-directories --target-dir='$DATA' --datadir='${TDATA:-$DATA}' $INNOMOVE"
- INNOBACKUP="$BACKUP_BIN $WSREP_SST_OPT_CONF --backup $disver $iopts $tmpopts $INNOEXTRA --galera-info --stream=$sfmt --target-dir='$itmpdir' --datadir='$DATA' $mysqld_args $INNOBACKUP"
+ INNOAPPLY="$BACKUP_BIN --prepare$disver$recovery${iapts:+ }$iapts$INNOEXTRA --target-dir='$DATA' --datadir='$DATA'$mysqld_args $INNOAPPLY"
+ INNOMOVE="$BACKUP_BIN$WSREP_SST_OPT_CONF --move-back$disver${impts:+ }$impts --force-non-empty-directories --target-dir='$DATA' --datadir='${TDATA:-$DATA}' $INNOMOVE"
+ INNOBACKUP="$BACKUP_BIN$WSREP_SST_OPT_CONF --backup$disver${iopts:+ }$iopts $tmpopts$INNOEXTRA --galera-info --stream=$sfmt --target-dir='$itmpdir' --datadir='$DATA'$mysqld_args $INNOBACKUP"
}
get_stream
@@ -1055,27 +1065,28 @@ then
tcmd="$ecmd | $tcmd"
fi
- iopts="--databases-exclude='lost+found' $iopts"
+ iopts="--databases-exclude='lost+found'${iopts:+ }$iopts"
if [ ${FORCE_FTWRL:-0} -eq 1 ]; then
- wsrep_log_info "Forcing FTWRL due to environment variable FORCE_FTWRL equal to $FORCE_FTWRL"
- iopts="--no-backup-locks $iopts"
+ wsrep_log_info "Forcing FTWRL due to environment variable" \
+ "FORCE_FTWRL equal to $FORCE_FTWRL"
+ iopts="--no-backup-locks${iopts:+ }$iopts"
fi
# if compression is enabled for backup files, then add the
# appropriate options to the mariabackup command line:
if [ "$compress" != 'none' ]; then
- iopts="--compress${compress:+=$compress} $iopts"
+ iopts="--compress${compress:+=$compress}${iopts:+ }$iopts"
if [ -n "$compress_threads" ]; then
- iopts="--compress-threads=$compress_threads $iopts"
+ iopts="--compress-threads=$compress_threads${iopts:+ }$iopts"
fi
if [ -n "$compress_chunk" ]; then
- iopts="--compress-chunk-size=$compress_chunk $iopts"
+ iopts="--compress-chunk-size=$compress_chunk${iopts:+ }$iopts"
fi
fi
if [ -n "$backup_threads" ]; then
- iopts="--parallel=$backup_threads $iopts"
+ iopts="--parallel=$backup_threads${iopts:+ }$iopts"
fi
setup_commands
@@ -1084,7 +1095,7 @@ then
set -e
if [ ${RC[0]} -ne 0 ]; then
- wsrep_log_error "mariabackup finished with error: ${RC[0]}. " \
+ wsrep_log_error "mariabackup finished with error: ${RC[0]}." \
"Check syslog or '$INNOBACKUPLOG' for details"
exit 22
elif [ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]; then
@@ -1125,7 +1136,8 @@ then
elif [ "$WSREP_SST_OPT_ROLE" = 'joiner' ]
then
- [ -e "$SST_PROGRESS_FILE" ] && wsrep_log_info "Stale sst_in_progress file: $SST_PROGRESS_FILE"
+ [ -e "$SST_PROGRESS_FILE" ] && \
+ wsrep_log_info "Stale sst_in_progress file: $SST_PROGRESS_FILE"
[ -n "$SST_PROGRESS_FILE" ] && touch "$SST_PROGRESS_FILE"
ib_home_dir="$INNODB_DATA_HOME_DIR"
@@ -1146,7 +1158,7 @@ then
ib_undo_dir="$INNODB_UNDO_DIR"
if [ -n "$backup_threads" ]; then
- impts="--parallel=$backup_threads $impts"
+ impts="--parallel=$backup_threads${impts:+ }$impts"
fi
stagemsg='Joiner-Recv'
@@ -1165,15 +1177,15 @@ then
ADDR="$WSREP_SST_OPT_ADDR"
- if [ "${tmode#VERIFY}" != "$tmode" ]
- then # backward-incompatible behavior
+ if [ "${tmode#VERIFY}" != "$tmode" ]; then
+ # backward-incompatible behavior:
CN=""
- if [ -n "$tpem" ]
- then
+ if [ -n "$tpem" ]; then
# find out my Common Name
get_openssl
if [ -z "$OPENSSL_BINARY" ]; then
- wsrep_log_error 'openssl not found but it is required for authentication'
+ wsrep_log_error \
+ 'openssl not found but it is required for authentication'
exit 42
fi
CN=$("$OPENSSL_BINARY" x509 -noout -subject -in "$tpem" | \
@@ -1213,15 +1225,17 @@ then
if ! ps -p "$WSREP_SST_OPT_PARENT" >/dev/null 2>&1
then
- wsrep_log_error "Parent mysqld process (PID: $WSREP_SST_OPT_PARENT) terminated unexpectedly."
+ wsrep_log_error "Parent mysqld process (PID: $WSREP_SST_OPT_PARENT)" \
+ "terminated unexpectedly."
exit 32
fi
- if [ ! -r "$STATDIR/$IST_FILE" ]
- then
+ if [ ! -r "$STATDIR/$IST_FILE" ]; then
if [ -d "$DATA/.sst" ]; then
- wsrep_log_info "WARNING: Stale temporary SST directory: '$DATA/.sst' from previous state transfer. Removing"
+ wsrep_log_info \
+ "WARNING: Stale temporary SST directory:" \
+ "'$DATA/.sst' from previous state transfer, removing..."
rm -rf "$DATA/.sst"
fi
mkdir -p "$DATA/.sst"
@@ -1229,17 +1243,20 @@ then
jpid=$!
wsrep_log_info "Proceeding with SST"
- wsrep_log_info "Cleaning the existing datadir and innodb-data/log directories"
+ wsrep_log_info \
+ "Cleaning the existing datadir and innodb-data/log directories"
if [ "$OS" = 'FreeBSD' ]; then
find -E ${ib_home_dir:+"$ib_home_dir"} \
${ib_undo_dir:+"$ib_undo_dir"} \
${ib_log_dir:+"$ib_log_dir"} \
- "$DATA" -mindepth 1 -prune -regex "$cpat" -o -exec rm -rfv {} 1>&2 \+
+ "$DATA" -mindepth 1 -prune -regex "$cpat" \
+ -o -exec rm -rfv {} 1>&2 \+
else
find ${ib_home_dir:+"$ib_home_dir"} \
${ib_undo_dir:+"$ib_undo_dir"} \
${ib_log_dir:+"$ib_log_dir"} \
- "$DATA" -mindepth 1 -prune -regex "$cpat" -o -exec rm -rfv {} 1>&2 \+
+ "$DATA" -mindepth 1 -prune -regex "$cpat" \
+ -o -exec rm -rfv {} 1>&2 \+
fi
get_binlog
@@ -1248,9 +1265,9 @@ then
binlog_dir=$(dirname "$WSREP_SST_OPT_BINLOG")
cd "$binlog_dir"
wsrep_log_info "Cleaning the binlog directory $binlog_dir as well"
- rm -fv "$WSREP_SST_OPT_BINLOG".[0-9]* 1>&2 \+ || true
+ rm -fv "$WSREP_SST_OPT_BINLOG".[0-9]* 1>&2 \+ || :
[ -f "$WSREP_SST_OPT_BINLOG_INDEX" ] && \
- rm -fv "$WSREP_SST_OPT_BINLOG_INDEX" 1>&2 \+ || true
+ rm -fv "$WSREP_SST_OPT_BINLOG_INDEX" 1>&2 \+ || :
cd "$OLD_PWD"
fi
@@ -1262,7 +1279,8 @@ then
monitor_process $jpid
if [ ! -s "$DATA/xtrabackup_checkpoints" ]; then
- wsrep_log_error "xtrabackup_checkpoints missing, failed mariabackup/SST on donor"
+ wsrep_log_error "xtrabackup_checkpoints missing," \
+ "failed mariabackup/SST on donor"
exit 2
fi
@@ -1277,7 +1295,7 @@ then
if [ -n "$qpfiles" ]; then
wsrep_log_info "Compressed qpress files found"
- if [ -z "$(command -v qpress)" ]; then
+ if [ -z "$(commandex qpress)" ]; then
wsrep_log_error "qpress utility not found in the path"
exit 22
fi
@@ -1300,14 +1318,17 @@ then
# Decompress the qpress files
wsrep_log_info "Decompression with $nproc threads"
- timeit "Joiner-Decompression" "find '$DATA' -type f -name '*.qp' -printf '%p\n%h\n' | $dcmd"
+ timeit "Joiner-Decompression" \
+ "find '$DATA' -type f -name '*.qp' -printf '%p\n%h\n' | $dcmd"
extcode=$?
if [ $extcode -eq 0 ]; then
wsrep_log_info "Removing qpress files after decompression"
find "$DATA" -type f -name '*.qp' -delete
if [ $? -ne 0 ]; then
- wsrep_log_error "Something went wrong with deletion of qpress files. Investigate"
+ wsrep_log_error \
+ "Something went wrong with deletion of qpress files." \
+ "Investigate"
fi
else
wsrep_log_error "Decompression failed. Exit code: $extcode"
@@ -1321,7 +1342,7 @@ then
BINLOG_FILENAME=$(basename "$WSREP_SST_OPT_BINLOG")
# To avoid comparing data directory and BINLOG_DIRNAME
- mv "$DATA/$BINLOG_FILENAME".* "$BINLOG_DIRNAME/" 2>/dev/null || true
+ mv "$DATA/$BINLOG_FILENAME".* "$BINLOG_DIRNAME/" 2>/dev/null || :
cd "$BINLOG_DIRNAME"
for bfile in $(ls -1 "$BINLOG_FILENAME".[0-9]*); do
@@ -1336,7 +1357,8 @@ then
timeit "mariabackup prepare stage" "$INNOAPPLY"
if [ $? -ne 0 ]; then
- wsrep_log_error "mariabackup apply finished with errors. Check syslog or '$INNOAPPLYLOG' for details"
+ wsrep_log_error "mariabackup apply finished with errors." \
+ "Check syslog or '$INNOAPPLYLOG' for details."
exit 22
fi