I have written a script to backup a data directory of our TM1 cube system. The script creates a new folder and copies files across (excluding some files / folders). This works fine.
The script then zips the new folder. This seems to fail after around 10 minutes.
Around 2000 objects are being backed up, including some cube files which are up to 3GB in size. Total is around 7GB before zipping.
I have been testing this on my C: drive with a full copy of files and structure to be backed up. It creates around 350 objects, including some of the cube files, in the zip and then fails.
ERROR: Object required: 'Namespace(...)'
Any ideas?
Here is my script:
' http://stackoverflow.com/questions/15139761/zip-a-folder-up
' ArchiveFolder "E:\Tm1dev9\Backups\Friday.zip", "E:\Tm1dev9\Backups\Friday"
' ***** Varialbles to set ******
'
strWeekday = weekday(now())-1
strSourceFolder = "C:\Temp\TM1\ZipTesting\TM1_Data" ' do not use backslash at end
strDestFolder = "C:\Temp\TM1\ZipTesting\Day" & strWeekday ' do not use backslash at end
strExclude = "C:\Temp\TM1\ZipTesting\ExcludeList.txt"
strZipFile = "C:\Temp\TM1\ZipTesting\Day" & strWeekDay & ".zip"
dim fso
dim objShell
dim blnFinished
Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
CopyFiles
WScript.Sleep 2000
ArchiveFolder strZipFile, strDestFolder
' Copy contents over to a backup folder excluding items in 'ExcludeList.txt'
Sub CopyFiles()
If fso.FolderExists(strDestFolder) Then
fso.DeleteFolder strDestFolder
End If
If fso.FileExists (strZipFile) Then
fso.DeleteFolder strZipFile
End If
objShell.run "xcopy " & strSourceFolder & "\*.* " & chr(34) & strDestFolder & "\*.*" & chr(34) & " /d /e /c /g /h /r /y /EXCLUDE:" & strExclude , 1, TRUE
End Sub
' Create Zip file from backup folder, then delete backup folder
Sub ArchiveFolder (zipFile, sFolder)
With CreateObject("Scripting.FileSystemObject")
zipFile = .GetAbsolutePathName(zipFile)
sFolder = .GetAbsolutePathName(sFolder)
With .CreateTextFile(zipFile, True)
.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, chr(0))
End With
End With
WScript.Sleep 2000
With CreateObject("Shell.Application")
.NameSpace(zipFile).CopyHere .NameSpace(sFolder).Items
Do Until .NameSpace(zipFile).Items.Count = _
.NameSpace(sFolder).Items.Count
WScript.Sleep 1000
Loop
End With
'WScript.Sleep 1000
If fso.FolderExists(strDestFolder) Then
fso.DeleteFolder strDestFolder
End If
End Sub