You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
1.5 KiB
82 lines
1.5 KiB
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
usage() {
|
|
cat - <<__USAGE__
|
|
$(basename "$0") used to compare mysql schemes between two hosts.
|
|
|
|
Usage: $(basename "$0") [options]
|
|
|
|
Options:
|
|
|
|
--formatter=[tap] - Specify the output format.
|
|
Skip it to get human readable output.
|
|
|
|
-h|--help - Show this message.
|
|
|
|
__USAGE__
|
|
}
|
|
|
|
FORMATTER=''
|
|
HOST1=''
|
|
HOST2=''
|
|
|
|
args=$(getopt -n "$(basename "$0")" -o h -l help,formatter:,host1:,host2: -- "$@")
|
|
eval set -- "${args}"
|
|
while true; do
|
|
case "${1}" in
|
|
--formatter)
|
|
FORMATTER="${2}"
|
|
shift 2
|
|
;;
|
|
--host1)
|
|
HOST1="${2}"
|
|
shift 2
|
|
;;
|
|
--host2)
|
|
HOST2="${2}"
|
|
shift 2
|
|
;;
|
|
-h|--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
--)
|
|
shift
|
|
break
|
|
;;
|
|
*)
|
|
log_error "Unknown parameter '${1}'"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
DB_BACKUP_LIST='/etc/ngcp-backup-tools/db-backup.conf'
|
|
if [[ ! -r "${DB_BACKUP_LIST}" ]]; then
|
|
echo "Cannot read mandatory config file ${DB_BACKUP_LIST}" 2>&1
|
|
exit 1
|
|
fi
|
|
|
|
MYSQL_CREDENTIALS='/etc/mysql/sipwise_extra.cnf'
|
|
if [[ ! -r "${MYSQL_CREDENTIALS}" ]]; then
|
|
echo "Cannot read mandatory config file '${MYSQL_CREDENTIALS}'" 2>&1
|
|
exit 1
|
|
fi
|
|
|
|
. "${DB_BACKUP_LIST}"
|
|
declare -a opts
|
|
if [[ -n "${FORMATTER}" ]]; then
|
|
opts+=(--formatter="${FORMATTER}")
|
|
fi
|
|
if [[ -n "${HOST1}" ]]; then
|
|
opts+=(--host_db1="${HOST1}")
|
|
fi
|
|
if [[ -n "${HOST2}" ]]; then
|
|
opts+=(--host_db2="${HOST2}")
|
|
fi
|
|
/usr/share/ngcp-system-tests/compare_dbs.pl \
|
|
--schemes="${NGCP_DB_BACKUP_FINAL_LIST[*]}" \
|
|
"${opts[@]}" || true
|