Tuesday, December 05, 2006

Scripting ERD (Emergency Repair Disk) Creation

Creating ERDs (Emergency Repair Disks) is a task that is often overlooked. They are easy to forget about because you never really need them until you're in an emergency recovery situation. Well, since Windows 2000 creating emergency repair disks, and creating registry backups in general, have been a major pain. There is no easy way to do it and because of the nature of the registry and user lists being several megabytes in size. Putting them on floppy disks just isn't practical.

I wrote a series of batch files that are designed to be scheduled to run via Windows Task Scheduler. These batch files use the old Windows NT4 ERD utility because you can't script the creation of ERDs in Windows 2000/2003. (Weird right?)

Basically what these scripts do are copy out the essentials to create an ERD locally on each machine. After all of the files are copied out, I use PSExec to execute another batch file that preforms the backup, compresses the results with 7zip, copies that zip file to a network share, and then deletes itself from the local machine.

Some things to keep in mind if you decide to use this script:

!WARNING!

This script should NOT be ran on Windows Primary or Secondary Domain controllers! It is possible to create disks for domain controllers but this process may be harmful because of the amount of information stored in the ACL of domain controllers. Running a backup may fill the hard drive of server. If you are sure that the Domain controller will have enough hard drive space, it should be safe to perform this backup.

!WARNING!

This package will loop through a list of servers that should be copied to the file “serverlist.txt”. It will copy backup.bat to each server in the list. The script is started by executing the GO.bat file. The GO.bat file will have to be modified to include a user name and password that will have administrative access to the servers that you will be performing the backup on. Replace “DOMAIN\USERNAME” with a user that will have administrative access. Replace “PASSWORD” with the password to that account.

You will also have to have a server with a network share that the backups will be copied to. This will have to be changed in the backup.bat file to reflect your server. Change all of the locations where \\SERVER\SHARE are located to your server and share location. This location should also contain the 7zip.exe, zip.dll, deflate.dll, rdisk.exe, and psexec.exe files.

Once these three files (serverlist.txt, GO.bat, and backup.bat) have been edited to include your setup information you can run the GO.bat file and the emergency repair diskette creation process will start. This process takes about one minute for every computer listed in the serverlist.txt file.

A special note about these emergency repair diskette files. Most of the repair disks will be significantly larger than 1.44Mb. Most will range in the 4 to 5 megabyte range after ZIP compression. In order to use these files during an emergency repair you will have to unzip them and burn them to a CD. They have been zipped to significantly reduce the size of the backups.

These backups will contain a copy of the current registry. This would be useful if corruption of the registry ever occurred. These also represent a bit of a security risk as they contain the encrypted copies of user names and passwords of all of the local accounts of the computer (these would domain accounts if the computer happened to be a domain controller). It is not recommended that these be stored in an unsecured location on the network. A determined hacker could recover this information with enough time and computing horsepower.

All of that said here are the copies of the scripts:

rdisk.zip - I will have a zip of all the required files here shortly.

REM backup.bat

\\SERVER\share\rdisk.exe /s-
md \\SERVER\share\%computername%
copy \\SERVER\share\7z.exe %systemroot%\repair
md %systemroot%\repair\Formats
copy \\SERVER\share\zip.dll %systemroot%\repair\Formats
md %systemroot%\repair\Codecs
copy \\SERVER\share\Deflate.dll %systemroot%\repair\Codecs
c:
cd %systemroot%\repair
7z a -tzip %computername%.zip *._ *.nt *.dat *.inf *.log
copy %computername%.zip \\SERVER\share\%computername%
del /Q /F %computername%.zip
del /Q /F 7z.exe
del /Q /F .\Formats\zip.dll
del /Q /F .\Codecs\Deflate.dll
rd .\Formats
rd .\Codecs

REM go.bat

FOR /F "tokens=1" %%X in (serverlist.txt) do psexec \\%%X -u domain\username -p password -c -f -d backup.bat >> "rdisk.log"
cscript email.vbs


'email.vbs

Set WSHNetwork = CreateObject("WScript.Network")
computerName = WSHNetwork.ComputerName


Set objEmail = CreateObject("CDO.Message")
objEmail.From = "you@you.com"
objEmail.To = "
you@you.com"
objEmail.Subject = "RDisk is complete."
objEmail.Textbody = "RDisk is complete.  Please copy the folders into a new folder."
objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
        "unixm4"
objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send

Send this to:                          

Comments

Name
URL
Email
Email address is not published
Remember Me
Comments

CAPTCHA
Write the characters in the image above