Thank you for visiting the Rackspace Community
The The Community is live! Post new content or topics so our teams can assist.

Please contact your support team if you have a question or need assistance for any Rackspace products, services, or articles.

Rackspace DNS Export Import

Rackspace-DNS-Export-Import

LINK TO SCRIPT: https://github.com/thejollyroger1/Rackspace-DNS-Export-Import

The script provided above  will export (in bind9 format) a list of DNS IDs or a single ID if specified. Otherwise it will export all domains from the source cloud account to another Rackspace cloud account specified. Hopefully this helps anyone that needs it! If you have issues or unexpected errors with the script please create an issue on the github page.

***********************

Note: This is not an official Rackspace supported script. In the off and rare chance that this script deletes the domain and fails to import it Rackspace is not responsible. I made this script personally to try to reduce time spent waiting for Rackspace support to transfer domains or export them.

Note: It is very important when running a export import transfer that the email is formatted correctly. If it is not it will fail. The format is name.domain.com. or for example johnsmith.gmail.com.

***********************

Usage Example WITHOUT IMPORTING domains (will export in bind9 only, will not delete source):

python dns_export_import.py --srcddi <source ddi> --srcuser <source user> --srcapikey <source api key> --domainid <your domain id> --email <name.domain.com.>

Output:

Single domain ID detected, running script for just this domain ID : 1234567

Import option not used, printing Bind9 export below and quitting:

"domo123.com.\t\t300\tIN\tSOA\tns.rackspace.com. thejollyrogerx.me.com. 1496451048 21600 3600 1814400 300\ndomo123.com.\t\t300\tIN\tA\t192.168.2.1\ndomo123.com.\t\t300\tIN\tTXT\t\"herpderp\"\nmail.domo123.com.\t300\tIN\tMX\t10 domo123.com.\nmail2.domo123.com.\t300\tIN\tMX\t20 domo123.com.\nwww.domo123.com.\t300\tIN\tCNAME\tdomo123.com.\n"

Usage Example SPECIFYING specific domain FOR IMPORT AFTER EXPORT(will export, delete source, and import one domain specified):

python dns_export_import.py --dstddi <destination ddi> --dstuser <destination user> --dstapikey <destination api key> --srcddi <source ddi> --srcuser <source user> --srcapikey <source api key> --domainid <your domain id> --importdomains --email <name.domain.com.>

Output:

Single domain ID detected, running script for just this domain ID : 1234567

Preparing to remove domain ID : 1234567 from source account

Here is the raw json formated Bind9 output if the import fails and has to be manually retried via the API:

{"domains" : [ {"contentType" : "BIND_9", "contents" : "domo123.com.\t\t300\tIN\tSOA\tns.rackspace.com. thejollyrogerx.me.com. 1496451048 21600 3600 1814400 300\ndomo123.com.\t\t300\tIN\tA\t192.168.2.1\ndomo123.com.\t\t300\tIN\tTXT\t\"herpderp\"\nmail.domo123.com.\t300\tIN\tMX\t10 domo123.com.\nmail2.domo123.com.\t300\tIN\tMX\t20 domo123.com.\nwww.domo123.com.\t300\tIN\tCNAME\tdomo123.com.\n"} ]}

Domain removal successful, preparing to import domain to destination account

Import DNS response : {"request":"{\"domains\" : [ {\"contentType\" : \"BIND_9\", \"contents\" : \"domo123.com.\\t\\t300\\tIN\\tSOA\\tns.rackspace.com. thejollyrogerx.me.com. 1496451048 21600 3600 1814400 300\\ndomo123.com.\\t\\t300\\tIN\\tA\\t192.168.2.1\\ndomo123.com.\\t\\t300\\tIN\\tTXT\\t\\\"herpderp\\\"\\nmail.domo123.com.\\t300\\tIN\\tMX\\t10 domo123.com.\\nmail2.domo123.com.\\t300\\tIN\\tMX\\t20 domo123.com.\\nwww.domo123.com.\\t300\\tIN\\tCNAME\\tdomo123.com.\\n\"} ]}","status":"RUNNING","verb":"POST","jobId":"c9140bf7-2f5d-428d-ba7f-068a6585bc23","callbackUrl":"https://dns.api.rackspacecloud.com/v1.0/1234567/status/c9140bf7-2f5d-428d-ba7f-068a61234567","requestUrl":"https://dns.api.rackspacecloud.com/v1.0/1234567/domains/import"}

