Debian’s bind transfer to another server or another system.

Had at work with a fun challenge bind9 migrate from server to server. Seemingly everything is trivial, but no. Problems along the way met. Seemingly simple, but remember how to solve them in the future, it would not be desirable.
Haha you may need it... well.. for example, in case of system reinstall. When you transfer the bind’a from server to server … all of a sudden you want to move on a physical server VDS) as well, this solution can be used to create a temporary secondary DNS server. In General, images themselves.
There are:
Debian1 — it now installed bind
Server2 is the transfer.
Be careful, look at the invitation to the team to see which server execute command.
Put a bind on the patient:
Server2: ~ # aptitude install bind9
Copy the rndc.key away, he then will come in handy:
Server2: ~ # cp/etc/bind9/rndc.key/root/rndc.key
Remove everything from the directory bind’a (on the second server, delete, be careful):
Server2: ~ # cd/etc/bind & & rm-r *
Now let’s create the configs of the existing bind’a file:
Debian1: ~ # cd/etc/bind tar-cvf & & bind.tar *
Zal′ëm archive for the second server:
Debian1: ~ # scp bind.tar root @ Server2: ~/etc/bind
Unpack it on the second server:
Server2: ~ # cd/etc/bind & & tar-xvf bind.tar
Copy the archive just in case:
Server2: ~ # cp/etc/bind/bind.tar & &/root/bind.tar
Now return the rndc.key on place:
Server2: ~ # rm/etc/bind/rndc.key & &/root/rndc.key cp/etc/bind/rndc.key
Now should work without any errors, type:
Server2: ~ #/etc/init.d/bind9 restart
If there are errors, please contact me, I will think how to fix.
If you reinstall the system think themselves guess how to upgrade the algorithm.
Now about those cases where IP Binda has changed.
First you need to change the IP address in the listen-on (I have it was unearthed in named.conf.options file row 4, if you have it not, grep-rn in your hands).
Secondly, if you are migrating sites themselves on new IP, you can use the following construct:
Server2: ~ # cd/etc/bind & & sed-i-e‘s/xx \.xx\.xx\.xx/yy\.yy\.yy\.yy/g *
This command in a directory all files Binda we replace xx. xx. xx. xx to yy. yy yy yy..
Ajpišniki. to … in principle, they can go there to write anything (well, for example, ns1. = > ns2.).
In a simplified way: sedi-e‘s/xx/yy/g ‘ *
But the point must be escaped before them put \ (backslash)
Just use caution if you are not sure, check the file name instead of the asterisk.