Last active
August 20, 2021 10:02
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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