Answers:
是的,它可以是更友好的方式。我建议使用cli53工具,https://github.com/barnybug/cli53
设置完后,只需尝试
cli53出口-完整sciworth.com
然后您将获得绑定格式的导出区域。
无需额外的软件安装。您只需要awscli。
这是我刚刚写的。它很简单,就像魅力。
#!/bin/bash -e
#
# Author: Peycho Dimitrov
#
# DESCRIPTION
#
# Create full backup of all hosted Route53 zones / domains in your account.
#
# REQUIREMENTS
#
# Available s3 bucket (where your json files will be saved)
# awscli (with cofigured credentials or IAM role)
# gzip
# awk
#
####################################
# CONFIGURATION
region="us-east-1" # Your aws region
b_route53_tmp="/tmp/r53_backup" # Your temp directory
b_route53_bucket="s3://my-backups/route53" # Your backup folder in s3.
# END OF CONFIGURATION
# Do not edit here if you don't know what your're doing! #
mkdir -p $b_route53_tmp
echo "$(date) Backup all Route53 zones and resource records."
p_aws="$(which aws) --region $region"
r53_zones=$($p_aws route53 list-hosted-zones --query '[HostedZones[*].[Id, Name]]' --output text | awk -F'/' '{print $3}')
if [ ! -z "$r53_zones" ]; then
while read route; do
zone=$(echo "$route" | awk '{print $1}')
domain=$(echo "$route" | awk '{print $2}')
echo "Processing $zone / $domain"
$p_aws route53 list-resource-record-sets --hosted-zone-id "$zone" --output json > "$b_route53_tmp"/$(date +%Y%m%d%H%M%S)-"$zone"-"$domain"backup.json
done <<<"$r53_zones"
echo "Archive json files."
gzip "$b_route53_tmp"/*backup.json
echo "Backup $zone / $domain data to $b_route53_bucket/$(date +%Y)/$(date +%m)/$(date +%d)/"
$p_aws s3 cp "$b_route53_tmp"/ $b_route53_bucket/$(date +%Y)/$(date +%m)/$(date +%d)/ --exclude "*" --include "*.gz" --recursive
fi
echo "$(date) Done!"
如果要导出绑定格式,可以使用以下脚本:
#!/bin/bash
zonename=$1
hostedzoneid=$(aws route53 list-hosted-zones | jq -r ".HostedZones[] | select(.Name == \"$zonename.\") | .Id" | cut -d'/' -f3)
aws route53 list-resource-record-sets --hosted-zone-id $hostedzoneid --output json | jq -jr '.ResourceRecordSets[] | "\(.Name) \t\(.TTL) \t\(.Type) \t\(.ResourceRecords[].Value)\n"'
要在AWS Route 53中导出托管区域,请执行以下步骤(假设您使用的是example.com托管区域):
步骤1:安装– pip install route53-transfer
步骤2:将区域备份到CSV文件:
route53-transfer dump example.com backup.csv
使用STDOUT代替文件
route53-transfer dump example.com –
步骤3:还原区域:
route53-transfer load example.com backup.csv
用于-
从STDIN加载
在帐户之间迁移:
使用命令行开关覆盖访问密钥和秘密密钥:
route53-transfer --access-key-id=ACCOUNT1 --secret-key=SECRET dump example.com
route53-transfer --access-key-id=ACCOUNT2 --secret-key=SECRET load example.com
如果您正在使用私有区域,请使用–private
来区分私有域:
route53-transfer --private dump example.com example-private.csv
route53-transfer dump example.com example-public.csv