我编写了一个脚本来备份TM1立方体系统的数据目录。该脚本创建一个新文件夹并复制文件(不包括某些文件/文件夹)。这很好。
然后脚本会压缩新文件夹。大约10分钟后,这似乎失败了。
正在备份大约2000个对象,包括一些最大3GB的多维数据集文件。在压缩之前总计约为7GB。
我一直在我的C:驱动器上测试它,并提供要备份的完整文件和结构副本。它在zip中创建了大约350个对象,包括一些立方体文件,然后失败。
错误:需要对象:'命名空间(...)'
有什么想法吗?
这是我的剧本:
' 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