Skip to main content

Import and export records

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

Export or import records

In the CDB Technical Web Portal, navigate to Managed DNS → All zones and open the domain zone.

Zone records page with Export records and Import records buttons

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:

$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.

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

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.

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.

An API token is required.

Export these variables:

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.

import os
from gcore import CDB

client = CDB()

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)
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)
}

To inspect the API response:

curl -s "https://api.cdb-staging.cdn.orange.com/dns/v2/zones/${ZONE_NAME}/export" \
  -H "Authorization: APIKey $GCORE_API_KEY"

The API returns:

{
  "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:

curl -s "https://api.cdb-staging.cdn.orange.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.

curl -s -X POST "https://api.cdb-staging.cdn.orange.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:

{
  "imported": {
    "rrsets": 1,
    "resource_records": 1,
    "qtype": 1,
    "skipped_resource_records": 0
  },
  "success": true,
  "warnings": {}
}