← Back to Tools
Open Source Tool

Cloudflare DNS Backup

Bash DNS Recovery Cloudflare API

Automated Bash script that backs up every DNS record across all your Cloudflare zones via the API. Exports records in BIND-compatible format to timestamped .txt files — run it before DNS changes, on a cron schedule, or after incidents to maintain a dated record of your DNS state.

View on GitHub ↗ Read the Write-up →
Run before and after every DNS change. If something breaks, you have a dated record of what existed — recovery depends on the saved fields, access, provider behaviour and a tested procedure.

What it does

Quick start

# Clone the repo
git clone https://github.com/mylesagnew/cloudflare-backup
cd cloudflare-backup

# Configure credentials (never commit this file)
cp .env.example .env && chmod 600 .env
# Edit .env: CLOUDFLARE_API_TOKEN=your_api_token_here

# Make executable and run — exports all zones to ./domains/
chmod +x cf-dns-backup.sh
./cf-dns-backup.sh

# Optional: schedule daily via cron
crontab -e
# 0 2 * * * /path/to/cloudflare-backup/cf-dns-backup.sh >> /var/log/cf-backup.log 2>&1

Check a backup before relying on it

Related resources

For client work

Managing client domains? Make DNS backup and recovery part of a repeatable security evidence workflow. See the agency workflow →

Get notified when new tools and checklists drop.

Join Security Tool Updates →

Subscribe for updates

Get new security tools, checklists and guides by email. No spam — unsubscribe anytime.

Please don't include passwords, secrets, or client data.