I recently had to export all Route53 DNS entries, just to do some cleanup of them. I was surprised that there is no “official” way to export them all from the AWS console!
I found the cli53 tool, but it doesn’t do exactly what I need.
So, I decided to write my own powershell script. I share it with you, I hope it may help!
Feel free to send me your suggestions to make it better!
$zones = Get-R53HostedZoneList | select name,id,ResourceRecordSetCount | sort -Property name
foreach ($zone in $zones) {
[string]::Format(“[{0}] [{1}] ({2})”,$zone.Name, $zone.Id, $zone.ResourceRecordSetCount)
$recordsets = Get-R53ResourceRecordSet -HostedZoneId $zone.id
$recordsets = $recordsets.ResourceRecordSets | sort -Property type # | where type -EQ 'a'
foreach ($rs in $recordsets){
[string]::Format(“`n[{0}] [{1}] ({2})”,$rs.type, $rs.name, $rs.ResourceRecords.Count)
foreach ($record in $rs.ResourceRecords){
[string]::Format(" {0}", $record.Value)
}
}
"`n-----------------------------`n"
}
Thanks! The cli53 tool is nice but I love my PowerShell!
Will this create a Zone File, that can be used to import into Route 53. Would love to use this as a DR backup in the event of a lost RT53 HostedZone.
Reference:
https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-creating-import.html
Here is something I use for backing up the Route 53 Entries to a JSON file.
This was originally from: https://arindamhazra.com/backup-aws-r53-dns-record-in-azure-blob/
And I altered it to fit my needs, which is to back up to individual JSON files for each HostedZone.
https://gist.github.com/Rugby-Ball/951e5bc7399de4b2256b2f74a3da6396#file-rt53-hosted-zone-entries-backup.ps1