• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Import and Export DNS zone files

WimPlesk

New Pleskian
Hi,

Does anyone know how I can export DNS zone files from a running Plesk 11.5 server.
(It is a DNS master with a 4PSA slave)

I want to export those zones so that I can import in another Plesk server and after that
I want to change the NS servers so that there is no downtime. After this I want to migrate.
This because I need to change every record manualy because our servers behind NAT.

Best regards,
 
Not sure that it is easy or even possible.

You try to can write some script like

# for i in `mysql -uadmin -p\`cat /etc/psa/.psa.shadow\` psa -Ns -e "select name from domains"`; do /usr/local/psa/bin/dns --info $i; done > list.txt

and then modify list.txt file as you want. But I haven't got a clue about import procedure.

I think that simple Plesk migration with modification zones on destination server would be more effective method.
Also look at API RPC method. Something like

<packet version="1.6.3.0">
<dns>
<get_rec>
<filter>
<site-id>1</site-id>
</filter>
</get_rec>
</dns>
</packet>

More details - http://download1.parallels.net/Plesk/PP10/10.1.1/Doc/en-US/online/plesk-api-rpc/34841.htm
 
Last edited:
Below is a script that will export the DNS records for a domain within Plesk. You could run this against all your domains to generate the commands needed to import the DNS info on the new server. It's easily adaptable to issue the domain creation commands as well. Script was originally provided by Parallels but hacked up (dirtyly, by me) to fix TXT records (dns utility has a bug that cannot accept ; in TXT records when using the -list command) and also SRV records which have multiple parameters stored in one field in the PSA database.

YMMV - good luck!

Code:
#!/bin/bash
if [ -z "$1" ] ; then
	echo "Usage: $0 <domain_name>"
	exit 1
fi

export domain_name
printf "/usr/local/psa/bin/dns --set $domain_name -list \'"

while IFS=\| read type host val opt ; do
	host=${host%%$domain_name.}
	host=${host%%.}

	case "$type" in
		"A"|"NS"|"CNAME")
			printf "%s,%s,%s;" "$type" "$host" "$val"
			;;
		"MX")
			printf "%s,%s,%s,%s;" "$type" "$host" "$val" "$opt"
			;;
		"PTR")
			# ignore PTR records
			;;
		"TXT")
			txt_r+="/usr/local/psa/bin/dns --add $domain_name -txt '$val' -domain '$host'\n"
			;;
		"SRV")
			# SRV
		        serv=`echo $host|cut -f1 -d'.'`
		        serv=${serv##_}
		        t_host=${val%%.}
		        proto=`echo $host|cut -f2 -d'.'`
		        proto=${proto##_}
		        sub=`echo $host|cut -f3 -d'.'`
		        sub=${sub%% }
		        if [ -z "$sub" ]; then
		                sub=\'\'
		        fi
			prio=`echo $opt|cut -f1 -d' '`
		        weig=`echo $opt|cut -f2 -d' '`
		        port=`echo $opt|cut -f3 -d' '`
		        srv_r+="/usr/local/psa/bin/dns --add $domain_name -srv $sub -srv-priority $prio -srv-weight $weig -srv-port $port -srv-target-host $t_host -srv-protocol $proto -srv-service $serv\n"
			;;
		*)
			echo "Unknown type of record: $type" >&2
			exit
			;;
	esac
done< <( echo "SELECT CONCAT_WS('|', type, host, val, opt) FROM dns_recs WHERE dns_zone_id = (SELECT id FROM dns_zone WHERE name = '$domain_name')" | mysql -Ns -uadmin -p`cat /etc/psa/.psa.shadow` -Dpsa )

printf "\'\n"
if [ -n "$srv_r" ]; then
	echo -e ${srv_r%%\\n}
fi
if [ -n "$txt_r" ]; then
	echo -e ${txt_r%%\\n}
fi
 
Hi Tim,

But I have more than 200 domains at one server, is it also possible with this script to select all the domains?

Best regards,
 
Code:
for i in `mysql -uadmin -p\`cat /etc/psa/.psa.shadow\` psa -Ns -e "select name from domains"`; do echo $i; done >> /tmp/dom_list

...

Code:
for i in `cat /tmp/dom_list`; do ./the_script_from_above.sh $i; done >> /tmp/exported_dns_commands
 
Code:
for i in `mysql -uadmin -p\`cat /etc/psa/.psa.shadow\` psa -Ns -e "select name from domains"`; do echo $i; done >> /tmp/dom_list

...

Code:
for i in `cat /tmp/dom_list`; do ./the_script_from_above.sh $i; done >> /tmp/exported_dns_commands

Hi Tim,

Sorry, but I doesn't have so much script knowledge but where must I put this rule?
 
Hi Tim,

Did you if there also a script the can change by bulk DNS.
And then not the main IP because our servers behind NAT.

A script like this changed the main IP and the DNS, but the main IP needs to be the internal IP only the DNS needs to be changed.
Hope you can help me.

mysql -Ns -uadmin -p`cat /etc/psa/.psa.shadow` -D psa -e 'select name from domains' | awk '{print "/usr/local/psa/bin/domain --update " $1 " -ip 000.000.000.000 "}' | sh

Script above change only the main IP's.

Best regards,
 
Back
Top