Import dns job URL : https://dns.api.rackspacecloud.com/v1.0/1234567/status/c9140bf7-2f5d-428d-ba7f-068a61234567?showDetails=true

Import Job Output: {"request":"{\"domains\" : [ {\"contentType\" : \"BIND_9\", \"contents\" : \"domo123.com.\\t\\t300\\tIN\\tSOA\\tns.rackspace.com. thejollyrogerx.me.com. 1496451048 21600 3600 1814400 300\\ndomo123.com.\\t\\t300\\tIN\\tA\\t192.168.2.1\\ndomo123.com.\\t\\t300\\tIN\\tTXT\\t\\\"herpderp\\\"\\nmail.domo123.com.\\t300\\tIN\\tMX\\t10 domo123.com.\\nmail2.domo123.com.\\t300\\tIN\\tMX\\t20 domo123.com.\\nwww.domo123.com.\\t300\\tIN\\tCNAME\\tdomo123.com.\\n\"} ]}","status":"COMPLETED","response":{"domains":[{"name":"domo123.com","id":5733115,"accountId":1234567,"ttl":300,"recordsList":{"records":[{"name":"domo123.com","id":"A-20405173","type":"A","data":"192.168.2.1","ttl":300,"updated":"2017-06-22T23:14:15.000+0000","created":"2017-06-22T23:14:15.000+0000"},{"name":"domo123.com","id":"TXT-1421743","type":"TXT","data":"herpderp","ttl":300,"updated":"2017-06-22T23:14:15.000+0000","created":"2017-06-22T23:14:15.000+0000"},{"name":"mail.domo123.com","id":"MX-6614785","priority":10,"type":"MX","data":"domo123.com","ttl":300,"updated":"2017-06-22T23:14:16.000+0000","created":"2017-06-22T23:14:16.000+0000"},{"name":"mail2.domo123.com","id":"MX-6614788","priority":20,"type":"MX","data":"domo123.com","ttl":300,"updated":"2017-06-22T23:14:16.000+0000","created":"2017-06-22T23:14:16.000+0000"},{"name":"www.domo123.com","id":"CNAME-15849958","type":"CNAME","data":"domo123.com","ttl":300,"updated":"2017-06-22T23:14:16.000+0000","created":"2017-06-22T23:14:16.000+0000"}]},"nameservers":[{"name":"dns1.stabletransit.com"},{"name":"dns2.stabletransit.com"}],"emailAddress":"thejollyrogerx@me.com","updated":"2017-06-22T23:14:14.000+0000","created":"2017-06-22T23:14:14.000+0000"}]},"verb":"POST","jobId":"c9140bf7-2f5d-428d-ba7f-068a6585bc23","callbackUrl":"https://dns.api.rackspacecloud.com/v1.0/1234567/status/c9140bf7-2f5d-428d-ba7f-068a61234567","requestUrl":"https://dns.api.rackspacecloud.com/v1.0/1234567/domains/import"}

Import appears to have been successful for domain ID : 1234567

For the sake of space on this article I won't post the output for the next commands. They look the same but loop through the file or all domains on the account.

Usage Example WITH FILE and import (will export, delete source, and import domains inside file):

python dns_export_import.py --dstddi <destination ddi> --dstuser <destination user> --dstapikey <destination api key> --srcddi <source ddi> --srcuser <source user> --srcapikey <source api key> --dnsidfile </path/to/file> --importdomains --email <name.domain.com.>

Real Example WITHOUT FILE (will export, delete source, and import all domains):

python dns_export_import.py --dstddi 123456 --dstuser bob1 --dstapikey zcf0ec12d0df4deb9de9e00a47c5113c --srcddi 654321 --srcuser bob2 --srcapikey a755bbe91fbd4629995eeddb8b072d4z --importdomains --email johnsmith.gmail.com.

***The DNS ID file must follow this format***

123456
456789
789456

Sincerely,

Sean