Knowledgebase

Using VBScript for alternate backup locations

Expand / Collapse
 

Using VBScript for alternate backup locations



This article takes you through the steps required to enable alternate backup locations for a disk image or file and folder backup.


In a typical backup rotation scenario you may have two (or more) external USB drives that are rotated on a weekly basis. The external drive that isn't currently in use can be stored off-site for extra security.

This example assumes that you have two external USB drives that when connected to your PC, show up as drive 'E:' and drive 'F:'.  Your images of drive 'C' are saved to 'E:\Images' and 'F:\Images' and the ideal solution is for Macrium Reflect to save your image file(s) to whichever drive is currently connected to your PC.

This can be achieved by using the VBScript feature of Macrium Reflect to detect which drive is connected and run the appropriate backup definition. 

Here's how...

  1. Create two XML backup definitions. One to save the image of drive 'C' to 'E:\Images' and the other to save to 'F:\Images'. We'll call them 'Image to E.xml' and 'Image to F.xml'
     
  2. Right click on 'Image to E' and select 'Generate a VBScript file'.
     
     
     
  3. Accept all the defaults and click 'OK'.
     
  4. Click the 'VBScript' tab, right click on the VBScript file and select 'Edit'

     
     
     
  5. The file will now open in 'Notepad'. Turn of 'Word Wrap' to make editing easier...
     

     
     
  6. Edit the file in notepad as follows:
Replace the line:

ExitCode = Backup ("""C:\Program Files\Macrium\Reflect\reflect.exe"" -e -w ""c:\users\nick\documents\reflect\Image to E.xml""")

With the following lines:

If DoesDirExist("E:\") = true Then
    ExitCode = Backup ("""C:\Program Files\Macrium\Reflect\reflect.exe"" -e -w ""c:\users\nick\documents\reflect\Image to E.xml""")
Else
    ExitCode = Backup ("""C:\Program Files\Macrium\Reflect\reflect.exe"" -e -w ""c:\users\nick\documents\reflect\Image to F.xml""")
End If

Note: Replace XML path and file names with the correct names for your scenario.

At the end of the VBScript source paste the following lines:

Function DoesDirExist(byVal pathname)
    Dim objFSO
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    DoesDirExist = objFSO.FolderExists(pathname)
    Set objFSO = Nothing
End Function

 7. Save the file.

You can run VBScript files like XML files and you can schedule the VBScript file to run by right clicking on the file and selecting 'Execute' or 'Schedule'.




Tags:

Related Links




.

Details
Last Modified:Monday, August 23, 2010

Last Modified By: Administrator

Type: Tutorial

Article not rated yet.

Article has been viewed 5,499 times.

Options