> ## Documentation Index
> Fetch the complete documentation index at: https://dnzwithazee.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Import and export

> Move zones in and out of DNZ as BIND zone files, and copy records to and from Cloudflare, with a preview before anything changes.

DNZ reads and writes standard **BIND zone files**, so you can move a zone from BIND, Knot,
PowerDNS or a registrar's export into DNZ, or take a copy out. When a division is connected to
Cloudflare, you can also copy records between Cloudflare and local DNS.

Every import shows a **preview** first: what is added, what is skipped and why. Nothing is written
until you confirm.

## Export a zone

**Dashboard**

Open the zone under **DNS → Zones** and click **Export**. You get a BIND zone file.

**CLI**

```bash theme={null}
dnz zone export example.com -o example.com.zone
```

**API**

```bash theme={null}
curl -H "Authorization: Bearer $DNZ_TOKEN" https://dns.example.com/api/zones/3/export
```

Needs `zones.read`. See [Zones API](/api/zones).

## Import into an existing zone

**Dashboard**

**1. Open the import dialog**

Open the zone under **DNS → Zones** and click **Import**.

**2. Add the file**

Click **Choose file** (up to 2 MB), or paste the zone file into the text box.

**3. Pick a mode**

**Merge** adds the file's records next to the ones already there. **Replace all** deletes
the zone's current records and keeps only the file's.

**4. Preview**

Click **Preview**. DNZ lists the records to add, the skipped records with the reason, and in
Replace mode how many existing records will be deleted.

**5. Apply**

Click **Import N records**.

**CLI**

```bash theme={null}
dnz zone import example.com extra.zone --dry-run   # only show what would happen
dnz zone import example.com extra.zone             # merge
dnz zone import example.com extra.zone --replace   # replace the zone's records
```

The command shows the plan and asks before applying it; `--yes` skips the question. See
[CLI: zones and records](/cli/zones-records).

## Create a new zone from a file

**Dashboard**

On **DNS → Zones**, click **Import zone**, add the file, and preview. The **Zone name** is
optional if the file has `$ORIGIN`. The preview says it **creates local zone** *name*.

This needs both `zones.write` and `records.write`.

**CLI**

```bash theme={null}
dnz zone add --file example.com.zone          # name from $ORIGIN
```

## What an import skips

Records are checked like manual input. These are skipped and listed with the reason:

| Skipped | Reason |
| - | - |
| `SOA` | SOA is generated by DNZ |
| `NS` at the apex | Apex NS records are managed by DNZ |
| Names outside the zone | Outside the zone |
| Types DNZ doesn't store, such as `HINFO` | Record type not supported by DNZ |

Records without a TTL get the zone's **default TTL** when the file has no `$TTL` (see
[Default TTL](/dns/zones#default-ttl)).

> [!NOTE]
>
> Import and export only use a zone's **default records**. Records that only one
> [view](/dns/views) sees are never exported, so internal addresses don't leak.

## Cloudflare

When a division has a Cloudflare connection (see [Cloudflare](/integrations/cloudflare)), the
Cloudflare zones appear under **DNS → Zones → Cloudflare**, and two more ways to move records open
up. Both show the same kind of preview.

### Copy from Cloudflare to local DNS

**One zone**: open the Cloudflare zone and click **Copy to local**. Tick the records you want, or
keep them all, then click **Copy**. DNZ copies them into the local zone of the same name, creating it
when it's missing, and then answers for them itself.

**Several zones**: on the Cloudflare tab, click **Import to local DNS**. Choose **All records**
(every record each zone can take) or **Choose records** (open a zone to tick the records it gets).
Each zone shows whether it becomes a **New local zone** or **Adds to the local zone**.

Right after you **Sign in with Cloudflare**, the same dialog is offered so you can bring the zones
into local DNS in one step.

* Existing local records are kept.
* Proxied records are copied with their origin address.

```bash theme={null}
dnz cf import example.com example.org             # Cloudflare → local DNS, previewed first
dnz cf import --all --dry-run
dnz cf import example.com --type A,CNAME --name www,api   # only some of the records
```

Without filters `import` takes every record it can. `--type` and `--name` (names relative to the
zone, `@` for the apex) narrow it to the matching records, and zones with none of them are left
alone. Copying needs `records.write`, and `zones.write` when it creates a zone.

### Push local records to Cloudflare

Open a local zone and click **Push to Cloudflare** (shown when the division is connected). DNZ adds
the zone's records that are missing from the Cloudflare zone with the same name. **Nothing on
Cloudflare is changed or deleted.**

```bash theme={null}
dnz cf push example.com                           # local records missing on Cloudflare → Cloudflare
```

Both `import` and `push` show what they would do and ask first; `--dry-run` only shows it. See
[CLI: Cloudflare](/cli/cloudflare).

> [!NOTE]
>
> *Copy to local* and *Push to Cloudflare* also use only the default records, never view-only ones.

> **[Zones and records](/dns/zones)**
>
> Edit the records once they are in DNZ.

> **[Cloudflare](/integrations/cloudflare)**
>
> Connect a division to Cloudflare.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.