DNS, DHCP Backup recovery Bat (batch automatically implemented) _ Server other

Source: Internet
Author: User

Now the server running a lot of system services, although there is no problem in the middle, but still afraid, if there is a problem, is a few days of time no, tired of 4 of people things AH. So you have to backup everything. Ghost Backup is the system, but the service configuration is at any time in the change, can not always come to a ghost bar, say no display, very troublesome.
Studied for an afternoon and finally implemented automatic DNS and DHCP backups.

Backup of DNS

1. Stop DNS Service
2, open regedit, find Hklm\system\currentcontrolset\services\dns
3. Export this branch of DNS. Named DNS-1
4, find HKLM\Software\Microsoft\Windows NT\CurrentVersion\DNS server
5, the DNSServer branch export, named DNS-2
6, open \windows\system32\dns, all of which *.dns files copied out, and Dns-1.reg and Dns-2.reg saved together.
Back up the above content.

DNS recovery:

1, when the DNS server in the zone fails, re-establish a win2003 server, and the DNS server to be replaced by the same name, set the same DNS suffix and IP address.
2. Install and start the DNS service in the new system.
3. Copy the *.dns file from the previous backup to the \windows\system32\dns folder of the new system.
4, disable the DNS service.
5, the backup of the Dns-1.reg and Dns-2.reg import into the registry.
6, restart the DNS service.

Fast Backup of DHCP
Command line:
netsh dhcp server dump >dhcp_bak.txt
Backup completed.
If the original DHCP server is corrupted, you need to create a new DHCP server and copy the Dhcp-bak.txt.
To run at the command line:
Netsh exec dhcp_bak.txt
In this way, the relevant information is restored, but the lease information cannot be recovered in this way.


This is only a manual implementation of the method, as a server, this is not enough, every day to backup not only trouble also very not insurance (forget how to do?) , so we can do a batch, and then set up a task to automate the implementation of the backup.
The following is the code for the backup:

@echo Smoile ' s network Management Road (c) 2005-2007 All right resevices
@echo Production maintenance: Smoile
@echo Technical Support: www.smoile.com
@echo (@ @ )
@echo ┏━oooo-(_)-oooo━━━━━━━━━┓
@echo ┃ Thank you for your support www.smoile.com  ┃
@echo ┃ ┃
@echo ┃oooo      ┃
@echo ┗━ ()-━oooo━━━━━━━━━┛
@echo \ (()
@echo \_))/
@echo (_/

@echo Backup DNS config start
... ..... @echo Please set up Backup\dns and DNCP two folders under D disk
:: Copy system32\dns DNS file
copy c:\windows\system32\dns\*.dns D:\backup\ dns/y
:: Export Registry File
regedit/e D:\backup\DNS\DNS-1.reg HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services \dns
:: full path filename with quotes
regedit/e D:\backup\DNS\DNS-2.reg "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT \currentversion\dns Server "
@echo DNS config backup complete!
@echo backup DHCP config start ...
:: Backing up DHCP files
netsh dhcp server dump >d:\backup\dhcp\dhcp_bak.txt/y
echo DHCP config backup complete!
echo off
exit

Save the above code as a bat file, and double-click to run the DNS and DHCP backup automatically.

Where the effect of a DNS backup is:

Effects of DHCP Backups

DHCP and DNS AutoRecover code:

@echo Smoile ' s network Management Road (c) 2005-2007 All right resevices
@echo Production maintenance: Smoile
@echo Technical Support: www.smoile.com
@echo (@ @ )
@echo ┏━oooo-(_)-oooo━━━━━━━━━┓
@echo ┃ Thank you for your support www.smoile.com  ┃
@echo ┃ ┃
@echo ┃oooo      ┃
@echo ┗━ ()-━oooo━━━━━━━━━┛
@echo \ (()
@echo \_))/
@echo (_/

@echo Resume DNS config start
... ..... net stop DNS
:: Copy the. dns file to System32\Dns
copy d:\backup\dns\*.dns c:\windows\system32\dns/y
:: Import Registry File
reg Import D:\backup\DNS\DNS-1.reg
reg import d:\backup\DNS\DNS-2.reg
net start DNS
@echo DNS Resume complete!
@echo Resume DHCP config start ...
:: Restoring the DHCP file
net stop tcpsvcs
netsh exec d:\backup\dhcp\dhcp_bak.txt< C28/>net start Tcpsvcs
echo DHCP config resume complete!
echo off
exit

This involves the export and import issues of the Registry
Export:
regedit/e filename Path
When the space occurs, enclose the entire path in quotes, or it will not recognize the space in DOS.

Import:
At the beginning of the regedit/s command, it seems no use, so use the reg import command, under Windows 2003 pass the test!

Original: http://www.smoile.com/article.asp?id=707

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.