I have powerdns with mysql backend. This is the perfect solution if you have many dns servers. If you have similar case see http://doc.powerdns.com/html/slave.html#supermaster
The last few years, we have only add domains, without delete expired and those that are no longer served by our DNS servers. powerdns cleaner script clean these particular domains.
Powerdns has two sql tables – domains and records. First I take the domains from “domains” table and check one by one with dig command for their DNS server. If the domain don’t have “my server”, the script will deleted all records for him from “domains” and “records” mysql table.
If you need of this script use my github repo https://github.com/ygeorgiev/pdns_cleaner.php