WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Backups

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Incremental Backup Procedure

Keywords:   Incremental Backup Procedure

 ;Incremental backup procedure.
 ;With minor changes it can do a full backup also
 ;(like for the first time....)


AddExtender("wwsop34i.dll")
SourcePath="C:\work"
BackupPath="d:\work"
LogFile="d:\BackupListw.txt"

#DefineFunction DirTree(Handle,CurrentDir,SourcePath,BackupPath,TotalFiles)
; DebugTrace(@ON,"d:\backuptrace.txt") ;;;;;;;;;;
   DirChange(CurrentDir)
   If StrSub(CurrentDir,StrLen(CurrentDir),1)!="\" Then CurrentDir=StrCat(CurrentDir,"\")
   aStatusbar(1,"Total files processed: %TotalFiles%",CurrentDir,1,0)
   FileList=FileItemPath("*.*")
   FileCount=ItemCount(FileList,@TAB)
   For CountF=1 To FileCount
      TotalFiles=TotalFiles+1
      File=ItemExtract(CountF,FileList,@TAB)
      FileDate=FileTimeGetEx(File,3)
      Archive=(StrSub(FileAttrGet(File),2,1)=="A") ;Check archive bit
      If Archive
         FileSz=FileSizeEx(File)/1024.0
         FileWrite(Handle,StrCat(FileDate," ",StrFixLeft(FileSz," ",7)," KB ",File))
         target=StrReplace(File,SourcePath,BackupPath) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
         If DirExist(FilePath(target))==@FALSE Then DirMake(FilePath(target)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
         aFileCopy(File,target,4) ;Backup file         ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
         FileAttrSet(File,"a") ;Reset archive bit
      EndIf
   Next
   SubDirs=DirItemize("*.*")
   DirCount=ItemCount(SubDirs,@TAB)
   For CountD=1 To DirCount
      SubDir=ItemExtract(CountD,SubDirs,@TAB)
      FullDir=StrCat(CurrentDir,SubDir,"\") 
      TotalFiles=DirTree(Handle,FullDir,SourcePath,BackupPath,TotalFiles)
   Next
   Return TotalFiles
#EndFunction

AddExtender("Wilx34i.dll") ;WIL Extender
Terminate(!DirExist(SourcePath),"Status","Invalid source path")
Terminate(!xDriveReady(StrSub(BackupPath,1,2)),"Status","Backup drive not ava1lable")
If !DirExist(BackupPath) Then DirMake(BackupPath)
aStatusbar(0,"Initializing...","",1,0)
Handle=FileOpen(LogFile,"APPEND") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TotalFiles=DirTree(Handle,SourcePath,SourcePath,BackupPath,0)
;TotalFiles=DirTree(Handle,SourcePath,SourcePath2,BackupPath2,0)
FileClose(Handle)
aStatusbar(2,"","",0,0)
Display(3,"Status","Incremental backup finished.%@CRLF%Total files checked: %TotalFiles%")
Exit 

Article ID:   W15526
File Created: 2003:05:13:11:28:30
Last Updated: 2003:05:13:11:28:30