je sais pas si c'est toujours d'actualité pour robocopy mais si cela peut te servir:
nom du fichier : robocopy.bat
voici mon script robocopy :
__________________________________________________________________________________________
SET
LOG="D:\Test\log\log.txt"
SET DEST="d:\Test\destination"
SET SOURCE="d:\Test\source"
c:
robocopy %SOURCE% %DEST% /MIR /LOG:%LOG% /R:1 /W:2
cscript "D:\robocopy\robocopy_checker.vbs"
__________________________________________________________________________________________
pour info le vbs me permet d'envoyer le rapport de sauvegarde par
mail
Nom du fichier vbs : robocopy_checker.vbs (tu peux le renommer mais oublie pas de le faire aussi dans le .bat ou est renseigner le chemin du vbs)
txtSMTPServer : tu dois indiquer l'adresse de ton serveur smtp : par exemple : smtp.orange.fr
txtTo: adresse mail du destinataire
txtFrom : adresse mail de l'expéditeur
voici le vbs :
__________________________________________________________________________________________
'robocopy_checker.vbs
Dim txtSMTPServer, txtTo, txtFrom, txtSubject, txtBody
Dim txtLog, strValue, iTotal, iPos, strText
txtSMTPServer = " " '
SMTP server
txtTo = " " 'To Address
txtFrom = " " 'From Address
txtSubject = "Rapport de sauvegarde test" 'Subjet du mail
txtLog = "D:\Test\log\log.txt" 'chemin du fichier de log de robocopy
'Récupérer le contenu du fichier
FileContents = GetFile(txtLog)
'-- Cycle thru the log file to find errors --
strText = FileContents
iPos = 1
Do While iPos <= Len(strText)
If InStr(iPos, UCase(strText), "0X00000") > 0 Then
iTotal = iTotal + 1
iPos = InStr(iPos, UCase(strText), "0X00000")_
+ Len("0X00000")
Else
Exit Do
End If
Loop
'-- --
If iTotal > 0 Then
strErrors = 1
Else
strErrors = 0
End If
'Sortie significative en cas d'erreur de copie
If strErrors = 1 Then
txtBody = "La sauvegarde a détecté " & iTotal & " fichiers " &_
"qui n'ont pas pu être sauvegardés." &_
"Voir le fichier log ci-joint en pièce jointe pour vérifier les fichiers qui n'ont pas pu être copiés." & vbcrlf & "" &_
"Il est possible que ces fichiers soient liés à une application restée en cours d'exécution." & vbcrlf & "" &_
"Si vous avez des questions ou des problèmes liés à la sauvegarde n'hésitez pas à nous contacter"
Else
txtBody = "La sauvegarde a réussie. Pas d'erreur trouvée. " &_
"Si vous avez des questions ou des problèmes liés à la sauvegarde n'hésitez pas à nous contacter"
End If
'-- Envoie d'Email --
Const cdoSendUsingMethod = _
"
http://schemas.microsoft.com/cdo/configuration/sendusing", _
cdoSendUsingPort = 2, _
cdoSMTPServer = _
"
http://schemas.microsoft.com/cdo/configuration/smtpserver"
'// Créer les connexions CDO.
Dim iMsg, iConf, Flds
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = txtSMTPServer
.Update
End With
'// Mettre les propriétés du message.
With iMsg
Set .Configuration = iConf
.To = txtTo
.From = txtFrom
.Subject = txtSubject
.TextBody = txtBody
End With
if txtlog <> "" then iMsg.AddAttachment txtLog
'// Send the message.
iMsg.Send ' send the message.
'-- Fonction de lecture du fichier --
function GetFile(txtLog)
If txtLog<>"" Then
Dim FS, FileStream
Set FS = CreateObject("Scripting.FileSystemObject")
on error resume Next
Set FileStream = FS.OpenTextFile(txtLog)
GetFile = FileStream.ReadAll
End If
End Function
__________________________________________________________________________________________
Si tu as besoin d'info n'hésite pas ;)