From: Frank Brehm Date: Thu, 16 Nov 2017 15:04:26 +0000 (+0100) Subject: Adding retrieving zones X-Git-Tag: 0.1.2~72 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=bef55d19ff420f1c5ec38da256960e4442513650;p=pixelpark%2Fadmin-tools.git Adding retrieving zones --- diff --git a/bin/backup-pdns-global.sh b/bin/backup-pdns-global.sh index ed711a6..860d3fb 100755 --- a/bin/backup-pdns-global.sh +++ b/bin/backup-pdns-global.sh @@ -3,14 +3,14 @@ set -e set -u -export LC_ALL=C -export LANG=C +export LC_ALL="en_US.utf8" +export LANG="en_US.utf8" VERBOSE="n" DEBUG="n" QUIET='n' -VERSION="1.0" +VERSION="1.1" # console colors: RED="" @@ -20,11 +20,12 @@ BLUE="" NORMAL="" HAS_TTY='y' +HAS_COLORS="n" BASENAME="$(basename ${0})" BASE_DIR="$(dirname ${0})" -declare -a DATABASES=() +declare -a ZONES=() ######################################################### # Modify below variables to fit your need ---- @@ -65,6 +66,7 @@ detect_color() { GREEN="\033[38;5;46m" BLUE="\033[38;5;27m" NORMAL="\033[39m" + HAS_COLORS="y" else RED="" YELLOW="" @@ -160,6 +162,7 @@ get_options() { GREEN="" BLUE="" NORMAL="" + HAS_COLORS="n" shift ;; --nocolor) @@ -168,6 +171,7 @@ get_options() { GREEN="" BLUE="" NORMAL="" + HAS_COLORS="n" shift ;; -h|--help) @@ -389,6 +393,37 @@ cleanup_old_backups() { } +#------------------------------------------------------------------------------ +get_zones() { + + local no_color_option="" + if [[ "${HAS_COLORS}" == "n" ]] ; then + no_color_option="--color no" + fi + + if [[ ! -x ./pdns-list-zones ]] ; then + error "Script '${RED}${BASE_DIR}/pdns-list-zones${NORMAL}' not found." + exit 5 + fi + + local zone= + for zone in $( ./pdns-list-zones ${no_color_option} --global --quiet | \ + tail -n +3 | awk '{print $1}' ) ; do + ZONES+=( "${zone}" ) + done + + if [[ "${VERBOSE}" == "y" ]] ; then + echo + echo "Zones to backup:" + for zone in "${ZONES[@]}" ; do + echo " * '${zone}'" + done + echo + fi + + +} + #------------------------------------------------------------------------------ backup_databases() { @@ -476,7 +511,7 @@ main() { prepare_dirs info "Starting backup ..." cleanup_old_backups - #get_databases + get_zones #backup_databases empty_line