For my personal project, I use Cloudflare to set up DNS records.
If you are also using Cloudflare and need a backup of your DNS records, you can use the following tutorial to download your data and store it in a secure location for future reference. All you need is an npm module and a command line.
The first thing we're going to do is use a tool called cloudflare-backup from npm.
To set this up run the following commands in your terminal:
$ npm install -g cloudflare-backup
Now that we have confirmed we have the prerequisites for the backup, create a file called
cf-backup.sh in your chosen folder.
Inside that file add the following script:
#!/bin/bash CF_EMAILemail@example.com CF_TOKEN=abc123 cf-backup > zones.bind.txt
To run this with your account
- Log in to Cloudflare and click on your name (in the top right) and click My Profile
- Go to the API Tokens tab
- Click to view your Global API Key
- Copy your global API key into
cf-backup.shwith your CloudFlare account email address
Run the script
Now you can run the script to retreive a copy of your records:
$ sh cf-backup.sh
A new file
zones.bind.txt should appear in your folder with all of your DNS records.
I am looking to update this in the future to closer match my Route 53 DNS Backups utilinsing one file per zone, Cloudflare API Tokens with just "read" access, and a date stamped folder.