Skip to content

Instantly share code, notes, and snippets.

@sdellenb
Created January 20, 2021 16:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sdellenb/299400b7aadc17c2a49d502ecc1f5d7d to your computer and use it in GitHub Desktop.
Save sdellenb/299400b7aadc17c2a49d502ecc1f5d7d to your computer and use it in GitHub Desktop.
Archive Netcup DNS zones to git
#!/usr/bin/env bash
set -Eeo pipefail
if [[ "$#" -ne 1 || ! ( "$1" == *ncdapi.sh) ]]
then
echo "Usage: $0 /path/to/ncdapi.sh"
exit 1
fi
declare -a zones=("example.com" "example.de" "example.org")
for zone in "${zones[@]}"
do
printf 'Backing up zone %s...\n' "${zone}"
bash "$1" -b "${zone}"
mv -v backup-${zone}-*.txt "${zone}.json"
git add "${zone}.json"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment