forked from evolix/ansible-roles
evolinux-base: backup-server-state: rename options and use mysqladmin instead of mysql
This commit is contained in:
parent
519228ff9f
commit
88cd8a0976
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
PROGNAME="backup-server-state"
|
PROGNAME="backup-server-state"
|
||||||
|
|
||||||
VERSION="22.01.1"
|
VERSION="22.01.2"
|
||||||
readonly VERSION
|
readonly VERSION
|
||||||
|
|
||||||
backup_dir=
|
backup_dir=
|
||||||
|
@ -204,7 +204,7 @@ backup_dpkg_full() {
|
||||||
rsync_bin=$(command -v rsync)
|
rsync_bin=$(command -v rsync)
|
||||||
|
|
||||||
if [ -n "${rsync_bin}" ]; then
|
if [ -n "${rsync_bin}" ]; then
|
||||||
last_result=$(${rsync_bin} -ah --itemize-changes --exclude='*-old' ${dpkg_dir}/ "${backup_dir}${dpkg_dir}/")
|
last_result=$(${rsync_bin} -ah --itemize-changes --exclude='*-old' "${dpkg_dir}/" "${backup_dir}${dpkg_dir}/")
|
||||||
last_rc=$?
|
last_rc=$?
|
||||||
|
|
||||||
if [ ${last_rc} -eq 0 ]; then
|
if [ ${last_rc} -eq 0 ]; then
|
||||||
|
@ -653,41 +653,40 @@ backup_dmesg() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
backup_mysql() {
|
backup_mysql_processes() {
|
||||||
debug "Backup mysql processes"
|
debug "Backup mysql processes"
|
||||||
|
|
||||||
mysql_bin=$(command -v mysql)
|
mysqladmin_bin=$(command -v mysqladmin)
|
||||||
|
|
||||||
if [ -n "${mysql_bin}" ]; then
|
if [ -n "${mysqladmin_bin}" ]; then
|
||||||
last_result=$(${mysql_bin} --execute 'show full processlist;' > "${backup_dir}/mysql.txt")
|
last_result=$(${mysqladmin_bin} --verbose processlist > "${backup_dir}/mysql-processlist.txt")
|
||||||
last_rc=$?
|
last_rc=$?
|
||||||
|
|
||||||
if [ ${last_rc} -eq 0 ]; then
|
if [ ${last_rc} -eq 0 ]; then
|
||||||
debug "* mysql OK"
|
debug "* mysqladmin OK"
|
||||||
else
|
else
|
||||||
debug "* mysql ERROR"
|
debug "* mysqladmin ERROR"
|
||||||
debug "${last_result}"
|
debug "${last_result}"
|
||||||
rc=10
|
rc=10
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
debug "* mysql not found"
|
debug "* mysqladmin not found"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
backup_services() {
|
backup_systemctl() {
|
||||||
debug "Backup services"
|
debug "Backup services"
|
||||||
|
|
||||||
systemctl_bin=$(command -v systemctl)
|
systemctl_bin=$(command -v systemctl)
|
||||||
|
|
||||||
if [ -n "${systemctl_bin}" ]; then
|
if [ -n "${systemctl_bin}" ]; then
|
||||||
last_result=$(${systemctl_bin} systemctl --no-legend --state=failed \
|
last_result=$(${systemctl_bin} systemctl --no-legend --state=failed --type=service > "${backup_dir}/systemctl-failed-services.txt")
|
||||||
--type=service > "${backup_dir}/services.txt")
|
|
||||||
last_rc=$?
|
last_rc=$?
|
||||||
|
|
||||||
if [ ${last_rc} -eq 0 ]; then
|
if [ ${last_rc} -eq 0 ]; then
|
||||||
debug "* services OK"
|
debug "* failed services OK"
|
||||||
else
|
else
|
||||||
debug "* services ERROR"
|
debug "* failed services ERROR"
|
||||||
debug "${last_result}"
|
debug "${last_result}"
|
||||||
rc=10
|
rc=10
|
||||||
fi
|
fi
|
||||||
|
@ -767,11 +766,11 @@ main() {
|
||||||
if [ "${DO_DMESG}" -eq 1 ]; then
|
if [ "${DO_DMESG}" -eq 1 ]; then
|
||||||
backup_dmesg
|
backup_dmesg
|
||||||
fi
|
fi
|
||||||
if [ "${DO_MYSQL}" -eq 1 ]; then
|
if [ "${DO_MYSQL_PROCESSES}" -eq 1 ]; then
|
||||||
backup_mysql
|
backup_mysql_processes
|
||||||
fi
|
fi
|
||||||
if [ "${DO_SERVICES}" -eq 1 ]; then
|
if [ "${DO_SYSTEMCTL}" -eq 1 ]; then
|
||||||
backup_services
|
backup_systemctl
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
@ -948,18 +947,18 @@ while :; do
|
||||||
DO_DMESG=0
|
DO_DMESG=0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--mysql)
|
--mysql-processes)
|
||||||
DO_MYSQL=1
|
DO_MYSQL_PROCESSES=1
|
||||||
;;
|
;;
|
||||||
--no-mysql)
|
--no-mysql-processes)
|
||||||
DO_MYSQL=0
|
DO_MYSQL_PROCESSES=0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--services)
|
--systemctl)
|
||||||
DO_SERVICES=1
|
DO_SYSTEMCTL=1
|
||||||
;;
|
;;
|
||||||
--no-services)
|
--no-systemctl)
|
||||||
DO_SERVICES=0
|
DO_SYSTEMCTL=0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--)
|
--)
|
||||||
|
@ -1002,8 +1001,8 @@ done
|
||||||
: "${DO_MOUNT:=1}"
|
: "${DO_MOUNT:=1}"
|
||||||
: "${DO_DF:=1}"
|
: "${DO_DF:=1}"
|
||||||
: "${DO_DMESG:=1}"
|
: "${DO_DMESG:=1}"
|
||||||
: "${DO_MYSQL:=1}"
|
: "${DO_MYSQL_PROCESSES:=1}"
|
||||||
: "${DO_SERVICES:=1}"
|
: "${DO_SYSTEMCTL:=1}"
|
||||||
|
|
||||||
export LC_ALL=C
|
export LC_ALL=C
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue