Scheduled DHCP Backup using Scheduled Tasks

We have recently upgraded 60 Windows 2003 DC to Windows 2008 R2 DC. After up-gradation, client wants to automate DHCP backup. We have thought of going by scheduled tasks. We followed below procedure
A.      Create a batch file for DHCP Backup and copy that file to all DHCP server
B.      Create a scheduled job on DHCP Server to run DHCP Backup file
C.      Run Scheduled job to verify it’s configured properly
D.      Verify
We want this task to be automated, as login to each server and following the procedure will be time consuming job.

A.      Create a batch file for DHCP Backup and copy that file to all DHCP server
Below is the batch file created to automate DHCP backup. This script will have last 7 days of DHCP backup.
cd c:\  
cd DHCP Daily Backup
rmdir %Date:~0,3%
md %Date:~0,3%
cd %Date:~0,3%
netsh dhcp server export dhcpdb all
We will give ‘DHCP-Bck.bat’ name to this file and copy to all servers windows directory.
B.      Create a scheduled job on DHCP Server to run DHCP Backup file
Login to any server and run below command, this command will create scheduled job named DHCP Backup to run job at 3 AM every day.
schtasks /create /s DHCPServerName /tn “DHCP Backup” /tr “C:\Windows\DHCP-Bck.bat ” /sc daily /st 03:00:00
Use excel to replace DHCPServerNameto Server list where you want to create a job

C.      Run Scheduled job to verify it’s configured properly
Once you done with previous step, it is now time to run that job. This task again can be accomplished remotely by using below command
schtasks /run /s DHCPSerrverName /tn “DHCP Backup”
Use excel to replace DHCPServerNameto Server list where you want to create a job
D.      Verify
As you have done all the tasks remotely, you may also want to verify that DHCP Backup is happening properly. So here two simple command that help you to make sure that DHCP Backup is scheduled properly. Below command will check DHCP backup file is exist or not. If exist it will create txt file with containing name of the computer and after that it will copied to the any share location
if exist “C:\DHCP Daily Backup\%date:~0,3%\dhcpdb” copy /y NUL %computername%.txt
copy %computername%.txt \\Servername\Verify
At the end, you just need to verify whether all server file name is exist in the share location or not.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s