PST Migration from Enterprise Vault to Commvault using TransVault

7 minute read

This one is from the vault as it goes back to 2014. I was browsing through some older projects and found this. The customer had Enterprise Vault and was migrating to Commvault OnePass for Exchange. They were exporting to PST via TransVault software and then importing it into Commvault.

When TransVault exports Symantec Enterprise Vault data to PST all of the PST’s will be located in one root folder once complete. The ownership of each PST will not match the associated user but rather will just inherit ownership of the export folder. In our customer case, all PST’s had administrators set as the owner. As such PST file ownership is not an option for associating to user mailboxes when exported from TransVault.

Since the PST permissions were of no value here it was folder structure as the process. The next best option then is to create a parent folder for each PST associating to that PST’s matching mailbox owner. In the format of \userName\pstName.pst. The name of the parent folder which matches the user’s username is used to associate the PST to the correct mailbox. This required copying the PST files to folders created for each user manually. Since this involved thousand of users and mailboxes a script was of much help. I created pstCopy.vbs to automate the process. Yes, I know VBscript! Why? I don't have a good answer other than I continued using vbscript long after everyone else had probably abandoned it but I am firmly in the PowerShell camp now. I am looking to convert the script to PowerShell.

The folder structure must be in the format of \UserName. The PST files that are under the user folder will get mapped in Commvault to the archived/protected mailbox. So for example, it would need to look something like this.

  • C:\PST\UserA\pst1.pst
  • C:\PST\UserA\pst2.pst
  • C:\PST\UserB\pst1.pst
  • C:\PST\UserB\pst2.pst
  • C:\PST\UserC\pst3.pst

TransVault creates a number of PST export file categories depending on certain scenarios when exporting from Enterprise Vault. The four primary types are listed below.

  • (User Completed Export) Recipients.UserName@domain.com_Number.pst
    • This is a completed export for the user found in Enterprise Vault with matching mailbox in Exchange. These are our primary target for import into CommVault
  • (User Partial Export) Recipients.UserName@domain.com_Number~LongNumber.pst
    • Same as above but with an additional <~Long Number > in the file name. This is an export in which TransVault experienced an event that caused a bad shutdown during export. It contains unique and valid data for that user and should be imported as well.
  • (No Active User Export) UserName@TemporaryODNforArchive .com_Number.pst
    • These are PST’s that match to user’s found in TransVault but with no matching active Exchange mailbox. These should be imported but can be matched to a user of the client’s choice. For example, a dedicated user could be created for this purpose. This data is unique and should be imported for Compliance Search
  • (No Data)
    • These are PST’s that could have any of the name formats but is either 265 KB or 0 KB which indicates an empty PST. The majority of PST’s exported in the customer case was ~39,000 of which ~37,000 matched this criteria and had no valid data. These are a part of the end of export process for TransVault and can be safely ignored. These PST’s should not be imported.

PST Archiving - Folder Creation Steps

  1. Navigate to TransVault PST Export directory and move all PST’s with no data to a dedicated folder for this purpose.
  2. Create another dedicated local source folder to manually move PST’s to for import. This step is not necessary but is good way to run an initial test and manage running the process in batches.
  3. Move a subset of PST’s to the batch import folder created in step 2
  4. Create another dedicated local folder as the target folder to where the PSTs will be moved to for import into CommVault. This target folder should then be backed up by CommVault to be ultimately imported.
  5. Copy pstCopy.vbs to the server where the PST export folder is located.
  6. Open the Cmd prompt and navigate to the directory where the PST was copied to
  7. Run the script as follows a. Csrcript pstCopy.vbs /T /source:<folder created in step 2> /destination:<folder created in step 4> ex. Cscript pstCopy.vbs /T /source:C:\PST\source /destination:C:\PST\target
  8. Once the script is completes the PSTs will be moved as follows. The script uses the username value in the file name to create the target folder structure necessary for import into CommVault. NOTE: If the source or target folders do not exist prior the script will automatically create them. a. C:\PST\source\recipients.usernameA@domain.com_Number.pst to C:\PST\target\usernameA\recipients.usernameA@domain.com_Number.pst
  9. A subclient should be created to backup the target folder. This data can then be used to archive the PST data and correctly associate to the user’s mailbox.

