A script using for NTBackup (Windows NT)
Author: Shawn Thompson
This script backs up across a Windows NT network using just the ntbackup.exe utility. It archives log files and writes appropriate event logs. Email me for a complete tutorial. Script:
/* Script file: net_backup.rex */ /* ~~Author~~. S. Thompson */ /* -- format tape (uncomment if you want the tape formatted first) -- */ /* 'ntbackup /nopoll' */ /* -- Minimize wait time for files in use -- */ hkey = w32RegOpenKey("HKEY_CURRENT_USER","Software\Microsoft\Ntbackup\User Interface") waittime = w32RegQueryValue(hkey,"Wait time") call w32RegSetValue hkey, "Wait time", "REG_SZ","3" /* -- get day of week -- */ day=date(w) /* -- shut down database server -- */ 'D:\PTCapps\proi\dataserv\bin\dbshut_ilink.bat' /* -- shut down file server -- */ 'D:\PTCapps\proi\fileserver\bin\fserv_shutdown.bat' call w32WriteEventLog , "REXX Backup", 4, , , ,"Intralink servers stopped" /* -- backup entire C: drive full or incremental -- */ if day='Monday' then butype='normal' else butype='incremental' 'ntbackup backup C:\ /v /r /d "Server C: drive" /a /e /b /hc:on /t 'butype ' /l "D:\backups\backup.log"' /* -- backup entire D: drive full or incremental -- */ if day='Tuesday' then butype='normal' else butype='incremental' 'ntbackup backup D:\ /v /r /d "Server D: drive & registry" /a /e /b /hc:on /t 'butype ' /l "D:\backups\backup.log"' /* -- backup entire E: drive full or incremental -- */ if day='Wednesday' then butype='normal' else butype='incremental' 'ntbackup backup E:\ /v /r /d "Server E: drive " /a /b /hc:on /t 'butype ' /l "D:\backups\backup.log"' call w32WriteEventLog , "REXX Backup", 4, , , ,"Local Backups Complete" /* -- restart file server -- */ 'D:\PTCapps\proi\fileserver\bin\fserv_startup.bat' /* -- restart database server -- */ 'D:\PTCapps\proi\dataserv\bin\dbstart_ilink.bat' call w32WriteEventLog , "REXX Backup", 4, , , ,"Intralink servers restarted" /* -- disconnect any stuck drives -- */ 'net use u: /delete' /* -- begin loop for each workstation by name -- */ if day='Thursday' then butype='normal' else butype='incremental' workstations=14 do i=1 while i<workstations+1 if i<10 then id='0'i else id=i /* -- connect to remote directory as U: drive -- */ 'net use u: \\cadstation'id'\d$ /user:cad\administrator ADMIN_PASSWORD_GOES_HERE' /* -- back up U: drive full or incremental -- */ description='"User directory on cadstation'id'"' 'ntbackup backup u:\users /v /d 'description' /a /hc:on /t 'butype ' /l "D:\backups\backup.log"' /* -- disconnect remotely mounted U: drive -- */ 'net use u: /delete' end call w32WriteEventLog , "REXX Backup", 4, , , ,"Backup of remote users done" /* -- save log file -- */ today=substr(date(o),1,2)'-'substr(date(o),4,2)'-'substr(date(o),7,2) 'if exist d:\backups\logs\'today'.bak del d:\backups\logs\'today'.bak' 'if exist d:\backups\logs\'today'.log rename d:\backups\logs\'today'.log 'today'.bak' 'if exist d:\backups\logs\'today'.log del d:\backups\logs\'today'.log' 'rename d:\backups\backup.log 'today'.log' 'copy d:\backups\*.log d:\backups\logs' 'if exist d:\backups\logs\'today'.log del d:\backups\'today'.log' /* -- Restore wait time for files in use -- */ call w32RegSetValue hkey, "Wait time", "REG_SZ",waittime call w32WriteEventLog , "REXX Backup", 4, , , ,"Backup Concluded"
XP Mapped Network Drive Disconnect
I have WinXP Pro connected to a workgroup. Everyone is setup to backup their data to a mapped network drive. My network drive stays connected OK until I run NTBACKUP. After about 30 minutes into the backup process it fails with the following error:
Windows - Delayed Write Failed. Windows was unable to save all of the data... The data has been lost.
The network drives are all disconnected. I can double-click on them and they reconnect. A small backup file exists. I can write to the drive and I can delete it. I have full control admin privileges.
I have done some research and have found many people have a problem with XP autodisconnect. I tried the following:
quoted from http://www25.brinkster.com/ChicagoTech Why some mapped network drives show a red x
"SYMPTOMS: You find that the network drive mapping may be disconnected after 15 minutes of inactivity and Windows Explorer may display a red "X" on the icon of the mapped drive. However, if you double-click it reconnects quickly.
RESOLUTION: by default, idle connections will be dropped after 15 minutes. To modify idle time, at a command prompt using net config server /autodisconnect: minutes. For example, to set the Autodisconnect value to 30 minutes, you would run the following command line: net config server /autodisconnect:30. If you would like to turn autodisconnect off, do net config server /autodisconnect:-1."
OK So I went to my command prompt and successfully ran net config server /autodisconnect:-1 but it did not help. NTBACKUP will not complete manually or scheduled. All mapped network drives disconnect.
Any help on this is greatly appreciated.
Comment from Allen Risler on 07/28/05 : NTBACKUP is in the process of writing backup.bkf when it disconnects. I can set NTBACKUP to create the same backup file to my D: drive hard disk partition, successfully, and I can copy and paste this 400MB file to my mapped network drive. It takes about an hour and does not disconnect. Power management is set to NEVER, Hibernation is disabled. Will try the REGEDIT and repost.
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters] "KeepAliveTime"=dword:00300000 "KeepAliveInterval"=dword:00001000
Or Copy that to a note pad and rename it keepalive.reg then double click on it and it will do the registry change for you.
What this does is that it sends keep alive packets every 5 minutes to the server you are mapped to making the connection live and not idle.
Also, does your XP workstation have a DNS entry? Sometime when the server can not resolve your IP via DNS (or wins) it will disconnect.
But try the registry change first.
Comment from Allen Risler on 07/28/05: The registry changes appears to have fixed this problem. The backup has finished successflly to the mapped network drive for the first time with no other changes. This will come in handy for solving similar network disconnect problems. Problem solved! Thank you!
Might also try turning off power management for your network card. Goto properties of your network connection and you should see a config button next to the card you have. Once in there in the advanced tab(i think) there may be an option for power saver or something like that. turn that off to see if it helps. Might also try turning off power saver features for hibernation and sleep. Check in the screensaver tab area for these.
Comment from Allen Risler on 07/28/05: This is a good point. The network card also has a power saving feture which I will disable. This was done after the regedit solved the problem already. I try things one at a time so that I know which measures actually fixed the problem.