[Pdns-users] Adding multiple records to all zones at once
Jacob Bunk Nielsen
jacob at bunknielsen.dk
Fri Oct 13 05:06:15 UTC 2023
Andrea Biancalani via Pdns-users <pdns-users at mailman.powerdns.com> writes:
> Using powerdns db in a mysql shell I can prompt this command
>
> insert into records(domain_id,name,type,content,ttl) VALUES ("2","autoconfig.zonename.tld","CNAME","<my autoconfig zone>","3600");
> insert into records(domain_id,name,type,content,ttl) VALUES ("2","autodiscover.zonename.tld","CNAME","<my autodiscover zone>","3600");
Why not do something along the lines of (PostgreSQL syntax as that's
what I know, and completely untested):
INSERT INTO records (domain_id, name, type, content, ttl)
SELECT domain.id, 'autoconfig.' || domains.name, 'CNAME, '<my autoconfig zone>, 3600
FROM domains
JOIN records ON domains.id = records.domain_id
WHERE domains.id NOT IN (
SELECT domains_id FROM records
JOIN domains ON domains.id = records.domain_id
WHERE name = 'autoconfig.' || domains.name );
You may want to just run the SELECT first to see that it gives you what
you want.
Best regards,
Jacob
More information about the Pdns-users
mailing list