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

# Import and export records

> Export DNS zone records to a BIND zone file for backup or migration, and import records from a BIND file into an existing zone.

## Customer Portal

Export DNS records to a BIND zone file for backup or migration, or import records from a BIND zone file into an existing Gcore DNS zone.

## Export or import records

In the [Gcore Customer Portal](https://portal.gcore.com), navigate to **Managed DNS** → [**All zones**](https://portal.gcore.com/dns/zones) and open the domain zone.

![Zone records page with Export records and Import records buttons](https://mintcdn.com/gcore/W9hLxFUXyZVjy-WH/images/docs/dns/dns-records/import-and-export-records/import-and-export-records-image2.png?fit=max\&auto=format\&n=W9hLxFUXyZVjy-WH\&q=85\&s=8559981c299d7a2817a22e8f0a3f1ba7)

> [tab] Export
>
> Click **Export records**. The portal downloads the records as a BIND zone file with the `.zone` extension, for example, `sample-test.com.zone`.
>
> The exported file contains the zone origin, TTLs, SOA parameters, authoritative nameservers, and DNS records:
>
> ```sh theme={null}
> $ORIGIN test.dnsexample.com.
> $TTL 300
> @ IN SOA ns1.gcorelabs.net. support.gcore.com. (
>   1690969313 ; serial number
>   5400 ; refresh
>   3600 ; update retry
>   1209600 ; expiry
>   300 ; minimum
> )
> $TTL 3600
> @ IN NS ns1.gcorelabs.net.
> @ IN NS ns2.gcdn.services.
> $TTL 600
> @ IN A 1.2.3.4
> @ IN A 4.5.6.7
> * IN CNAME sample.domains.com.
> * IN CNAME sample-2.domains.com.
> ```

> [tab] Import
>
> Click **Import records**. Paste the BIND zone content into the dialog, or click **Upload zone file** to select a `.zone` file. Then click **Import**.
>
> ![Import records dialog with zone file content field and Upload zone file button](https://mintcdn.com/gcore/W9hLxFUXyZVjy-WH/images/docs/dns/dns-records/import-and-export-records/import-and-export-records-image3.png?fit=max\&auto=format\&n=W9hLxFUXyZVjy-WH\&q=85\&s=9be2fa63bd980cdca8e8bc16da7a0127)
>
> Import adds new RRsets to the zone. Existing RRsets with the same name and type are skipped; records not mentioned in the file remain unchanged.

## REST API

Export and import DNS zone records as BIND-format zone files. Export returns the full zone file; import adds new RRsets to the zone. Existing RRsets with the same name and type are skipped — records not in the file remain unchanged.

> [!NOTE]
>
> An [API token](https://docs.gcore.com/account-settings/api-tokens.md) is required.

Export these variables:

```bash theme={null}
export GCORE_API_KEY="{YOUR_API_KEY}"
export ZONE_NAME="{YOUR_ZONE_NAME}"
```

## Export zone records

The response contains the full zone as a BIND-formatted string in the `raw_zone` field. SOA and NS records are included automatically.

> [tab] Python SDK
>
> ```python theme={null}
> import os
> from gcore import Gcore
>
> client = Gcore()
>
> exported = client.dns.zones.export(os.environ["ZONE_NAME"])
> with open("zone-file.zone", "w") as f:
>     f.write(exported.raw_zone)
> print("Saved to zone-file.zone")
> print(exported.raw_zone)
> ```

> [tab] Go SDK
>
> ```go theme={null}
> package main
>
> import (
>     "context"
>     "fmt"
>     "os"
>
>     gcore "github.com/G-Core/gcore-go"
> )
>
> func main() {
>     client := gcore.NewClient()
>     ctx := context.Background()
>
>     exported, err := client.DNS.Zones.Export(ctx, os.Getenv("ZONE_NAME"))
>     if err != nil {
>         panic(err)
>     }
>     err = os.WriteFile("zone-file.zone", []byte(exported.RawZone), 0644)
>     if err != nil {
>         panic(err)
>     }
>     fmt.Println("Saved to zone-file.zone")
>     fmt.Println(exported.RawZone)
> }
> ```

> [tab] curl
>
> To inspect the API response:
>
> ```bash theme={null}
> curl -s "https://api.gcore.com/dns/v2/zones/${ZONE_NAME}/export" \
>   -H "Authorization: APIKey $GCORE_API_KEY"
> ```
>
> The API returns:
>
> ```json theme={null}
> {
>   "raw_zone": "$ORIGIN example.com.\n$TTL 300\n@ IN SOA ns1.gcorelabs.net. ...\n$TTL 3600\n@ IN NS ns1.gcorelabs.net.\n@ IN NS ns2.gcdn.services.\n$TTL 300\n@ IN A 1.2.3.4\nwww IN A 5.6.7.8\n"
> }
> ```
>
> To export directly to a zone file:
>
> ```bash theme={null}
> curl -s "https://api.gcore.com/dns/v2/zones/${ZONE_NAME}/export" \
>   -H "Authorization: APIKey $GCORE_API_KEY" \
>   | python3 -c "import sys, json; print(json.load(sys.stdin)['raw_zone'])" \
>   > zone-file.zone
> ```

## Import zone records

Send the BIND zone file as a plain-text request body. Import adds new RRsets to the zone; existing RRsets with the same name and type are skipped and listed in `warnings`. Records not present in the file remain unchanged.

```bash theme={null}
curl -s -X POST "https://api.gcore.com/dns/v2/zones/${ZONE_NAME}/import" \
  -H "Authorization: APIKey $GCORE_API_KEY" \
  -H "Content-Type: text/plain" \
  --data-binary @zone-file.zone
```

The API returns:

```json theme={null}
{
  "imported": {
    "rrsets": 1,
    "resource_records": 1,
    "qtype": 1,
    "skipped_resource_records": 0
  },
  "success": true,
  "warnings": {}
}
```
