PingWin.com

Black belts on Computer Repairs

Call 818 262 5621

Backup script for scheduling task.

@echo off
rem WHEN SELECT FILES TO BACKUP, MAKE SURE NOT TO SELECT D:\NTBACKPU!
cls
set Drive=d:
set extDrive=b:
set Folder=\ntBackup\
set logFile=c:\Backup\BackupLog.log
echo . >> %logFile%
echo . >> %logFile%
echo . >> %logFile%
echo BACKUP STARTS >> %logFile%
date /t >> %logFile%
time /t >> %logFile%

if .%1==. goto noTarget
if .%2==. goto noType
if %2==normal goto paraOK
if %2==incremental goto paraOK
goto wrongPara
:paraOK
if not exist %Drive% goto noDrive
%Drive%
if not exist %Folder% md %Folder%
set target=%Drive%%Folder%%1.bkf
echo Running %2 backup, saving it into %target% >> %logFile%
ntBackup backup systemstate "@c:\backup\selectedFile.bks" /f %target% /m %2 /j "%2 backup performed to %1.bkf" /l:f >> %logFile%
goto backOK
:noDrive
echo ERROR: Can't find drive %Drive% >> %logFile%
goto noBackup
:noTarget
echo ERROR: Target file name not entered >> %logFile%
goto noBackup
:noType
echo ERROR: No backup type, should be Normail or incremental >> %logFile%
goto noBackup

:wrongPara
echo ERROR: Backup type should either normail or incremental >> %logFile%
goto noBackup
:noBackup
echo ERROR - NO BACKUP PERFORMED >> %logFile%
goto end

:backOK
rem Restarting stations

echo Restarting all computers on network >> %logFile%
FOR /F "tokens=1 skip=4" %%A IN ('net sessions') do shutdown /m %%A /f /r /c "From server for backup" >> %logFile%
echo Finish restarting >> %logFile%
 

echo ntBackup completed. Now copiying to external drive >> %logFile%
if not exist %extDrive%\*.* goto noExternal
%extDrive%
if not exist %Folder% md %Folder%
XCOPY %target% %extDrive%%Folder%\*.* /y >> %logFile%
%Drive%
goto end
 

:noExternal
echo ERROR - Can't find external disk. >> %logFile%

:end
c:
cd\backup
echo BACKUP ENDS >> %logFile%
date /t >> %logFile%
time /t >> %logFile%
echo **** >> %logFile%
 


Privacy  About Us  Contact Us  Work Order Make a payment Links Website Hosting Prices Computer Repair Links

Will make your computer behave!

Copyright (C) Tal Bahir, Inc 2008