AWS – Backup All Amazon Route53 Zones (Single Domain)

July 30, 2020

Recently I needed to backup all of our Amazon Route53 Zones for a single domain.

Here is a script I put together

#!/bin/bash # # Original script written by Tomas ( # Modified by Steve Stonebraker ( BACKUP_PATH="/tmp/zones" ZONES_FILE="all-zones.bak" DNS_FILE="all-dns.bak" mkdir -p "$BACKUP_PATH" 2> /dev/null cd "$BACKUP_PATH" # get a list of all hosted zones cli53 list > "$ZONES_FILE" 2>&1 # get a list of domain names only awk '{ print $1 }' "$ZONES_FILE" > "$DNS_FILE" # create backup files for each domain while read -r line; do cli53 export --full "$line" > "$line.bak" done < "$DNS_FILE" # create an archive to put on S3 tar cvfz "$BACKUP_PATH.tgz" "$BACKUP_PATH" exit 0
Code language: Bash (bash)