Auswertung von großen Log Dateien aus Robocopy; Nur Fehler anzeigen

The estimated reading time 4 minutes

Immer wieder steht man vor dem Problem, dass ein Sync mit Robocopy eine große Logdatei mit vielen Einträgen und auch Fehlern ausgibt.

Nun möchte man möglichst nur die Fehler analysieren.

Dies lässt sich relativ leicht erreichen.

  1. Variante: man kann Robocopy anpassen, dass im Ausgabe Log nur die Fehler ausgegeben werden
  2. Variante: man kann mit einer weiteren Batchdatei nur die Fehler in ein gesondertes LOG schreiben

Variante 1:

@echo off
robocopy "\\Quelle\Ordner" "\\Ziel\Ordner" /mir /XD "AusgeschlossenerOrdner1" "AusgeschlossenerOrdner2" /TS /R:1 /W:1 /LOG+:"C:\temp\%date:~0,2%-%date:~3,2%-%date:~6,4%-%time:~0,2%-%time:~3,2%-%time:~6,2%-NAME.log" /NP /NDL /NFL 
pause

Paramter für die Logfile Bearbeitung:

/L   :: List only - don't copy, timestamp or delete any files.
/X   :: report all eXtra files, not just those selected.
/V   :: produce Verbose output, showing skipped files.
/TS  :: include source file Time Stamps in the output.
/FP  :: include Full Pathname of files in the output.

/NS  :: No Size - don't log file sizes.
/NC  :: No Class - don't log file classes.
/NFL :: No File List - don't log file names.
/NDL :: No Directory List - don't log directory names.

/NP  :: No Progress - don't display % copied.
/ETA :: show Estimated Time of Arrival of copied files.

siehe hierzu auch Link

Variante 2

Zuerst lasse ich alles komplett Mitloggen, danach lese ich die Logdateien in einer Batchdatei ein und generiere daraus eine neue Logdatei, welche nur die Fehler enthält

Hierzu eine Batchdatei im selben  Verzeichnis generieren mit folgendem Code:

type name.log |find /i "0x00000002" >> nurfehler.log

Beispielbatch:

type *.log |find /i "0x00000002" >> C:\temp\Fehler\%date:~0,2%-%date:~3,2%-%date:~6,4%-%time:~0,2%-%time:~3,2%-%time:~6,2%-ERROR-Dateiname.log
type *.log |find /i "0x00000003" >> C:\temp\Fehler\%date:~0,2%-%date:~3,2%-%date:~6,4%-%time:~0,2%-%time:~3,2%-%time:~6,2%-ERROR-Pfadname.log
type *.log |find /i "0x00000005" >> C:\temp\Fehler\%date:~0,2%-%date:~3,2%-%date:~6,4%-%time:~0,2%-%time:~3,2%-%time:~6,2%-ERROR-Zugriffverweigert.log
type *.log |find /i "0x00000020" >> C:\temp\Fehler\%date:~0,2%-%date:~3,2%-%date:~6,4%-%time:~0,2%-%time:~3,2%-%time:~6,2%-ERROR-DateiimZugriff.log
type *.log |find /i "0x00000035" >> C:\temp\Fehler\%date:~0,2%-%date:~3,2%-%date:~6,4%-%time:~0,2%-%time:~3,2%-%time:~6,2%-ERROR-Netzwerkpfadnichtgefunden.log

Wird diese Batchdatei ausgeführt durchsucht sie alle .log-Dateien im selben Ordner wie die Batchdatei und  erstellt dann weitere .log-Dateien in den Ordner C:\temp\Fehler\ mit dem Datum und aktueller Uhrzeit.

Hat man nun diese Fehlerdatei kann diese zum Beispiel in Excel weiterverarbeitet werden

Um zum Beispiel herauszufinden wieviele Zeichen ein Pfad hat, kann dies mit der Excelfunktion LÄNGE

Hinweis: hierfür habe ich ein gutes Tool gefunden auf Powershell Basis siehe hier

=LÄNGE(Zelle)

robocopy-error-logDiese Funktion lässt sich dann bequem nach unten ziehen und auch sortieren. Somit kann man die längsten Pfade sortieren

Error Codes in Robocopy siehe TechnetBlog

Code Meaning
0 No errors occurred and no files were copied.
1 One of more files were copied successfully.
2 Extra files or directories were detected.  Examine the log file for more information.
4 Mismatched files or directories were detected.  Examine the log file for more information.
8 Some files or directories could not be copied and the retry limit was exceeded.
16 Robocopy did not copy any files.  Check the command line parameters and verify that Robocopy has enough rights to write to the destination folder.

Diese Codes gelten z.B. wenn die Batches per „Aufgabe“ ausgeführt werden (also benutzerunabhängig)

Hier noch einige Fehler direkt aus dem Error Log

ERROR 2  (0x00000002) The system cannot find the file specified.
ERROR 3  (0x00000003) The system cannot find the path specified.
ERROR 5  (0x00000005) Access is denied.
ERROR 6  (0x00000006) The handle is invalid.
ERROR 32 (0x00000020) The process cannot access the file because it is being used by another process.
ERROR 53 (0x00000035) The network path was not found.
ERROR 64 (0x00000040) The specified network name is no longer available.
ERROR 112(0x00000070) There is not enough space on the disk.
ERROR 121(0x00000079) The semaphore timeout period has expired.

Viel Spaß beim Nachbauen.

 

Print Friendly, PDF & Email
Was this article helpful?
YesNo
0 0 votes
Article Rating
Abonnieren
Benachrichtige mich bei
guest
0 Comments
Inline Feedbacks
View all comments