How to Export and Import a DNS Zone File (Without Downtime)
Moving a domain to a new registrar, switching nameservers, or just want a backup of every DNS record before you start editing? A DNS zone file is the fastest way to move dozens of records at once instead of retyping them one by one. Here's how to export one cleanly, read it, and import it back without breaking mail or your site.
What a Zone File Actually Is
A zone file is a plain-text file in BIND format that lists every DNS record for a domain: A, AAAA, CNAME, MX, TXT, SRV, NS, all of it. Every DNS server, from cPanel's built-in nameservers to Cloudflare to your registrar's control panel, can read and write this format because it's an actual internet standard (RFC 1035), not a proprietary export.
That's what makes it useful. You can export a zone from one host and import it into a completely different platform, and the records land correctly, TTLs and all, as long as you don't leave broken syntax behind.
When You'd Actually Need to Do This
- Switching nameservers. Moving from your registrar's DNS to Cloudflare, or from Cloudflare to cPanel's DNS. You need every record captured before the switch, or things like SPF/DKIM silently vanish and mail starts failing.
- Before bulk-editing records. If you're about to touch 15 TXT records for a new email provider, export first. It's your rollback plan.
- Migrating a domain between cPanel servers. WHM's transfer tool moves accounts, but if the domain's DNS is hosted separately, you often need the zone file moved on its own.
- Rebuilding after a mistake. Someone deleted the MX records by accident. If you exported the zone last month, you paste it back and you're done in two minutes instead of reconstructing everything from memory.
Exporting a Zone File From cPanel
If your domain's DNS is hosted on cPanel/WHM (not just your website, the actual DNS):
- Log in to WHM as root or reseller (this isn't in the customer-facing cPanel — it's a server-admin action).
- Go to DNS Functions → Edit DNS Zone, select the domain, and you'll see the raw zone data in a text box.
- Alternatively, use DNS Functions → Dump DNS Zone for a clean, downloadable copy without the editor chrome around it.
- Copy everything, or use the download option if your WHM version has one, and save it as
yourdomain.com.zone.
No WHM access, only regular cPanel? You won't find a zone file export button there, because cPanel's Zone Editor only lets you view and edit individual records, not dump the whole file. In that case, export records manually from Zone Editor, or ask your host for a WHM-level export, or use dig from your own machine (see below) to reconstruct what's live.
Pulling a Zone From the Command Line (Any Host)
If you don't have panel access, or you just want a quick snapshot of what's actually resolving right now, dig works from any Linux/macOS terminal or WSL:
for type in A AAAA CNAME MX TXT NS SRV CAA; do
dig yourdomain.com $type +noall +answer
done > yourdomain-snapshot.txt
This isn't a true zone file (it's missing SOA serial internals and won't import directly into every panel), but it's an accurate, dated record of what's live, and it's often enough to manually rebuild records if you're in a hurry and the real export isn't available.
Reading the File Before You Trust It
A typical entry looks like this:
yourdomain.com. 14400 IN A 203.0.113.10
www.yourdomain.com. 14400 IN CNAME yourdomain.com.
yourdomain.com. 14400 IN MX 10 mail.yourdomain.com.
yourdomain.com. 3600 IN TXT "v=spf1 include:_spf.google.com ~all"
_dmarc.yourdomain.com. 3600 IN TXT "v=DMARC1; p=none;"
A few things worth knowing before you touch this:
- Trailing dots matter.
yourdomain.com.with the dot at the end means "fully qualified, stop here." Drop the dot on some panels and it gets silently appended to the domain again, e.g.mail.yourdomain.com.yourdomain.com. - The number after the hostname is the TTL in seconds. 14400 = 4 hours. Lower it to 300 (5 minutes) on records you're about to change, so a mistake doesn't linger for hours.
- The SOA record has a serial number that must increase every time the zone changes, or some secondary/slave DNS servers won't pick up the update at all. Most panels bump this automatically on import; a few don't. If records aren't propagating anywhere after an import, check the SOA serial first.
- TXT records with quotes need the quotes preserved exactly. A stripped or doubled quote is the single most common reason SPF or DKIM breaks after a zone import.
Importing the Zone Into a New Host
Into WHM/cPanel: DNS Functions → Edit DNS Zone → select the domain (or create it fresh under Add a DNS Zone) → paste the full contents into the raw zone box → Save. WHM will flag syntax errors on save rather than accepting broken data silently, which is the main safety net here.
Into Cloudflare: DNS → Records → Import and Export → upload the .zone file directly. Cloudflare parses standard BIND format natively and shows you a preview of every record before you commit, so you can catch anything that looks wrong before it goes live.
Into another registrar's DNS panel: Most don't accept raw zone file uploads. You'll need to re-enter records manually using the zone file as your reference sheet, which is tedious but far less error-prone than trying to remember 20 TXT records from memory.
The Cutover Sequence That Avoids Downtime
The zone file itself is safe. What causes outages is the order you do things in:
- Export and save the current zone first. Always, even if you're confident nothing will go wrong.
- Import into the new location while the old one is still live. Don't point nameservers at the new host until you've confirmed every record landed correctly there.
- Verify with
digagainst the new host's nameservers directly, before switching anything:dig @ns1.newhost.com yourdomain.com MX - Lower the domain's TTL to 300 seconds a day ahead if you can plan the migration, so the eventual nameserver switch propagates fast instead of taking the old 24-48 hour worst case.
- Only then switch nameservers at the registrar, and keep the old DNS host's zone active and untouched for at least 48 hours as a fallback.
Common Mistakes That Cause Mail or Site Outages
| Mistake | What breaks | Fix |
|---|---|---|
| Missing MX records after import | Email stops routing entirely | Cross-check MX priority and hostname against the original export before switching nameservers |
| SPF/DKIM TXT quotes stripped | Outgoing mail starts landing in spam or gets rejected | Compare the raw TXT string character-for-character against the source zone |
| Old nameservers left active for content that changed | Some visitors see the old site, others see the new one, mid-migration | Keep both zones identical until the cutover is fully propagated, then decommission the old one |
| SOA serial not incremented | Secondary DNS servers never sync the new zone | Manually bump the serial if your panel doesn't auto-increment it |
Prevention: Keep a Standing Backup
Don't treat this as a one-time migration task. Export the zone file every time you make a meaningful DNS change, and keep the last few dated copies somewhere outside the DNS host itself, a shared drive or a private repo is fine. If a record ever gets deleted by accident or a plugin/script touches DNS via API and gets it wrong, you paste the last good zone back in and you're done, instead of trying to reconstruct SPF and DKIM records from memory under pressure.
Frequently asked questions
Does exporting a DNS zone file affect my live site or email?
No. Exporting just reads the current records, it doesn't change anything. It's completely safe to do at any time, and you should do it before any DNS change as a rollback point.
Can I import a zone file exported from one host directly into a different host's panel?
Usually yes, since BIND zone format is a standard, but support varies. WHM and Cloudflare both accept raw zone imports. Many registrar DNS panels don't have a bulk import option and require you to re-enter records manually using the file as reference.
Why did my email stop working right after I imported a zone file?
The most common causes are a dropped or malformed MX record, or stripped quotes on an SPF/DKIM TXT record. Compare the imported records line-by-line against your original export to catch the mismatch.
How long does it take for an imported zone to fully propagate?
It depends on the TTL values in the file, from a few minutes if TTLs were already low, up to 24-48 hours on records left at default TTLs. Lowering TTLs to around 300 seconds a day before a planned migration speeds this up significantly.
I don't have WHM access, only regular cPanel — can I still get a zone file?
Regular cPanel's Zone Editor only lets you view and edit individual records, it has no full zone export. Ask your host for a WHM-level export, or use dig to pull a live snapshot of your current records as a manual reference.