Código: Seleccionar todo
Author Basicos foro http://www.autoit.es
#include <Date>
#include <file>
Opt("trayicondebug", 1)
Global $BackupDesde = "g:\test", $BackupHaciaCarpeta = "g:\Mybackup"
$iRekursive=0
$message = ""
$backupName=StringLeft(StringReplace(_NowCalc(), "/", ""), 6) & "_BackUpReport.log"
$backupLog = @ScriptDir & "\" & $backupName
SplashTextOn("My Backup", "", 800, 600, 100, 200, 4, "")
_FileWriteLog($backupLog, @CRLF &@CRLF & "Resultados de la copia incremental desde " & $BackupDesde & " hacia " & $BackupHaciaCarpeta & "..:" & @CRLF)
DateiKopyDirInkre($BackupDesde, $BackupHaciaCarpeta, $backupLog,$iRekursive)
Run("Notepad.exe " & $backupLog)
WinWait($backupName,"")
If Not WinActive($backupName,"") Then WinActivate($backupName)
WinWaitActive($backupName,"",5)
Send("{CTRLDOWN}{END}{CTRLUP}")
Exit
Func DateiKopyDirInkre($BackupDesde, $BackupHaciaCarpeta, $backupLog,$iRekursive)
_FileWriteLog($backupLog, @crlf&" A la carpeta.... " & $BackupHaciaCarpeta)
;FileChangeDir($BackupDesde)
$search = FileFindFirstFile($BackupDesde & "\*.*")
; Test ob gefunden
If $search = -1 Then
ControlSetText("My Backup", "", "Static1", $message & " No existe la carpeta desde de la Mascara " & $BackupDesde)
_FileWriteLog($backupLog, "*Fehler Kopiert... " & " No existe la carpeta desde de la Mascara " & $BackupDesde)
Else
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
If FileGetAttrib($BackupDesde & "\" & $file) = "D" Then
if $iRekursive then DateiKopyDirInkre($BackupDesde & "\" & $file, $BackupHaciaCarpeta & "\" & $file, $backupLog,$iRekursive)
Else
DateiKopyInkrementelle($BackupDesde & "\" & $file, $BackupHaciaCarpeta & "\" & $file, 1, $backupLog)
EndIf
WEnd
; Handle Zu machen
FileClose($search)
EndIf
EndFunc ;==>DateiKopyDirInkre
Func DateiKopyInkrementelle($fromfile, $tofile, $NeuKopieren, $backupLog)
$wFehler = ""
If Not FileExists($tofile) Then
If $NeuKopieren Then
If Not FileCopy($fromfile, $tofile, 9) Then
_FileWriteLog($backupLog, "*Error al Copiar ... " & FileGetShortName($fromfile) & "->" & FileGetShortName($tofile))
$wFehler = " nicht kopiert"
Else
_FileWriteLog($backupLog, "+Bien al Copiar ... " & FileGetShortName($fromfile) & "->" & FileGetShortName($tofile))
EndIf
EndIf
Else
$fromCrc = FileGetAttrib($fromfile) & FileGetSize($fromfile) & FileGetTime($fromfile)
$toCrc = FileGetAttrib($tofile) & FileGetSize($tofile) & FileGetTime($tofile)
If $fromCrc <toCrc>DateiKopyInkrementelle If Not FileCopy($fromfile, $tofile, 9) Then
_FileWriteLog($backupLog, "*Error al Copiar ... " & FileGetShortName($fromfile) & "->" & FileGetShortName($tofile))
$wFehler = "<nicht>" & FileGetShortName($tofile))
EndIf
Else
_FileWriteLog($backupLog, "=Nada Ya existía ... " & FileGetShortName($fromfile) & "->" & FileGetShortName($tofile))
EndIf
EndIf
$message &= "Copiar " & $fromfile & " hacia " & $tofile & $wFehler & @CRLF
ControlSetText("My Backup", "", "Static1", $message)
EndFunc ;==>DateiKopyInkrementelle