You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-5771 fixed -spoll for newer versions and config-file defaults
This commit is contained in:
committed by
Alan Mologorsky
parent
e2941628d1
commit
a02d15ad11
@ -13,7 +13,7 @@
|
||||
#
|
||||
########################################################################
|
||||
# Documentation: bash mcs_backup_manager.sh help
|
||||
# Version: 3.8
|
||||
# Version: 3.9
|
||||
#
|
||||
# Backup Example
|
||||
# LocalStorage: sudo ./mcs_backup_manager.sh backup
|
||||
@ -26,7 +26,7 @@
|
||||
# S3: sudo ./mcs_backup_manager.sh restore -bb s3://my-cs-backups -l <date>
|
||||
#
|
||||
########################################################################
|
||||
mcs_bk_manager_version="3.8"
|
||||
mcs_bk_manager_version="3.9"
|
||||
start=$(date +%s)
|
||||
action=$1
|
||||
|
||||
@ -67,8 +67,7 @@ check_operating_system() {
|
||||
esac
|
||||
}
|
||||
|
||||
load_default_backup_variables()
|
||||
{
|
||||
load_default_backup_variables() {
|
||||
check_operating_system
|
||||
|
||||
# What directory to store the backups on this machine or the target machine.
|
||||
@ -125,8 +124,8 @@ load_default_backup_variables()
|
||||
# modes ['direct','indirect'] - direct backups run on the columnstore nodes themselves. indirect run on another machine that has read-only mounts associated with columnstore/mariadb
|
||||
mode="direct"
|
||||
|
||||
# Name of the Configuration file to load variables from
|
||||
config_file=".cs-backup-config"
|
||||
# Name of the Configuration file to load variables from - relative or full path accepted
|
||||
config_file=""
|
||||
|
||||
# Track your write speed with "dstat --top-cpu --top-io"
|
||||
# Monitor individual rsyncs with ` watch -n0.25 "ps aux | grep 'rsync -a' | grep -vE 'color|grep' | wc -l; ps aux | grep 'rsync -a' | grep -vE 'color|grep' " `
|
||||
@ -155,7 +154,10 @@ load_default_backup_variables()
|
||||
|
||||
#source_ips=$(grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" /etc/columnstore/Columnstore.xml)
|
||||
#source_host_names=$(grep "<Node>" /etc/columnstore/Columnstore.xml)
|
||||
cmapi_key="$(grep "x-api-key" $CS_CONFIGS_PATH/cmapi_server.conf | awk '{print $3}' | tr -d "'" )";
|
||||
cmapi_key=""
|
||||
if [[ -f "$CS_CONFIGS_PATH/cmapi_server.conf" ]]; then
|
||||
cmapi_key="$(grep "x-api-key" "$CS_CONFIGS_PATH/cmapi_server.conf" | awk '{print $3}' | tr -d "'")";
|
||||
fi
|
||||
final_message="Backup Complete"
|
||||
skip_save_brm=false
|
||||
skip_locks=false
|
||||
@ -199,8 +201,7 @@ load_default_backup_variables()
|
||||
ASSIGNED_DBROOT=$(xmllint --xpath "string(//ModuleDBRootID$PM_NUMBER-1-3)" $CS_CONFIGS_PATH/Columnstore.xml)
|
||||
}
|
||||
|
||||
parse_backup_variables()
|
||||
{
|
||||
parse_backup_variables() {
|
||||
# Dynamic Arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
key="$1"
|
||||
@ -256,6 +257,9 @@ parse_backup_variables()
|
||||
;;
|
||||
-f| --config-file)
|
||||
config_file="$2"
|
||||
if [ "$config_file" == "" ] || [ ! -f "$config_file" ]; then
|
||||
handle_early_exit_on_backup "\n[!!!] Invalid Configuration File: $config_file\n" true
|
||||
fi
|
||||
shift # past argument
|
||||
shift # past value
|
||||
;;
|
||||
@ -327,16 +331,17 @@ parse_backup_variables()
|
||||
done
|
||||
|
||||
# Load config file
|
||||
if [ -f $config_file ]; then
|
||||
source $config_file
|
||||
if [ -n "$config_file" ] && [ -f "$config_file" ]; then
|
||||
if ! source "$config_file"; then
|
||||
handle_early_exit_on_backup "\n[!!!] Failed to source configuration file: $config_file\n" true
|
||||
fi
|
||||
fi
|
||||
|
||||
# Adjustment for indirect mode
|
||||
if [ $mode == "indirect" ]; then skip_locks=true; skip_save_brm=true; fi;
|
||||
}
|
||||
|
||||
print_backup_help_text()
|
||||
{
|
||||
print_backup_help_text() {
|
||||
echo "
|
||||
Columnstore Backup
|
||||
|
||||
@ -349,7 +354,7 @@ print_backup_help_text()
|
||||
-s | --storage The storage used by columnstore data 'LocalStorage' or 'S3'
|
||||
-i | --incremental Adds columnstore deltas to an existing full backup [ <Folder>, auto_most_recent ]
|
||||
-P | --parallel Number of parallel rsync/compression threads to run
|
||||
-f | --config-file Path to backup configuration file to load variables from
|
||||
-f | --config-file Path to backup configuration file to load variables from - see load_default_backup_variables() for defaults
|
||||
-sbrm | --skip-save-brm Skip saving brm prior to running a backup - ideal for dirty backups
|
||||
-slock | --skip-locks Skip issuing write locks - ideal for dirty backups
|
||||
-spoll | --skip-polls Skip sql checks confirming no write/cpimports running
|
||||
@ -386,14 +391,13 @@ print_backup_help_text()
|
||||
|
||||
}
|
||||
|
||||
print_backup_variables()
|
||||
{
|
||||
print_backup_variables() {
|
||||
# Log Variables
|
||||
s1=20
|
||||
s2=20
|
||||
printf "\nBackup Variables\n"
|
||||
echo "--------------------------------------------------------------------------"
|
||||
if [ -f $config_file ]; then
|
||||
if [ -n "$config_file" ] && [ -f "$config_file" ]; then
|
||||
printf "%-${s1}s %-${s2}s\n" "Configuration File:" "$config_file";
|
||||
fi
|
||||
echo "--------------------------------------------------------------------------"
|
||||
@ -549,8 +553,7 @@ confirm_pigz_installed() {
|
||||
fi
|
||||
}
|
||||
|
||||
check_for_dependancies()
|
||||
{
|
||||
check_for_dependancies() {
|
||||
# Check pidof works
|
||||
if [ $mode != "indirect" ] && ! command -v pidof > /dev/null; then
|
||||
handle_failed_dependencies "\n\n[!] Please make sure pidof is installed and executable\n\n"
|
||||
@ -636,8 +639,7 @@ check_for_dependancies()
|
||||
fi
|
||||
}
|
||||
|
||||
validation_prechecks_for_backup()
|
||||
{
|
||||
validation_prechecks_for_backup() {
|
||||
echo "Prechecks"
|
||||
|
||||
# Adjust rsync for incremental copy
|
||||
@ -913,7 +915,7 @@ cs_read_only_wait_loop() {
|
||||
|
||||
((retry_counter++))
|
||||
done
|
||||
printf "Done\n"
|
||||
printf "Done\n\n"
|
||||
}
|
||||
|
||||
# Having columnstore offline is best for non-volatile backups
|
||||
@ -927,6 +929,7 @@ issue_write_locks()
|
||||
|
||||
printf "\nLocks \n";
|
||||
# Pre 23.10.2 CS startreadonly doesnt exist - so poll cpimports added to protect them
|
||||
# Consider removing when 23.10.x is EOL
|
||||
if ! $skip_polls; then
|
||||
poll_check_no_active_sql_writes
|
||||
poll_check_no_active_cpimports
|
||||
@ -954,8 +957,9 @@ issue_write_locks()
|
||||
printf "Skip since offline\n";
|
||||
elif [ $DBROOT_COUNT == "1" ] && [[ -n "$startreadonly_exists" ]]; then
|
||||
if dbrmctl startreadonly ; then
|
||||
cs_read_only_wait_loop
|
||||
printf " \n";
|
||||
if ! $skip_polls; then
|
||||
cs_read_only_wait_loop
|
||||
fi
|
||||
else
|
||||
handle_early_exit_on_backup "\n[X] Failed issuing columnstore BRM lock via dbrmctl startreadonly\n"
|
||||
fi;
|
||||
@ -981,7 +985,6 @@ issue_write_locks()
|
||||
fi
|
||||
else
|
||||
cs_read_only_wait_loop
|
||||
printf " \n";
|
||||
fi
|
||||
}
|
||||
|
||||
@ -1036,8 +1039,7 @@ poll_check_no_active_cpimports() {
|
||||
fi;
|
||||
}
|
||||
|
||||
run_save_brm()
|
||||
{
|
||||
run_save_brm() {
|
||||
|
||||
if $skip_save_brm || [ $pm != "pm1" ] || ! $columnstore_online || [ $mode == "indirect" ]; then return; fi;
|
||||
|
||||
@ -1054,21 +1056,21 @@ run_save_brm()
|
||||
|
||||
printf " - Backing up minimal DBRMs @ $tmp_dir ... "
|
||||
# Base Set
|
||||
eval "smcat /data1/systemFiles/dbrm/BRM_saves_current 2>/dev/null > $tmp_dir/BRM_saves_current $xtra_cmd_args"
|
||||
eval "smcat /data1/systemFiles/dbrm/BRM_saves_journal 2>/dev/null > $tmp_dir/BRM_saves_journal $xtra_cmd_args"
|
||||
eval "smcat /data1/systemFiles/dbrm/BRM_saves_em 2>/dev/null > $tmp_dir/BRM_saves_em $xtra_cmd_args"
|
||||
eval "smcat /data1/systemFiles/dbrm/BRM_saves_vbbm 2>/dev/null > $tmp_dir/BRM_saves_vbbm $xtra_cmd_args"
|
||||
eval "smcat /data1/systemFiles/dbrm/BRM_saves_vss 2>/dev/null > $tmp_dir/BRM_saves_vss $xtra_cmd_args"
|
||||
smcat /data1/systemFiles/dbrm/BRM_saves_current 2>/dev/null > $tmp_dir/BRM_saves_current
|
||||
smcat /data1/systemFiles/dbrm/BRM_saves_journal 2>/dev/null > $tmp_dir/BRM_saves_journal
|
||||
smcat /data1/systemFiles/dbrm/BRM_saves_em 2>/dev/null > $tmp_dir/BRM_saves_em
|
||||
smcat /data1/systemFiles/dbrm/BRM_saves_vbbm 2>/dev/null > $tmp_dir/BRM_saves_vbbm
|
||||
smcat /data1/systemFiles/dbrm/BRM_saves_vss 2>/dev/null > $tmp_dir/BRM_saves_vss
|
||||
|
||||
# A Set
|
||||
eval "smcat /data1/systemFiles/dbrm/BRM_savesA_em 2>/dev/null > $tmp_dir/BRM_savesA_em $xtra_cmd_args"
|
||||
eval "smcat /data1/systemFiles/dbrm/BRM_savesA_vbbm 2>/dev/null > $tmp_dir/BRM_savesA_vbbm $xtra_cmd_args"
|
||||
eval "smcat /data1/systemFiles/dbrm/BRM_savesA_vss 2>/dev/null > $tmp_dir/BRM_savesA_vss $xtra_cmd_args"
|
||||
smcat /data1/systemFiles/dbrm/BRM_savesA_em 2>/dev/null > $tmp_dir/BRM_savesA_em
|
||||
smcat /data1/systemFiles/dbrm/BRM_savesA_vbbm 2>/dev/null > $tmp_dir/BRM_savesA_vbbm
|
||||
smcat /data1/systemFiles/dbrm/BRM_savesA_vss 2>/dev/null > $tmp_dir/BRM_savesA_vss
|
||||
|
||||
# B Set
|
||||
eval "smcat /data1/systemFiles/dbrm/BRM_savesB_em 2>/dev/null > $tmp_dir/BRM_savesB_em $xtra_cmd_args"
|
||||
eval "smcat /data1/systemFiles/dbrm/BRM_savesB_vbbm 2>/dev/null > $tmp_dir/BRM_savesB_vbbm $xtra_cmd_args"
|
||||
eval "smcat /data1/systemFiles/dbrm/BRM_savesB_vss 2>/dev/null > $tmp_dir/BRM_savesB_vss $xtra_cmd_args"
|
||||
smcat /data1/systemFiles/dbrm/BRM_savesB_em 2>/dev/null > $tmp_dir/BRM_savesB_em
|
||||
smcat /data1/systemFiles/dbrm/BRM_savesB_vbbm 2>/dev/null > $tmp_dir/BRM_savesB_vbbm
|
||||
smcat /data1/systemFiles/dbrm/BRM_savesB_vss 2>/dev/null > $tmp_dir/BRM_savesB_vss
|
||||
printf " Done \n"
|
||||
fi
|
||||
|
||||
@ -1085,8 +1087,7 @@ run_save_brm()
|
||||
|
||||
# Example: s3sync <from> <to> <success_message> <failed_message>
|
||||
# Example: s3sync s3://$bucket $backup_bucket/$today/columnstoreData "Done - Columnstore data sync complete"
|
||||
s3sync()
|
||||
{
|
||||
s3sync() {
|
||||
|
||||
local from=$1
|
||||
local to=$2
|
||||
@ -1127,8 +1128,7 @@ s3sync()
|
||||
}
|
||||
|
||||
# Example: s3cp <from> <to>
|
||||
s3cp()
|
||||
{
|
||||
s3cp() {
|
||||
local from=$1
|
||||
local to=$2
|
||||
local cmd=""
|
||||
@ -1145,8 +1145,7 @@ s3cp()
|
||||
}
|
||||
|
||||
# Example: s3rm <path to delete>
|
||||
s3rm()
|
||||
{
|
||||
s3rm() {
|
||||
local path=$1
|
||||
local cmd=""
|
||||
|
||||
@ -1161,8 +1160,7 @@ s3rm()
|
||||
}
|
||||
|
||||
# Example: s3ls <path to list>
|
||||
s3ls()
|
||||
{
|
||||
s3ls() {
|
||||
local path=$1
|
||||
local cmd=""
|
||||
|
||||
@ -1176,8 +1174,7 @@ s3ls()
|
||||
$cmd
|
||||
}
|
||||
|
||||
clear_read_lock()
|
||||
{
|
||||
clear_read_lock() {
|
||||
|
||||
if [ $mode == "indirect" ] || $skip_locks; then return; fi;
|
||||
|
||||
@ -1219,8 +1216,7 @@ clear_read_lock()
|
||||
}
|
||||
|
||||
# handle_ called when certain checks/functionality fails
|
||||
handle_failed_dependencies()
|
||||
{
|
||||
handle_failed_dependencies() {
|
||||
printf "\nDependency Checks Failed: $1"
|
||||
alert "$1"
|
||||
exit 1;
|
||||
@ -1228,8 +1224,7 @@ handle_failed_dependencies()
|
||||
|
||||
# first argument is the error message
|
||||
# 2nd argument true = skip clear_read_lock, false= dont skip
|
||||
handle_early_exit_on_backup()
|
||||
{
|
||||
handle_early_exit_on_backup() {
|
||||
skip_clear_locks=${2:-false}
|
||||
if ! $skip_clear_locks; then clear_read_lock; fi;
|
||||
printf "\nBackup Failed: $1\n"
|
||||
@ -1237,8 +1232,7 @@ handle_early_exit_on_backup()
|
||||
exit 1;
|
||||
}
|
||||
|
||||
handle_early_exit_on_restore()
|
||||
{
|
||||
handle_early_exit_on_restore() {
|
||||
printf "\nRestore Failed: $1\n"
|
||||
alert "$1"
|
||||
exit 1;
|
||||
@ -1285,8 +1279,7 @@ wait_on_rsync()
|
||||
done
|
||||
}
|
||||
|
||||
initiate_rsyncs()
|
||||
{
|
||||
initiate_rsyncs() {
|
||||
local dbrootToSync=$1
|
||||
parallel_rysnc_flags=" -a "
|
||||
if $incremental ; then parallel_rysnc_flags+=" --inplace --no-whole-file --delete"; fi;
|
||||
@ -1304,8 +1297,7 @@ initiate_rsyncs()
|
||||
# depthCurrent: 1
|
||||
# depthTarget: 3
|
||||
# depthCurrent: data1
|
||||
deepParallelRsync()
|
||||
{
|
||||
deepParallelRsync() {
|
||||
path=$1
|
||||
depthCurrent=$2
|
||||
depthTarget=$3
|
||||
@ -1357,8 +1349,7 @@ deepParallelRsync()
|
||||
wait
|
||||
}
|
||||
|
||||
run_backup()
|
||||
{
|
||||
run_backup() {
|
||||
if [ $storage == "LocalStorage" ]; then
|
||||
if [ $backup_destination == "Local" ]; then
|
||||
|
||||
@ -1454,7 +1445,7 @@ run_backup()
|
||||
rm -rf $CS_CONFIGS_PATH/$col_xml_backup
|
||||
rm -rf $CS_CONFIGS_PATH/$cmapi_backup
|
||||
cp $CS_CONFIGS_PATH/Columnstore.xml $CS_CONFIGS_PATH/$col_xml_backup
|
||||
cp $CS_CONFIGS_PATH/cmapi_server.conf $CS_CONFIGS_PATH/$cmapi_backup
|
||||
if [ -f $CS_CONFIGS_PATH/cmapi_server.conf ]; then cp $CS_CONFIGS_PATH/cmapi_server.conf $CS_CONFIGS_PATH/$cmapi_backup; fi;
|
||||
compress_paths+=" $CS_CONFIGS_PATH/$col_xml_backup $STORAGEMANGER_CNF $CS_CONFIGS_PATH/$cmapi_backup"
|
||||
fi;
|
||||
fi
|
||||
@ -1584,8 +1575,20 @@ run_backup()
|
||||
max_wait=180
|
||||
printf " - Checking storagemanager/journal/data$ASSIGNED_DBROOT/* "
|
||||
while [[ $j_counts -gt 0 ]]; do
|
||||
if [ $i -gt $max_wait ]; then printf "[!] Maybe you have orphaned journal files, active writes or an unreachable bucket \n"; handle_early_exit_on_backup "\n[!] max_wait exceeded for $cs_journal/data$ASSIGNED_DBROOT/* to sync with bucket "; ls -la $cs_journal/data$ASSIGNED_DBROOT/*; fi;
|
||||
if (( $i%10 == 0 )); then printf "\n[!] Not empty yet - found $j_counts files @ $cs_journal/data$ASSIGNED_DBROOT/*\n"; printf " - Checking storagemanager/journal/data$ASSIGNED_DBROOT/* "; fi;
|
||||
|
||||
# Handle when max_wait exceeded
|
||||
if [ $i -gt $max_wait ]; then
|
||||
printf "[!] Maybe you have orphaned journal files, active writes or an unreachable bucket \n";
|
||||
handle_early_exit_on_backup "\n[!] max_wait exceeded for $cs_journal/data$ASSIGNED_DBROOT/* to sync with bucket ";
|
||||
ls -la $cs_journal/data$ASSIGNED_DBROOT/*;
|
||||
fi;
|
||||
|
||||
# Print every 10 seconds
|
||||
if (( $i%10 == 0 )); then
|
||||
printf "\n[!] Not empty yet - found $j_counts files @ $cs_journal/data$ASSIGNED_DBROOT/*\n";
|
||||
printf " - Checking storagemanager/journal/data$ASSIGNED_DBROOT/* ";
|
||||
fi;
|
||||
|
||||
sleep 1
|
||||
i=$(($i+1))
|
||||
j_counts=$(find $cs_journal/data$ASSIGNED_DBROOT/* -type f 2>/dev/null | wc -l)
|
||||
@ -1746,8 +1749,7 @@ run_backup()
|
||||
printf "$final_message\n\n"
|
||||
}
|
||||
|
||||
load_default_restore_variables()
|
||||
{
|
||||
load_default_restore_variables() {
|
||||
# What date folder to load from the backup_location
|
||||
load_date=''
|
||||
|
||||
@ -1777,8 +1779,8 @@ load_default_restore_variables()
|
||||
# modes ['direct','indirect'] - direct backups run on the columnstore nodes themselves. indirect run on another machine that has read-only mounts associated with columnstore/mariadb
|
||||
mode="direct"
|
||||
|
||||
# Name of the Configuration file to load variables from
|
||||
config_file=".cs-backup-config"
|
||||
# Name of the Configuration file to load variables from - relative or full path accepted
|
||||
config_file=""
|
||||
|
||||
# Only used if storage=S3
|
||||
# Name of the bucket to copy into to store the backup S3 data
|
||||
@ -1842,8 +1844,7 @@ load_default_restore_variables()
|
||||
rsync_flags=" -av";
|
||||
}
|
||||
|
||||
parse_restore_variables()
|
||||
{
|
||||
parse_restore_variables() {
|
||||
# Dynamic Arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
key="$1"
|
||||
@ -1933,6 +1934,9 @@ parse_restore_variables()
|
||||
;;
|
||||
-f|--config-file)
|
||||
config_file="$2"
|
||||
if [ "$config_file" == "" ] || [ ! -f "$config_file" ]; then
|
||||
handle_early_exit_on_restore "\n[!!!] Invalid Configuration File: $config_file\n"
|
||||
fi
|
||||
shift # past argument
|
||||
shift # past value
|
||||
;;
|
||||
@ -1972,8 +1976,10 @@ parse_restore_variables()
|
||||
done
|
||||
|
||||
# Load config file
|
||||
if [ -f $config_file ]; then
|
||||
source $config_file
|
||||
if [ -n "$config_file" ] && [ -f "$config_file" ]; then
|
||||
if ! source "$config_file"; then
|
||||
handle_early_exit_on_restore "\n[!!!] Failed to source configuration file: $config_file\n" true
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@ -1997,7 +2003,7 @@ print_restore_help_text()
|
||||
-nr | --new-region Defines the region of the new bucket to copy the s3 data to from the backup bucket
|
||||
-nk | --new-key Defines the aws key to connect to the new_bucket
|
||||
-ns | --new-secret Defines the aws secret of the aws key to connect to the new_bucket
|
||||
-f | --config-file Path to backup configuration file to load variables from
|
||||
-f | --config-file Path to backup configuration file to load variables from - see load_default_restore_variables() for defaults
|
||||
-cont| --continue This acknowledges data in your --new_bucket is ok to delete when restoring S3
|
||||
-smdb| --skip-mariadb-backup Skip restoring mariadb server via mariadb-backup - ideal for only restoring columnstore
|
||||
-sb | --skip-bucket-data Skip restoring columnstore data in the bucket - ideal if looking to only restore mariadb server
|
||||
@ -2027,9 +2033,8 @@ print_restore_variables()
|
||||
{
|
||||
|
||||
printf "\nRestore Variables\n"
|
||||
if [ -f $config_file ]; then
|
||||
if [ -n "$config_file" ] && [ -f "$config_file" ]; then
|
||||
printf "%-${s1}s %-${s2}s\n" "Configuration File:" "$config_file";
|
||||
source $config_file
|
||||
fi
|
||||
if [ $mode == "indirect" ] || $skip_mdb || $skip_bucket_data; then
|
||||
echo "------------------------------------------------"
|
||||
@ -2486,35 +2491,40 @@ run_restore()
|
||||
handle_early_exit_on_restore "Invalid Script Variable --backup_destination: $backup_destination"
|
||||
fi
|
||||
|
||||
# MariaDB Server Restore
|
||||
printf "\nRestore MariaDB Server\n"
|
||||
if [[ -n "$compress_format" ]]; then
|
||||
# Handle compressed mariadb-backup restore
|
||||
mbd_prefix="$backup_location$load_date/$split_file_mdb_prefix.$compress_format"
|
||||
case $compress_format in
|
||||
pigz)
|
||||
printf " - Decompressing MariaDB Files -> $MARIADB_PATH ... "
|
||||
rm -rf $MARIADB_PATH/*
|
||||
cd /
|
||||
if ! eval "pigz -dc -p $PARALLEL_THREADS $mbd_prefix | mbstream -p $PARALLEL_THREADS -x -C $MARIADB_PATH"; then
|
||||
handle_early_exit_on_restore "Failed to decompress mariadb backup\ncommand:\npigz -dc -p $PARALLEL_THREADS $mbd_prefix | mbstream -p $PARALLEL_THREADS -x -C $MARIADB_PATH \n"
|
||||
fi;
|
||||
printf " Done \n"
|
||||
printf " - Running mariabackup --prepare ... "
|
||||
if eval "mariabackup --prepare --target-dir=$MARIADB_PATH $xtra_cmd_args"; then
|
||||
printf " Done\n";
|
||||
else
|
||||
handle_early_exit_on_restore "Failed to --prepare\nmariabackup --prepare --target-dir=$MARIADB_PATH";
|
||||
fi;
|
||||
;;
|
||||
*) # unknown option
|
||||
handle_early_exit_on_backup "\nUnknown compression flag: $compress_format\n"
|
||||
esac
|
||||
if ! $skip_mdb; then
|
||||
# MariaDB Server Restore
|
||||
printf "\nRestore MariaDB Server\n"
|
||||
if [[ -n "$compress_format" ]]; then
|
||||
# Handle compressed mariadb-backup restore
|
||||
mbd_prefix="$backup_location$load_date/$split_file_mdb_prefix.$compress_format"
|
||||
case $compress_format in
|
||||
pigz)
|
||||
printf " - Decompressing MariaDB Files -> $MARIADB_PATH ... "
|
||||
rm -rf $MARIADB_PATH/*
|
||||
cd /
|
||||
if ! eval "pigz -dc -p $PARALLEL_THREADS $mbd_prefix | mbstream -p $PARALLEL_THREADS -x -C $MARIADB_PATH"; then
|
||||
handle_early_exit_on_restore "Failed to decompress mariadb backup\ncommand:\npigz -dc -p $PARALLEL_THREADS $mbd_prefix | mbstream -p $PARALLEL_THREADS -x -C $MARIADB_PATH \n"
|
||||
fi;
|
||||
printf " Done \n"
|
||||
printf " - Running mariabackup --prepare ... "
|
||||
if eval "mariabackup --prepare --target-dir=$MARIADB_PATH $xtra_cmd_args"; then
|
||||
printf " Done\n";
|
||||
else
|
||||
handle_early_exit_on_restore "Failed to --prepare\nmariabackup --prepare --target-dir=$MARIADB_PATH";
|
||||
fi;
|
||||
;;
|
||||
*) # unknown option
|
||||
handle_early_exit_on_backup "\nUnknown compression flag: $compress_format\n"
|
||||
esac
|
||||
else
|
||||
eval "mariabackup --prepare --target-dir=$backup_location$load_date/mysql/ $xtra_cmd_args"
|
||||
rm -rf /var/lib/mysql/*
|
||||
eval "mariabackup --copy-back --target-dir=$backup_location$load_date/mysql/ $xtra_cmd_args"
|
||||
fi
|
||||
else
|
||||
eval "mariabackup --prepare --target-dir=$backup_location$load_date/mysql/ $xtra_cmd_args"
|
||||
rm -rf /var/lib/mysql/*
|
||||
eval "mariabackup --copy-back --target-dir=$backup_location$load_date/mysql/ $xtra_cmd_args"
|
||||
fi
|
||||
echo "[!] Skipping mariadb server restore"
|
||||
|
||||
fi;
|
||||
printf " - Chowning MariaDB Files ... ";
|
||||
chown -R $mariadb_user:$mariadb_user /var/lib/mysql/
|
||||
chown -R $columnstore_user:$mariadb_user /var/log/mariadb/
|
||||
@ -2696,12 +2706,13 @@ run_restore()
|
||||
printf "$final_message\n\n"
|
||||
if ! $quiet; then
|
||||
if [ $pm == "pm1" ]; then
|
||||
echo -e " - Last you need to manually configure mariadb replication between nodes"
|
||||
echo -e " - systemctl start mariadb "
|
||||
echo -e " - systemctl start mariadb-columnstore-cmapi "
|
||||
echo -e " - mcs cluster start \n\n"
|
||||
echo -e "Next: "
|
||||
if [ $DBROOT_COUNT -gt 1 ]; then echo -e "[!!] Check Replicas to manually configure mariadb replication"; fi
|
||||
echo -e "systemctl start mariadb "
|
||||
echo -e "systemctl start mariadb-columnstore-cmapi "
|
||||
echo -e "mcs cluster start \n\n"
|
||||
else
|
||||
printf " - Last you need to manually configure mariadb replication between nodes\n"
|
||||
echo -e "[!!] Check this replica to manually configure mariadb replication after primary node is ready"
|
||||
echo -e "Example:"
|
||||
echo -e "mariadb -e \"stop slave;CHANGE MASTER TO MASTER_HOST='\$pm1' , MASTER_USER='repuser' , MASTER_PASSWORD='aBcd123%123%aBc' , MASTER_USE_GTID = slave_pos;start slave;show slave status\G\""
|
||||
echo -e "mariadb -e \"show slave status\G\" | grep \"Slave_\" \n"
|
||||
@ -2928,7 +2939,7 @@ validation_prechecks_for_dbrm_backup() {
|
||||
|
||||
# Check backup location exists
|
||||
if [ ! -d $backup_location ]; then
|
||||
echo "[+] Created: $backup_location"
|
||||
echo "Created: $backup_location"
|
||||
mkdir "$backup_location";
|
||||
fi;
|
||||
|
||||
@ -3076,6 +3087,12 @@ validation_prechecks_for_dbrm_restore() {
|
||||
done
|
||||
}
|
||||
|
||||
print_if_not_quiet() {
|
||||
if ! $quiet; then
|
||||
printf "$1";
|
||||
fi
|
||||
}
|
||||
|
||||
process_dbrm_backup() {
|
||||
|
||||
load_default_dbrm_variables
|
||||
@ -3118,14 +3135,14 @@ process_dbrm_backup() {
|
||||
|
||||
# Copy files to the backup directory
|
||||
if [[ $skip_storage_manager == false || $storage == "LocalStorage" ]]; then
|
||||
if ! $quiet; then printf " - copying $dbrm_dir ..."; fi;
|
||||
print_if_not_quiet " - copying $dbrm_dir ...";
|
||||
cp -arp "$dbrm_dir"/* "$backup_folder"
|
||||
if ! $quiet; then printf " Done\n"; fi;
|
||||
print_if_not_quiet " Done\n";
|
||||
fi
|
||||
|
||||
if [ "$storage" == "S3" ]; then
|
||||
# smcat em files to disk
|
||||
if ! $quiet; then printf " - copying DBRMs from bucket ..."; fi;
|
||||
print_if_not_quiet " - copying DBRMs from bucket ...";
|
||||
mkdir $backup_folder/dbrms/
|
||||
smls /data1/systemFiles/dbrm 2>/dev/null > $backup_folder/dbrms/dbrms.txt
|
||||
smcat /data1/systemFiles/dbrm/BRM_saves_current 2>/dev/null > $backup_folder/dbrms/BRM_saves_current
|
||||
@ -3142,24 +3159,23 @@ process_dbrm_backup() {
|
||||
smcat /data1/systemFiles/dbrm/oidbitmap 2>/dev/null > $backup_folder/dbrms/oidbitmap
|
||||
smcat /data1/systemFiles/dbrm/SMTxnID 2>/dev/null > $backup_folder/dbrms/SMTxnID
|
||||
smcat /data1/systemFiles/dbrm/tablelocks 2>/dev/null > $backup_folder/dbrms/tablelocks
|
||||
if ! $quiet; then printf " Done\n"; fi;
|
||||
print_if_not_quiet " Done\n";
|
||||
fi
|
||||
|
||||
if [ $retention_days -gt 0 ] ; then
|
||||
# Clean up old backups
|
||||
# example: find /tmp/dbrm_backups -maxdepth 1 -type d -name "dbrm_backup_*" -mtime +1 -exec rm -r {} \;
|
||||
if ! $quiet; then printf " - applying retention policy ..."; fi;
|
||||
print_if_not_quiet " - applying retention policy ...";
|
||||
find "$backup_location" -maxdepth 1 -type d -name "${backup_base_name}_*" -mtime +$retention_days -exec rm -r {} \;
|
||||
if ! $quiet; then printf " Done\n"; fi;
|
||||
print_if_not_quiet " Done\n";
|
||||
fi;
|
||||
|
||||
printf "Created: $backup_folder\n"
|
||||
|
||||
|
||||
if [ "$mode" == "once" ]; then
|
||||
end=$(date +%s)
|
||||
runtime=$((end-start))
|
||||
if ! $quiet; then printf "Runtime: $runtime\n"; fi;
|
||||
if ! $quiet; then printf "\nRuntime: $runtime\n"; fi;
|
||||
break;
|
||||
fi;
|
||||
|
||||
@ -3167,7 +3183,7 @@ process_dbrm_backup() {
|
||||
sleep "$sleep_seconds"
|
||||
done
|
||||
|
||||
if ! $quiet; then printf "Complete\n\n"; fi;
|
||||
print_if_not_quiet "Complete\n\n"
|
||||
}
|
||||
|
||||
is_cmapi_installed() {
|
||||
@ -3207,11 +3223,11 @@ start_mariadb_cmapi_columnstore() {
|
||||
# Currently assumes systemd installed
|
||||
shutdown_columnstore_mariadb_cmapi() {
|
||||
|
||||
pf=35
|
||||
local print_formatting=35
|
||||
init_cs_down
|
||||
wait_cs_down 0
|
||||
|
||||
printf "%-${pf}s ... " " - Stopping MariaDB Server"
|
||||
printf "%-${print_formatting}s ... " " - Stopping MariaDB Server"
|
||||
if ! systemctl stop mariadb; then
|
||||
echo "[!!] Failed to stop mariadb"
|
||||
exit 1;
|
||||
@ -3220,7 +3236,7 @@ shutdown_columnstore_mariadb_cmapi() {
|
||||
fi
|
||||
|
||||
if is_cmapi_installed ; then
|
||||
printf "%-${pf}s ... " " - Stopping CMAPI"
|
||||
printf "%-${print_formatting}s ... " " - Stopping CMAPI"
|
||||
if ! systemctl stop mariadb-columnstore-cmapi; then
|
||||
echo "[!!] Failed to stop CMAPI"
|
||||
exit 1;
|
||||
@ -3594,14 +3610,14 @@ process_localstorage_dbrm_restore() {
|
||||
|
||||
manually_run_loadbrm_and_savebrm() {
|
||||
|
||||
pf_offset=45
|
||||
printf "%-${pf_offset}s ... " " - Running load_brm"
|
||||
local print_formatting=45
|
||||
printf "%-${print_formatting}s ... " " - Running load_brm"
|
||||
if ! sudo -su mysql /usr/bin/load_brm /var/lib/columnstore/data1/systemFiles/dbrm/BRM_saves ; then
|
||||
printf "\n[!!] Failed to complete load_brm successfully\n\n"
|
||||
exit 1;
|
||||
fi;
|
||||
|
||||
printf "%-${pf_offset}s ... " " - Starting mcs-controllernode"
|
||||
printf "%-${print_formatting}s ... " " - Starting mcs-controllernode"
|
||||
if ! systemctl start mcs-controllernode ; then
|
||||
echo "[!!] Failed to start mcs-controllernode "
|
||||
exit 1;
|
||||
@ -3609,7 +3625,7 @@ manually_run_loadbrm_and_savebrm() {
|
||||
printf "Done\n"
|
||||
fi;
|
||||
|
||||
printf "%-${pf_offset}s ... " " - Confirming extent map readable"
|
||||
printf "%-${print_formatting}s ... " " - Confirming extent map readable"
|
||||
if ! editem -i >/dev/null ; then
|
||||
echo "[!!] Failed to run editem -i (read the EM)"
|
||||
exit 1;
|
||||
@ -3617,13 +3633,13 @@ manually_run_loadbrm_and_savebrm() {
|
||||
printf "Done\n"
|
||||
fi;
|
||||
|
||||
printf "%-${pf_offset}s ... \n" " - Running save_brm"
|
||||
printf "%-${print_formatting}s ... \n" " - Running save_brm"
|
||||
if ! sudo -u mysql /usr/bin/save_brm ; then
|
||||
echo "[!!] Failed to run save_brm"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
printf "%-${pf_offset}s ... " " - Stopping mcs-controllernode"
|
||||
printf "%-${print_formatting}s ... " " - Stopping mcs-controllernode"
|
||||
if ! systemctl stop mcs-controllernode; then
|
||||
echo "[!!] Failed to stop mcs-controllernode"
|
||||
exit 1;
|
||||
@ -3632,7 +3648,7 @@ manually_run_loadbrm_and_savebrm() {
|
||||
fi
|
||||
|
||||
if [ $storage == "S3" ]; then
|
||||
printf "%-${pf_offset}s ... " " - Stopping mcs-storagemanager"
|
||||
printf "%-${print_formatting}s ... " " - Stopping mcs-storagemanager"
|
||||
if ! systemctl stop mcs-storagemanager ; then
|
||||
echo "[!!] Failed to stop mcs-storagemanager "
|
||||
exit 1;
|
||||
@ -3641,7 +3657,7 @@ manually_run_loadbrm_and_savebrm() {
|
||||
fi
|
||||
fi;
|
||||
|
||||
printf "%-${pf_offset}s ... " " - clearShm"
|
||||
printf "%-${print_formatting}s ... " " - clearShm"
|
||||
clearShm
|
||||
printf "Done\n"
|
||||
sleep 2
|
||||
@ -3693,7 +3709,7 @@ case "$action" in
|
||||
'restore')
|
||||
process_restore "$@";
|
||||
;;
|
||||
'-v' | 'version' )
|
||||
'-v' | 'version' | '--version')
|
||||
print_mcs_bk_mgr_version_info
|
||||
;;
|
||||
'source' )
|
||||
|
Reference in New Issue
Block a user