From: Aki Tuomi Date: Tue, 9 Jun 2015 20:16:52 +0000 (+0300) Subject: Add backend to backend migration tool X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~78^2~8^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90c2c8e9a9ee18c68e4ec8c620c65989e02f9df3;p=thirdparty%2Fpdns.git Add backend to backend migration tool --- diff --git a/pdns/pdnssec.cc b/pdns/pdnssec.cc index ec46daef3e..011ed19c22 100644 --- a/pdns/pdnssec.cc +++ b/pdns/pdnssec.cc @@ -1293,6 +1293,7 @@ try cerr<<"add-zone-key ZONE zsk|ksk [bits] [active|passive]"<getPrefix() == cmds[1]) src = b; + if (b->getPrefix() == cmds[2]) tgt = b; + } + if (!src) { + cerr<<"Unknown source backend '"<getPrefix()<<" to "<getPrefix()< domains; + + tgt->getAllDomains(&domains, true); + if (domains.size()>0) + throw PDNSException("Target backend has domain(s), please clean it first"); + + src->getAllDomains(&domains, true); + // iterate zones + for(const DomainInfo& di: domains) { + size_t nr,nc,nm,nk; + DNSResourceRecord rr; + cout<<"Processing '"<createDomain(di.zone)) throw PDNSException("Failed to create zone"); + tgt->setKind(di.zone, di.kind); + tgt->setAccount(di.zone,di.account); + for(const string& master: di.masters) { + tgt->setMaster(di.zone, master); + } + // move records + if (!src->list(di.zone, di.id, true)) throw PDNSException("Failed to list records"); + nr=0; + while(src->get(rr)) { + if (!tgt->feedRecord(rr)) throw PDNSException("Failed to feed record"); + nr++; + } + // move comments + nc=0; + if (src->listComments(di.id)) { + Comment c; + while(src->getComment(c)) { + tgt->feedComment(c); + nc++; + } + } + // move metadata + nm=0; + std::map > meta; + if (src->getAllDomainMetadata(di.zone, meta)) { + std::map >::iterator i; + for(i=meta.begin(); i != meta.end(); i++) { + if (!tgt->setDomainMetadata(di.zone, i->first, i->second)) throw PDNSException("Failed to feed domain metadata"); + nm++; + } + } + // move keys + nk=0; + std::vector keys; + if (src->getDomainKeys(di.zone, 0, keys)) { + for(const DNSBackend::KeyData& k: keys) { + tgt->addDomainKey(di.zone, k); + nk++; + } + } + cout<<"Moved "< tkeys; + if (src->getTSIGKeys(tkeys)) { + for(const struct TSIGKey& tk: tkeys) { + if (!tgt->setTSIGKey(tk.name, tk.algorithm, tk.key)) throw PDNSException("Failed to feed TSIG key"); + ntk++; + } + } + cout<<"Moved "<