There are 2 replies, with the last one on June 13 2014 at 19:45:54 by GlennChambers
Quote:
Hi,
I use Robocopy to create a duplicate then create log file. Here is an example of my code. Maybe it can give you some idea's
Quote:
Hi,
I use Robocopy to create a duplicate then create log file. Here is an example of my code. Maybe it can give you some idea's
Sub VBMain() Dim objShell Dim ExitCode Dim StrSource ' Elevate this script for Admin privileges in Vista Elevate Set objShell = WScript.CreateObject("WScript.Shell") ' Do the backup ''If Weekday(Date) = 2 AND Month(DateAdd("d", -7, Date)) <> Month(Date) Then ' Run the full image ExitCode = Backup ("""C:\Program Files\Macrium\Reflect\reflect.exe"" -e -w <BACKUP_TYPE> ""C:\Users\glenn_000\Documents\Reflect\My PC Documents Folder Backup.xml""") ExitCode = Backup ("""C:\Program Files\Macrium\Reflect\Reflect.exe"" -e -w <BACKUP_TYPE> ""C:\Users\glenn_000\Documents\Reflect\My FSX Backup.xml""") ExitCode = Backup ("""C:\Program Files\Macrium\Reflect\reflect.exe"" -e -w <BACKUP_TYPE> ""C:\Users\glenn_000\Documents\Reflect\My Windows System Backup.xml""") ExitCode = Backup ("""C:\Program Files\Macrium\Reflect\reflect.exe"" -e -w <BACKUP_TYPE> ""C:\Users\glenn_000\Documents\Reflect\My Images Backup.xml""") ExitCode = Backup ("""C:\Program Files\Macrium\Reflect\Reflect.exe"" -e -w <BACKUP_TYPE> ""C:\Users\glenn_000\Documents\Reflect\My VirtualBox Backups.xml""") ''End If ' Make sure the backup drive is mapped to Z so that the files can be copied. MapNetworkDriveBackups ' Copy the file(s) just created to NAS or External USB Drive CopyToSecondaryDestination ' done Set objShell = nothing wscript.quit(ExitCode) End Sub Sub MapNetworkDriveBackups 'Define Objects Dim objNetwork,strSoftwareFolder,strHomeServer,colDrives,i,strBackupLetter,strBackupFolder,objShell ' Instantiate Objects Set objFileSystem = CreateObject("Scripting.FileSystemObject") Set objNetwork = CreateObject("WScript.Network") Set objShell = WScript.CreateObject("WScript.Shell") On Error Resume Next 'Enumerate network drives into a collection object so we know what drives are already mapped. Set colDrives = WSHNetwork.EnumNetworkDrives strBackupLetter = "Z:" strHomeServerUNC = "\\DS112\" strHomeServerIP = "\\192.168.2.4\" strHomeServer = "\\192.168.2.1\" strBackupFolder = "backup" 'If there are more than 0 drives... If colDrives.Count <> 0 Then ' Check the drives to see if any of the drive letters to be mapped are already in use, if they are, disconnect them. For i = 0 To colDrives.count - 1 Step 2 If (ColDrives(i) = strBackupLetter) Then WshNetwork.RemoveNetworkDrive colDrives(i) End If Next End If 'Z:\ Map Software drive to Z using IP , if this fails try UNC path objNetwork.MapNetworkDrive strBackupLetter, strHomeServerIP & strBackupFolder If Err.Number <> 0 Then objNetwork.MapNetworkDrive strBackupLetter, strHomeServerUNC & strBackupFolder Else If Err.Number <> 0 then MsgBox "Got Error#" & Err.Number & ": " & Err.Description End If End If 'End of Drive Mapping Section add more vbs commands below if needed. Set objNetwork = nothing Set WSHNetwork = nothing '----- End Sub Sub CopyToSecondaryDestination Dim objShell, objFSO, objLogFile, WshShell Set WshShell = Wscript.CreateObject("WScript.Shell") ' // For Documents Backups WshShell.run "cmd /C robocopy L:\My_Backups\Reflect_PC_Documents\ *Documents* \\192.168.2.4\backup\Reflect_PC_Documents\ /xo /PURGE /v /fp /njh /NP /COPY:DAT /log+:C:\Users\glenn_000\Documents\CopyFile.log",0,True ' // For FSX Drive Image Backups WshShell.run "cmd /C robocopy D:\FSX_Images\ *FSX* \\192.168.2.4\backup\Reflect_PC_FSX_Images\ /xo /PURGE /v /fp /njh /NP /COPY:DAT /log+:C:\Users\glenn_000\Documents\CopyFile.log",0,True ' // For Windows 8.1 System Drive Image Backups WshShell.run "cmd /C robocopy D:\Windows_System_Images\ *8.1* \\192.168.2.4\backup\Reflect_PC_Windows_System_Images\ /xo /PURGE /v /fp /njh /NP /COPY:DAT /log+:C:\Users\glenn_000\Documents\CopyFile.log",0,True ' // For Photo Backups WshShell.run "cmd /C robocopy L:\My_Backups\Reflect_PC_Photos\ *Photo* \\192.168.2.4\backup\Images\ /xo /PURGE /v /fp /njh /NP /COPY:DAT /log+:C:\Users\glenn_000\Documents\CopyFile.log",0,True ' // For VirtualBox Snapshot Backups WshShell.run "cmd /C robocopy L:\My_Backups\Reflect_PC_Virtual_Box_Snaphots\ *VirtualBox* \\192.168.2.4\backup\Reflect_PC_VirtualBox /xo /PURGE /v /fp /njh /NP /COPY:DAT /log+:C:\Users\glenn_000\Documents\CopyFile.log",0,True ' Run the MD5 check once a week on a Saturday. Set WshShell = nothing End Sub