Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Windows 2000 System State Backup
While backups should be conducted regularly and not be limited to the system state, this service can make repairing a server easier because the backed up data is kept on the server - no need to get 3rd party software loaded, find tapes, or make tape drives work.
I've used this to restore an Active Directory that gotten garbled so I think others might find this useful.
My experience has been that the backup file has been around 300mb and it normally can be zipped to just over 100 mb, so you need 400 MB of working space.
The main goal was to have this service not impact server performance, so each process is set to "Below Normal" priority. I've found this service to consume lots of CPU cycles, but server responsiveness was still very good.
Two scripts should be attached - the service and an install script. To compile them and have it work correctly, you'll need sc.exe (from the Win2K ResKit). I could be going on old info, but I assume the current NT extender cannot delete a service - so I use SC.exe for that. After installation, you'll need to add some Registry values to configure the service. If anyone bothers to write a quick front end to set these values, please post it here.
If nothing else, this should help some folks learn about writing services.
; Backup Zip Installation process ; Program installs BackupZip server service ; By Jim Graczyk ; Netway Solutions, Inc. ; 240 Palomino Dr. ; Salisbury, NC 28146 ; (704) 637-6155 ; www.netwaysolutions.com ; ; v1.1 Changes necessary for WB 2001 Recompile ; v1.12 Recompiled with WB 2001K ; v1.14 Added lower priority and included NTBackup command. Scheduled ; NT backup is no longer required verno="v1.14" progname=itemextract(1,winexename(""),".") debugtrace(1,"%progname%.log") sysroot=environment("systemroot") dest=strcat(sysroot,"\BackupZip") question="You are about to install Netway Solutions, Inc (704) 637-6155. BackUp Zip Service on this machine. This program must be executed from the %dest% directory and the BackupZip server services must be stopped. %@crlf%%@crlf% Do you wish to continue?" err=askyesno("BackupZip Installation",question) if err == @no then exit thisdir=strupper(dirget()) thisdir=strsub(thisdir,1,strlen(thisdir)-1) if strupper(dest) <> thisdir Message("BackupZip Server Installation","Program is not in the correct directory. Program is running from the %thisdir% directory, rather than the %dest% directory. Installation halted.") exit endif Boxopen("BackupZip Service Install","Installing BackupZip %verno%") AddExtender("WWWNT34I.DLL") err=runenviron("%sysroot%\system32\net.exe","stop BackupZip", @hidden , @wait) Files1=strcat("BackupZip.exe") files2=strcat("BackupZip.exs") err=filedelete(files2) for i = 1 to itemcount(files1,@tab) file1=itemextract(i,files1,@tab) file2=itemextract(i,files2,@tab) err=filerename(file1,file2) next strvals="ServiceName | DisplayName | BinaryPathName | LoadOrderGroup | ServiceStartName | Password" numvals="ServiceType | StartType | ErrorControl" ownprocess=16 interactive=256 boot=0 system=1 Auto=2 demand=3 disabled=4 error_ignore=0 error_normal=1 err=runenviron("sc.exe","delete BackupZip", @hidden , @wait) err=filedelete("sc.exe") strvals="BackupZip|BackupZip|%dest%\BackupZip.exs||LocalSystem|" servicetype=ownprocess numvals="%servicetype%|%auto%|%error_normal%" dependencies="" err=wntSvcCreate("", strvals, numvals, dependencies, "") errormode(@off) err=regsetvalue(@regmachine,"system\currentcontrolset\services\BackupZip\parameters[Workdir]","c:\sharedata\images\systemstatebackup") err=regsetvalue(@regmachine,"system\currentcontrolset\services\BackupZip\parameters[Source]","c:\sharedata\images\systemstatebackup\systate.bkf") err=regsetvalue(@regmachine,"system\currentcontrolset\services\BackupZip\parameters[Target]","c:\backup\systemstate.zip") err=regsetvalue(@regmachine,"system\currentcontrolset\services\BackupZip\parameters[StartTime]","03:00") err=regsetvalue(@regmachine,"system\currentcontrolset\services\BackupZip\parameters[daysoftheweek]","Mon|Wed|Fri") boxshut() err=message("BackupZip Installation Program","Installation Complete.%@crlf%%@crlf%Edit Registry HKLM\System\CurrentControlSet\Services\BackupZip\Parameters to set locations and schedule. Defaults set to Mon, Weds & Fri at 3 am.")
; BackupZip Service ; This service is intended to backup the System State of an Windows 2000 Server ; or Workstation to a file, then zip the result. All processes are set to ; "Below Normal" priority to reduce then impact seen by users. This process will ; run in the background. The System State is essential to rebuilding a failed ; server, somewhat like an Emergency Repair Disk was for NT, but much larger ; and more complicated. Once the zip is complete, the backupfile is moved to ; a destination dir. ; ; A registry key can easily be added with a more complex backup command. ; I've been told the zip extender only supports 4 gb files. No provision ; has been made for this fact, since I'm only backing up System State. ; ; Needs a front end to configure the registry settings. ; ; By Jim Graczyk ; Netway Solutions, Inc. ; 240 Palomino Dr. ; Salisbury, NC 28146 ; (704) 637-6155 ; www.netwaysolutions.com ; ; Winbatch 2001A Service to look for a new backup, zip it and copy it somewhere ; v1.12 recompiled for Winbatch 2001K ; v1.13 Added change of Priority to Below Normal to minimize load ; v1.14 Added NTBackup function to this service ;generic debug setting progname=itemextract(1,winexename(""),".") gosub dbgchk ;============================ UDFs ================================================== #definefunction GetProcessID(MyProcessID,MyThreadID) Kernel32DllSpec=strcat(dirwindows(1),"KERNEL32.DLL") myprocessid=0 mythreadid=0 ErrorMode(@OFF) MyProcessId = DllCall(Kernel32DllSpec, long:"GetCurrentProcessId") ErrorMode(@CANCEL) ErrorMode(@OFF) MyThreadId = DllCall(Kernel32DllSpec, long:"GetCurrentThreadId") ErrorMode(@CANCEL) return MyprocessId #endfunction ;============================ End UDFs =============================================== ;addextender("WWZIP34I.DLL") ;addextender("wproc34i.dll") addextender("WWZIP44I.DLL") addextender("WWPRC44I.DLL") ; Run as a Service IntControl (1001, 1, 0, 0, 0) ; Hide Icon While Running IntControl (1002, 0, 0, 0, 0) ; Prevent Desktop closure IntControl(1008,0,0,0,0) ;Icon Cannot be opened ;intcontrol(1003,0,0,0,0) ;Icon cannot be terminated IntControl(12,8,0,0,0) ; set process priority to below normal ; first find ProcessID processid = GetProcessID("","") ; set process priority \ ; NT 4 doesn't support above normal and below normal, set to idle ; This was stolen form somewhere - and is somewhat silly - NT ; doesn't support backup to a file. OS=winversion(5) if processid <> 0 if strsub(OS,1,2)=="2-4" priority = 64 else Priority = 16384 endif err=tSetPriority(ProcessId,priority) endif ; set values for the saveACL portion of this program exedir=strsub(progname,1,strindex(progname,"\",0,@backscan)) saveaclprog=strcat(exedir,"saveacl.exe") ; read the reg each loop so you don't have to start & start service for setting changes ; to take effect. :top workdir=regqueryvalue(@regmachine,"system\currentcontrolset\services\BackupZip\parameters[Workdir]") Source=regqueryvalue(@regmachine,"system\currentcontrolset\services\BackupZip\parameters[Source]") Target=regqueryvalue(@regmachine,"system\currentcontrolset\services\BackupZip\parameters[Target]") StartTime=regqueryvalue(@regmachine,"system\currentcontrolset\services\BackupZip\parameters[StartTime]") DaysOfTheWeek=regqueryvalue(@regmachine,"system\currentcontrolset\services\BackupZip\parameters[daysoftheweek]") DaysOfTheWeek=strupper(daysoftheweek) if regexistvalue(@regmachine,"system\currentcontrolset\services\BackupZip\parameters[Logtype]") == @true logtype=regqueryvalue(@regmachine,"system\currentcontrolset\services\BackupZip\parameters[logtype]") else logtype="N" ; set log type to none endif ;BackupSelectionPath=regqueryvalue(@regmachine,"system\currentcontrolset\services\BackupZip\parameters[BackupSelectionPath]") DirChange(workdir) ;Wait until the start time each day TimeToWait=strcat("0000:00:00:",starttime,":00") err=timewait(timetowait) ; determine if it's the day to run the backup job. a=TimeYmdHms( ) b=TimeJulianDay(a) c=(b+5) mod 7 today=strupper(ItemExtract(c+1, "Sun Mon Tue Wed Thu Fri Sat", " ")) if itemlocate(today,daysoftheweek,"|") <> 0 ;create run strings for backup job params=strcat('backup systemstate /j "BackupZip System State Backup" /f ',source,' /v:no /l:',logtype,' /rs:yes') ;perform the backup ProcessID=runshell("NTBackup.exe",params ,"",@hidden,@getprocid) PID=strcat("|",ProcessID) ;set process Priority to Below Normal if processid <> 0 if strsub(OS,1,2)=="2-4" priority = 64 else Priority = 16384 endif err=tSetPriority(ProcessId,priority) ;wait for NTBackup to complete while @true plist=tlistproc() if strindexnc(plist,PID,0,@fwdscan)== 0 then break timedelay(120) endwhile endif ;zip the file and move it pos=strindex(target,"\",strlen(target),@backscan) if pos == 0 tfile=target else tfile=strsub(target,pos+1,-1) endif ; This section is not needed - sometimes I need to backup all file ; security to a file using SaveACL.exe - a utility from Pedestal Software ; www.pedestalsoftware.com ; before we zip the backup - get ACLs for the whole system ; ACLFileName=strcat(workdir,"\cdrive.acl") ; if fileexist(saveaclprog) ; ProcessID=runshell(saveaclprog, "-r -archivebit -inherited c:\* %aclfilename% -x c:\pagefile.sys","",@hidden,@getprocid) ; PID=strcat("|",ProcessID) ; endif ; ;set process Priority to Below Normal ; if processid <> 0 ; if strsub(OS,1,2)=="2-4" ; priority = 64 ; else ; Priority = 16384 ; endif ; err=tSetPriority(ProcessId,priority) ; ; ;wait for saveacl to complete ; while @true ; plist=tlistproc() ; if strindexnc(plist,PID,0,@fwdscan)== 0 then break ; timedelay(120) ; endwhile ; endif ; ; zip to local file ; err=zZipFiles("S9", tfile, "%source%|%aclfilename%", "") err=zZipFiles("S9", tfile, "%source%", "") ;move the file without warning err=filemove(tfile,target,@false) endif goto top ;=================================================================== :dbgchk if fileexist("%progname%.dbg") debugtrace(1,"%progname%.log") else debugtrace(0,"%progname%.log") endif return ;====================================================================
Article ID: W14964
File Created: 2013:04:01:09:20:20
Last Updated: 2013:04:01:09:20:20