How to restore cPanel DNS zone files from backup
If your cPanel is setup for daily backups and you accidentally deleted a DNS zone or need to restore one for a client, all your DNS zone backup files are stored here:
/backup/cpbackup/daily/dirs/_var_named
This is assuming you have your backup mounted to /backup
Now you can either copy over whatever file you need or you can copy the entire folder if you need to restore all DNS zones.
These files need to be moved to /var/named
Once you move the backup copy over to /var/named you need to change ownership of the files to named.named, for that we will use chown.
1 |
chown -R named:named /var/named |
Now that changed permissions for everything in the /var/named folder. There are a few files that need to be owned by root though.
For that use chown again, here are the files/folders for root:named ownership.
1 2 3 4 5 6 7 8 9 |
chown root.named /var/named/chroot/ chown root.named /var/named/localdomain.zone chown root.named /var/named/localhost.zone chown root.named /var/named/named.broadcast chown root.named /var/named/named.ca chown root.named /var/named/named.ip6.local chown root.named /var/named/named.local chown root.named /var/named/named.rfc1912.zones chown root.named /var/named/named.zero |
Once you get all your ownership settings correct we will need to restart named, so
1 |
service named restart |
or
1 |
/etc/init.d/named restart |
After we restart named we will want to rebuild the DNS configuration inside cPanel, so run this command:
1 |
/scripts/rebuilddnsconfig |
That should do it! Verify all your files loaded in WHM and check with a DNS script, you can find one here: http://dns.hostt.net
-
V. Ivanov