Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@edupr91
Last active August 20, 2021 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edupr91/651a30d8203b00b4ddd6e9d098793055 to your computer and use it in GitHub Desktop.
Save edupr91/651a30d8203b00b4ddd6e9d098793055 to your computer and use it in GitHub Desktop.
dummy script to dump aws route53 zones. Also let you pick one single domain to dump.
#!/bin/bash
set -e
# Before using this script check that you have configured your credentials and
# you are logged in to the right aws account.
# try running `aws configure list` to list all your configuration data
# You will also need to install cli53. https://github.com/barnybug/cli53
# Download the latest and move it to your local bin folder https://github.com/barnybug/cli53/releases/latest
# mv cli53-linux-amd64 ~/.local/bin/cli53
# chmod u+x ~/.local/bin/cli53
usage() { echo "Usage: $0 [-d <domain to dump>] [-p <backup_dir_path>]" 1>&2; exit 1; }
while getopts ":d:p:" o; do
case "${o}" in
d)
domain=${OPTARG}
;;
p)
backup_path=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z $backup_path ];then
BACKUP_DIR=$PWD/route53-backup
else
BACKUP_DIR=$backup_path
fi
if [ ! -d $BACKUP_DIR ]; then mkdir $BACKUP_DIR; fi
if [ -z $domain ]; then
hosted_zones=$(cli53 list | sed 1d | awk '{print $2}')
for zone in $hosted_zones; do
echo "Backing up zone $zone"
cli53 export $zone > $BACKUP_DIR/$zone
done
else
echo "Backing up zone $domain"
cli53 export $domain > $BACKUP_DIR/$domain
fi
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment