Backup duplicate file issue
Hello,
We are experiencing an issue with using a script where we get duplicate .pst files during the backup. I was wondering if anyone had any ideas on what may be causing this?
We are using Roaming Profiles on XP SP3, with the H: drive being the users Home folder (My documents redirected) with offline caching of "H:\Data". This is occuring on Windows Server 2000 all the way up to 2008 R2 so it doesn't seem to be an NOS specific
item.
Here is a dir output of an example directory:
Directory of D:\Users\USERID\Backup\program\microsoft\Outlook
08/01/2011 08:26 AM <DIR> .
08/01/2011 08:26 AM <DIR> ..
12/17/2010 02:01 PM 18,555,904 archive (USERID v1).pst
03/10/2011 11:30 AM 18,809,856 archive (USERID v10).pst
03/16/2011 10:42 AM 18,809,856 archive (USERID v11).pst
04/11/2011 08:47 AM 18,809,856 archive (USERID v12).pst
04/14/2011 07:59 AM 18,809,856 archive (USERID v13).pst
05/20/2011 10:45 AM 18,809,856 archive (USERID v14).pst
06/07/2011 11:03 AM 18,809,856 archive (USERID v15).pst
07/01/2011 12:50 PM 18,809,856 archive (USERID v16).pst
07/27/2011 03:51 PM 18,809,856 archive (USERID v17).pst
12/23/2010 10:06 AM 18,809,856 archive (USERID v2).pst
01/05/2011 10:04 AM 18,809,856 archive (USERID v3).pst
01/12/2011 06:43 PM 18,809,856 archive (USERID v4).pst
01/14/2011 05:47 PM 18,809,856 archive (USERID v5).pst
01/31/2011 12:35 PM 18,809,856 archive (USERID v6).pst
02/01/2011 03:38 PM 18,809,856 archive (USERID v7).pst
02/09/2011 04:35 PM 18,809,856 archive (USERID v8).pst
03/07/2011 09:19 AM 18,809,856 archive (USERID v9).pst
07/18/2011 05:38 PM 18,809,856 archive.pst
12/17/2010 11:41 AM 16,270,336 archive1 (USERID v1).pst
03/07/2011 09:18 AM 6,620,160 archive1 (USERID v10).pst
03/10/2011 11:30 AM 6,620,160 archive1 (USERID v11).pst
03/16/2011 10:34 AM 6,620,160 archive1 (USERID v12).pst
04/11/2011 08:46 AM 6,620,160 archive1 (USERID v13).pst
04/14/2011 07:59 AM 6,620,160 archive1 (USERID v14).pst
04/29/2011 03:34 PM 6,620,160 archive1 (USERID v15).pst
05/20/2011 10:45 AM 6,620,160 archive1 (USERID v16).pst
06/07/2011 11:02 AM 6,620,160 archive1 (USERID v17).pst
06/20/2011 01:49 PM 6,620,160 archive1 (USERID v18).pst
07/01/2011 11:42 AM 6,620,160 archive1 (USERID v19).pst
12/17/2010 02:01 PM 16,270,336 archive1 (USERID v2).pst
07/27/2011 03:26 PM 6,620,160 archive1 (USERID v20).pst
12/23/2010 10:05 AM 16,270,336 archive1 (USERID v3).pst
01/05/2011 10:00 AM 16,270,336 archive1 (USERID v4).pst
01/12/2011 06:43 PM 6,620,160 archive1 (USERID v5).pst
01/14/2011 05:47 PM 6,620,160 archive1 (USERID v6).pst
01/31/2011 12:35 PM 6,620,160 archive1 (USERID v7).pst
02/01/2011 03:38 PM 6,620,160 archive1 (USERID v8).pst
02/09/2011 04:35 PM 6,620,160 archive1 (USERID v9).pst
07/18/2011 05:38 PM 6,620,160 archive1.pst
05/20/2011 10:45 AM 18,555,904 archive2 (USERID v1).pst
06/07/2011 11:02 AM 18,555,904 archive2 (USERID v2).pst
07/01/2011 11:42 AM 20,587,520 archive2 (USERID v3).pst
07/27/2011 03:26 PM 22,619,136 archive2 (USERID v4).pst
07/18/2011 05:38 PM 20,587,520 archive2.pst
12/30/2010 11:31 AM 2,150,990,848 older files storage (USERID v1).pst
01/14/2011 05:53 PM 2,377,262,080 older files storage (USERID v2).pst
01/17/2011 11:18 AM 2,377,262,080 older files storage (USERID v3).pst
04/11/2011 09:21 AM 2,426,020,864 older files storage (USERID v4).pst
04/12/2011 02:47 PM 2,426,020,864 older files storage (USERID v5).pst
04/13/2011 08:18 AM 2,426,020,864 older files storage (USERID v6).pst
04/13/2011 04:37 PM 2,426,020,864 older files storage (USERID v7).pst
04/14/2011 08:02 AM 2,442,273,792 older files storage (USERID v8).pst
07/01/2011 12:53 PM 2,686,575,616 older files storage (USERID v9).pst
07/27/2011 11:52 AM 2,728,731,648 older files storage.pst
08/01/2011 08:26 AM 0 pst.txt
07/27/2011 03:29 PM 1,463,288,832 USERID (USERID v1).pst
07/01/2011 11:25 AM 1,419,101,184 USERID.pst
07/01/2011 01:33 PM 1,209,336,832 USERID_2 (USERID v1).pst
07/27/2011 05:55 PM 1,208,828,928 USERID_2 (USERID v2).pst
01/04/2011 04:54 PM 86,107,136 USERID_2.pst
60 File(s) 30,470,695,936 bytes
2 Dir(s) 69,710,946,304 bytes free
Here is our script:
' Version 1.1
'*******************************************************************************
'* Script name: BackupPST.vbs
'* Purpose: This script copies all Outlook .pst files that are stored locally
'* On the Computer to the user home folder.
'* The script is triggered by the user.
' -[ History ]----------------------------------------------------------------
' ----------------------------------------------------------------------------
'*******************************************************************************
Option Explicit
'*******************
'* Define Constants
'*******************
'********************
'* Declare variables
'********************
Dim objWSH
Dim objFSO
Dim colSystemEnvVars
Dim strUserProfile
Dim strSourceFolder
Dim strTargetFolder
Dim strHomeShare
Dim objOutlook
Dim objTrue
Dim Explanation
Dim strComputerName
Dim BtnCode
'**********************************************
'* Create objects
'**********************************************
Set objWSH = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colSystemEnvVars = objWSH.Environment("Process")
'**********************************************
'* Set Variables
'**********************************************
BtnCode = objWSH.Popup("Do you want to backup your PST files?", , "Backup of PST -files:", 4 + 32)
Select Case BtnCode
Case 7 Wscript.Quit(0)
End Select
strComputerName = colSystemEnvVars("ComputerName")
objTrue = CheckProcess (strComputerName, "Outlook.exe")
If objTrue = True Then
objWSH.Popup "Microsoft Outlook is running on your computer. You must close Outlook before you can backup your PST files", , "Backup of PST -files:", 16
Wscript.Quit(0)
End If
strUserProfile = colSystemEnvVars("USERPROFILE")
strHomeShare = colSystemEnvVars("HomeShare")
strSourceFolder = strUserProfile & "\Local Settings\Application Data\Microsoft\Outlook"
strTargetFolder = strHomeShare & "\Backup\program\microsoft\Outlook"
'*********************************************************************************
'* Copy all .pst files from the local user profile to the backup folder on the
'* user home -folder. THe backup folder will be created if it not exists.
'**********************************************************************************
' Create the Backup -folder, if it not exists
If Not objFSO.FolderExists(strTargetFolder) Then
objWSH.Run "CMD /c mkdir " & strTargetFolder, 7, True
End If
' Copy all local .pst -files to the backup folder
If objFSO.FolderExists(strSourceFolder) Then
objWSH.Run "CMD /c xcopy " & Chr(34) & strSourceFolder & "\*.pst" & Chr(34) & " " &_
Chr(34) & strTargetFolder & Chr(34) & " /V /c /H /Y", 7, True
End If
'Timestamp the backup
objWSH.RegWrite "HKEY_CURRENT_USER\Software\SCA\Outlook\PSTBackup\LastBackup", Now, "REG_SZ"
objWSH.Popup "Backup is completed!",,"Backup of PST -files:",64
'**********************************************
'*
'* Function library
'*
'**********************************************
Function CheckProcess( strComputer, strProcess )
' This function checks if the process, specified by strProcess, is running on
' the machine specified by strComputer. It only works for Windows 2000 or higher.
On Error Resume Next
Dim objWmi
Dim objProcess
Dim collProcesses
Dim strQuery
set objWmi = GetObject("winmgmts://" & strComputer )
If( Err.Number <> 0 ) Then
CheckProcess = retvalUnknown
EXPLANATION = "Unable to access '" & strComputer & "'. Possible reasons: no WMI installed on the remote server, no rights to access remote WMI service, or remote server down"
Exit Function
End If
strQuery = "select * from win32_process"
set collProcesses = objWmi.ExecQuery( strQuery )
If( collProcesses.Count = 0 ) Then
CheckProcess = retvalUnknown
EXPLANATION = "Unable to list processes on computer '" & strComputer & "'"
Exit Function
End If
For Each objProcess in collProcesses
If( Err.Number <> 0 ) Then
CheckProcess = retvalUnknown
EXPLANATION = "Unable to list processes on computer '" & strComputer & "'"
Exit Function
End If
If UCase( objProcess.Name ) = UCase( strProcess ) Then
CheckProcess = True
EXPLANATION = "Process '" & strProcess & "' is running on computer '" & strComputer & "'"
Exit Function
End If
Next
CheckProcess = False
EXPLANATION = "Process '" & strProcess & "' is not running on computer '" & strComputer & "'"
End Function
August 8th, 2011 12:07pm
Hello,
for scripting questions ask them here: http://social.technet.microsoft.com/Forums/en-US/ITCG/threads
This
posting is provided "AS IS" with no warranties or guarantees , and confers no rights.
Microsoft Student
Partner 2010 / 2011
Microsoft Certified Professional
Microsoft Certified Systems Administrator:
Security
Microsoft Certified Systems Engineer:
Security
Microsoft Certified Technology Specialist:
Windows Server 2008 Active Directory, Configuration
Microsoft Certified Technology Specialist:
Windows Server 2008 Network Infrastructure, Configuration
Microsoft Certified Technology Specialist:
Windows Server 2008 Applications Infrastructure, Configuration
Microsoft Certified Technology Specialist:
Windows 7, Configuring
Microsoft Certified IT Professional: Enterprise
Administrator
Microsoft Certified IT Professional: Server Administrato
Free Windows Admin Tool Kit Click here and download it now
August 8th, 2011 3:27pm
It seems the problem with looping structure of your program.
In addition to Mr. X you can also post your query on
VB Forum.
Thanks
August 8th, 2011 6:33pm