Script Instructions (pstCopy.vbs)

  • Scripts purpose is to move PST’s from source folder to target folder structure necessary for CommVault PST import”
  • If PST file owner set correctly then script is not necessary
  • Currently specific to only copying PSTs from TransVault migration output from Enterprise Vault.
  • Creates log directory and log file if doesn’t exist in \pstCopyLogs\pstCopy.Log
  • Creates target folder if doesn’t exist and path is valid
  • /Source - Source directory where PST’s are located. Not recursive! PST’s must be in root of directory
  • /Destination - Target main directory where PST’s are to be moved to
  • /T - Use when migrating PST’s from TransVault and Enterprise Vault”
  • Example:
    • cscript pstCopy.vbs /T /source:C:\PST\sourcedir /destination:C:\PST\targetdir

Script Contents (pstCopy.vbs)


'------------------------------------------------------------------------------------------------------------------------------------------------------------
'
' START SCRIPT
'
'------------------------------------------------------------------------------------------------------------------------------------------------------------

'Check if cscript

On Error Resume Next
checkifcscript

Set WshShell = WScript.CreateObject("WScript.Shell")
Sub checkifcscript
  strengine = LCase(Mid(WScript.FullName, InstrRev(WScript.FullName,"\")+1))
  If Not strengine="cscript.exe" Then
	wscript.echo "Use CMD cscript pstmgr.vbs <OPTIONS>"
    WScript.Quit
  End If
End Sub

'Intro Text
WScript.Echo "CommVault Professional Services"
WScript.Echo "Latest Edit: 11/17/2014"
Wscript.echo
WScript.Echo "/? or /H for Usage Instructions"
Wscript.echo
strMyComputer = "."

'Define Variables
Set dateTime = CreateObject("WbemScripting.SWbemDateTime")					
Set objFSO = CreateObject("Scripting.FileSystemObject")								
Set colNamedArguments = WScript.Arguments.Named
SourceFolder = colNamedArguments.Item("Source")
TargetFolder = colNamedArguments.Item("Destination")
booTransVaultEV = colNamedArguments.Exists("T")


'************************************************LOGGING**********************************************************************************
'Set logging variables
strDirectory = "pstCopylogs"
strFile = "\pstCopy.log"
CurrentDate = Now

'Check if log directory already exists. If not create it.
If objFSO.FolderExists(strDirectory) Then
	Set objFolder = objFSO.GetFolder(strDirectory)
	Else
	Set objFolder = objFSO.CreateFolder(strDirectory)
End If

'Check if log file already exists. If not create it.
If objFSO.FileExists(strDirectory & strFile) Then
	Set objFolder = objFSO.GetFolder(strDirectory)
	Else
	Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
End If

set objFile = nothing
set objFolder = Nothing

' ForAppending = 8 ForReading = 1, ForWriting = 2
Const ForAppending = 8

'Open log file for appending
Set objReportFile = objFSO.OpenTextFile (strDirectory & strFile, ForAppending, True)

objReportFile.WriteBlankLines(2)

objReportFile.WriteLine("----------------------------------------------------------------------------------------------------------------------")
objReportFile.WriteLine("							SCRIPT RUN: " & FormatDateTime(CurrentDate, vbGeneralDate))
objReportFile.WriteLine("----------------------------------------------------------------------------------------------------------------------")

objReportFile.WriteBlankLines(2)


'*********************************************ARGUMENTS*******************************************************************************
'Check if /H /? option provided
If colNamedArguments.Exists("H") OR colNamedArguments.Exists("?") Then
  Call Usage()
  WScript.Quit
End If



'Check for valid source and target folders
If objFSO.FolderExists(SourceFolder) Then
	wscript.echo "Source Folder Exists!"
	objReportFile.WriteLine ("Source Folder Exists!")
	wscript.echo
	Else
	wscript.echo "No Source Folder! Quit Script"
	objReportFile.WriteLine ("No Source Folder! Quit Script")
	wscript.quit
End If

If objFSO.FolderExists(TargetFolder) Then
	wscript.echo "Target Folder Exists!"
	wscript.echo
	objReportFile.WriteLine ("Target Folder Exists!")
	Else
			Err.Clear
			Set objFolder = objFSO.CreateFolder(TargetFolder)
			If Err.number <> 0 Then
			wscript.echo "Target Path Creation not possible! Provide valid path"
			objReportFile.WriteLine ("Target Path Creation not possible! Provide valid path")
			DisplayErrorInfo
			wscript.echo TargetFolder
			wscript.quit
			Else
			wscript.echo "Target Folder doesn't exist. Target Folder Created!"
			objReportFile.WriteLine ("Target Folder doesn't exist. Target Folder Created!")

		End If

End If

 If booTransVaultEV Then 'Use recursive search
 TransVault
 End If

'************************************************MOVE FILES (TransVault)*************************************************************************************

Sub TransVault
'Find regular Expression pattern
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Global = True
objRegEx.Pattern = "Recipients(\.\w{1,})"
'Set Variables
Set objFolder = objFSO.GetFolder(SourceFolder)
Set colFiles = objFolder.Files
'Err.Clear
'Create target path and copy file to target path
For Each objFile in colFiles
    strSearchString = objFile.Name
	strSearchStringPath = objFile.Path
    Set colMatches = objRegEx.Execute(strSearchString)  

    For Each strMatch in colMatches
        strFolderName = strMatch.Value
		'wscript.echo strFolderName
		finalName = Replace(strFolderName, "Recipients.", "")
		'wscript.echo finalName
        strFolderName = TargetFolder & "\" & finalName & "\"
		'wscript.echo strFolderName
        If Not objFSO.FolderExists(strFolderName) Then
            Set objNewFolder = objFSO.CreateFolder(strFolderName)
        End If


	'Move to target path
	If Not objFSO.FileExists(strFolderName & strSearchString) Then
    objFSO.MoveFile objFile.Path, strFolderName
	objReportFile.WriteLine("Moved the PST file from:   " & strSearchStringPath & " To: " & strFolderName)
	wscript.echo "Moved the PST file from:   " & strSearchStringPath & " To: " & strFolderName
	End If
	Next
Next

End Sub




'For errors
Sub DisplayErrorInfo

    WScript.Echo "Error:      : " & Err
    WScript.Echo "Error (hex) : &H" & Hex(Err)
    WScript.Echo "Source      : " & Err.Source
    WScript.Echo "Description : " & Err.Description
	objReportFile.WriteLine ("Error:      : " & Err)
	objReportFile.WriteLine ("Error (hex) : &H" & Hex(Err))
	objReportFile.WriteLine ("Source      : " & Err.Source)
	objReportFile.WriteLine ("Description : " & Err.Description)
    Err.Clear

End Sub

'******************************************************************USAGE INSTRUCTIONS***********************************************************************

Sub Usage()

	Wscript.Echo "********************pstCopy.vbs INFO**********************"
	WScript.Echo "** Scripts purpose is to move PST's from source folder to target folder structure necessary for CommVault PST import"
	WScript.Echo "** If PST file owner set correctly then script is not necessary."
	WScript.Echo "** Currently specific to only copying PSTs from TransVault migration output from Enterprise Vault.
	WScript.Echo "** Creates log directory and log file if doesn't exist in  <directory where script is run>\pstCopyLogs\pstCopy.Log"
	WScript.Echo "** Creates target folder if doesn't exist and path is valid"
	WScript.Echo
	WScript.Echo "   /Source - Source directory where PST's are located. Not recursive! PST's must be in root of directory"
	WScript.Echo "   /Destination - Target main directory where PST's are to be moved to"
	WScript.Echo "   /T - Use when migrating PST's from TransVault and Enterprise Vault"
	wscript.echo "   Example: cscript pstCopy.vbs /T /source:C:\PST\sourcedir /destination:C:\PST\targetdir"

End Sub



'------------------------------------------------------------------------------------------------------------------------------------------------------------
'
' END SCRIPT
'
'------------------------------------------------------------------------------------------------------------------------------------------------------------