Could we help you? Please click the banners. We are young and desperately need the money
It might happen that the BuddyNS zonedata is out of sync with your local system or that you would like to clean BuddyNS zone data from unused domains. We've created a script which automates this procedure. It does the following:
Please use at your own risk! We tested it several times and it worked nicely on our Debian server.
#! /bin/bash MASTER_NS=IP.OF.YOUR-MASTER.DNS PATH_TO_BIND_CONFIG_FILES=/etc/bind TOKEN="Enter Your BuddyNS Token Here. Go to BuddyNS account settings to generate one" if [ -z "$1" ] ; then echo "This script removes ALL ZONES from BuddyNS secondary nameserver, fetches a list of all zones currently set up on the MASTER, recreates all these zones on BuddyNS and resyncs zone data - be careful!!!:" echo "Syntax: $0 ok_go4it" echo "" exit 1 else if [ "$1" = "ok_go4it" ]; then ### Fetch a list of all zones on BuddyNS declare -a arr_buddyns_zonenames="($(curl -ss -H 'Authorization: Token ${TOKEN}' -XGET https://www.buddyns.com/api/v2/zone/ | jq '.[].name_idn' -r))" ### Iterate through that list and delete every single entry for currentzonename in ${arr_buddyns_zonenames[@]}; do ### Remove DNS entry from BuddyNS list echo "Deleting zone from BuddyNS: ${currentzonename}..." curl -ss -H "Authorization: Token ${TOKEN}" -XDELETE https://www.buddyns.com/api/v2/zone/${currentzonename} |jq ".[]" done ### Fetching a list of all Bind DNS master zones from the DNS master... declare -a arr_masterns_zonenames="($(ls ${PATH_TO_BIND_CONFIG_FILES}/*.hosts | while read zf; do basename $zf .hosts ; done))" ### Iterate through that list and add every single entry on BuddyNS for currentzonename in ${arr_masterns_zonenames[@]}; do ### Remove DNS entry from BuddyNS list echo "Adding zone to BuddyNS: ${currentzonename}..." curl -ss -H "Authorization: Token ${TOKEN}" -XPOST -F "name=${currentzonename}" -F "master=$MASTER_NS" https://www.buddyns.com/api/v2/zone/ |jq ".[]" done ### Force sync of all zone files NOW echo "Forcing immediate RESYNC of all zones ..." curl -ss -H "Authorization: Token ${TOKEN}" -XGET https://www.buddyns.com/api/v2/sync/ |jq ".[]" fi fi