diff --git a/functions.sh b/functions.sh index 341d106..02d0237 100644 --- a/functions.sh +++ b/functions.sh @@ -37,6 +37,13 @@ ensure_pwd_is_scriptdir () { fi } +# ok if current user is the same (name) as script directory +ensure_scriptdir_equals_user () { + if [[ "$USER" != "${ABSDIR##*/}" ]]; then + exit 1 + fi +} + # make sure systemd directory exists ensure_systemd_as_user_dir_exists () { [[ -d ${HOME}/.config/systemd/user/ ]] || mkdir -p ${HOME}/.config/systemd/user/ diff --git a/podman-wpamapsta/60_db_dump.sh b/podman-wpamapsta/60_db_dump.sh new file mode 100755 index 0000000..0501353 --- /dev/null +++ b/podman-wpamapsta/60_db_dump.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +ABSDIR="$( dirname "$(readlink -f -- "$0")" )" +source ${ABSDIR}/../functions.sh +source ${ABSDIR}/vars.sh + +ensure_not_root +ensure_scriptdir_equals_user + +# pod should exist +ensure_pod_exists "${pod_name}" + +podman exec db /bin/bash -c '/usr/bin/mysqldump --user=${MARIADB_USER} --password=${MARIADB_PASSWORD} --all-databases'