LostInWindows
asked on
sbs 2008 script problem
Hi all,
I am trying to write a vbscript to automatically backup my Sharepoint. I am testing it by opening a command prompt as administrator and then running the script. The script correctly creates the backup sub-directory however, it doesn't appear to launch stsadm as it doesn't create any backup files and it doesn't show as running in Taks manager - All Users.
How can I test this script and ensure it works? I have attached the script incase i made an error in it.
Thank you.
I am trying to write a vbscript to automatically backup my Sharepoint. I am testing it by opening a command prompt as administrator and then running the script. The script correctly creates the backup sub-directory however, it doesn't appear to launch stsadm as it doesn't create any backup files and it doesn't show as running in Taks manager - All Users.
How can I test this script and ensure it works? I have attached the script incase i made an error in it.
Thank you.
' Description:
' Tool for planning and automating files/entries
' Microsoft Office SharePoint Server 2007
'
' Will generate file entry names with the following style: YYYYMMDD
' E.g.: 20070228
Option Explicit
Const BackupPath = "D:\SharePoint_Backup\"
Const C_SiteURL = "http://companyweb"
Const C_NamePrefix = "SharePoint_"
Const C_SharePointBin = "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Bin"
Dim fso, folder, filedate, f, file, filesys
Dim sBackupPrefix
set filesys=CreateObject("Scripting.FileSystemObject")
Set fso = CreateObject("Scripting.FileSystemObject")
if Not fso.FolderExists(BackupPath) then
WScript.Echo "The folder " & BackupPath & " does not exist!"
WScript.Quit
end if
Set folder = fso.GetFolder(BackupPath)
filedate = now
Set f = Nothing
' Assigns a name of the new file
sBackupPrefix = BackupPath & year(now) & right("00" & Month(now),2) & right("00" & day(now),2)
Set folder = filesys.CreateFolder(sBackupPrefix)
Dim objShell
Dim strcmd
Set objShell = CreateObject("WScript.Shell")
'msgbox ("C_SiteURL = " & C_SiteURL & ", filename = " & sBackupPrefix )
'WScript.Quit
strcmd = C_SharePointBin & "\stsadm.exe -o backup -url " & C_SiteURL & " -filename " & sBackupPrefix & "\companyweb.bak -backupmethod full -includeusersecurity"
wscript.echo strcmd
objShell.Exec(strCmd)
WScript.Echo "Backup of site collection successful"
Set objshell = nothing
ASKER
I tried your suggestion and stsadm still doesn't show in Task Manager and the destination directory is still empty
OK, maybe it's command line only...try this
strcmd = "cmd /c """ & C_SharePointBin & "\stsadm.exe"" -o backup -url " & C_SiteURL & " -filename " & sBackupPrefix & "\companyweb.bak -backupmethod full -includeusersecurity"
If that doesn't work, then after that line put this
strcmd = InputBox("Prompt", "Title", strcmd)
and copy and paste that to a command line and see what it does.
Regards,
Rob.
strcmd = "cmd /c """ & C_SharePointBin & "\stsadm.exe"" -o backup -url " & C_SiteURL & " -filename " & sBackupPrefix & "\companyweb.bak -backupmethod full -includeusersecurity"
If that doesn't work, then after that line put this
strcmd = InputBox("Prompt", "Title", strcmd)
and copy and paste that to a command line and see what it does.
Regards,
Rob.
ASKER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I received the following output:
D:\SharePoint_Backup>cmd /c "C:\Program Files\Common Files\Microsoft Shared\Web
Server Extensions\12\Bin\stsadm.e xe" -o backup -url http://companyweb -filename
D:\SharePoint_Backup\20091 230\compan yweb.bak -backupmethod full -includeusersecu
rity
Command line error. Invalid parameter.
For site collection backup:
stsadm.exe -o backup
-url <url>
-filename <filename>
[-overwrite]
[-nositelock]
For catastrophic backup:
stsadm.exe -o backup
-directory <UNC path>
-backupmethod <full | differential>
[-item <created path from tree>]
[-percentage <integer between 1 and 100>]
[-backupthreads <integer between 1 and 10>]
[-showtree]
[-quiet]
[-force]
I then removed the option -includeusersecurity and the process worked.
I don't know about this user security item. I tried it before with Microsoft and it works if you type it into the command line but it will not work in a script and it will not work with copy/paste.
D:\SharePoint_Backup>cmd /c "C:\Program Files\Common Files\Microsoft Shared\Web
Server Extensions\12\Bin\stsadm.e
D:\SharePoint_Backup\20091
rity
Command line error. Invalid parameter.
For site collection backup:
stsadm.exe -o backup
-url <url>
-filename <filename>
[-overwrite]
[-nositelock]
For catastrophic backup:
stsadm.exe -o backup
-directory <UNC path>
-backupmethod <full | differential>
[-item <created path from tree>]
[-percentage <integer between 1 and 100>]
[-backupthreads <integer between 1 and 10>]
[-showtree]
[-quiet]
[-force]
I then removed the option -includeusersecurity and the process worked.
I don't know about this user security item. I tried it before with Microsoft and it works if you type it into the command line but it will not work in a script and it will not work with copy/paste.
OK, so if we omit that by changing this
strcmd = "cmd /c """ & C_SharePointBin & "\stsadm.exe"" -o backup -url " & C_SiteURL & " -filename " & sBackupPrefix & "\companyweb.bak -backupmethod full -includeusersecurity"
to this
strcmd = "cmd /c """ & C_SharePointBin & "\stsadm.exe"" -o backup -url " & C_SiteURL & " -filename " & sBackupPrefix & "\companyweb.bak -backupmethod full"
Does it work?
Rob.
strcmd = "cmd /c """ & C_SharePointBin & "\stsadm.exe"" -o backup -url " & C_SiteURL & " -filename " & sBackupPrefix & "\companyweb.bak -backupmethod full -includeusersecurity"
to this
strcmd = "cmd /c """ & C_SharePointBin & "\stsadm.exe"" -o backup -url " & C_SiteURL & " -filename " & sBackupPrefix & "\companyweb.bak -backupmethod full"
Does it work?
Rob.
ASKER
Here is the output with the -includeusersecurity removed:
D:\SharePoint_Backup>cmd /c "C:\Program Files\Common Files\Microsoft Shared\Web
Server Extensions\12\Bin\stsadm.e xe" -o backup -url http://companyweb -filename
D:\SharePoint_Backup\20091 230\compan yweb.bak -backupmethod full
Setting the site collection to be read-only for the duration of the backup. If t
he operation is interrupted, make sure to check the site lock for this site coll
ection. For more information see stsadm.exe -help getsitelock and stsadm.exe -he
lp setsitelock.
Operation completed successfully.
D:\SharePoint_Backup>cmd /c "C:\Program Files\Common Files\Microsoft Shared\Web
Server Extensions\12\Bin\stsadm.e
D:\SharePoint_Backup\20091
Setting the site collection to be read-only for the duration of the backup. If t
he operation is interrupted, make sure to check the site lock for this site coll
ection. For more information see stsadm.exe -help getsitelock and stsadm.exe -he
lp setsitelock.
Operation completed successfully.
ASKER
Thank you very much for your help. if you have any suggestions about the user security please let me know.
ASKER
Thanks for a timely and efficient solution
Thanks for the grade.
It appears that the -includeusersecurity parameter might only be valid for the Import or Export operations, not the Backup operation.
http://blogs.msdn.com/joelo/archive/2006/10/16/what-happened-to-smigrate-exe-what-if-i-only-want-to-upgrade-one-site-what-can-i-do-now-with-stsadm-exe.aspx
http://blog.techgalaxy.net/archives/993
So if you wanted to preserve the security info, try using the Export method instead.
Regards,
Rob.
It appears that the -includeusersecurity parameter might only be valid for the Import or Export operations, not the Backup operation.
http://blogs.msdn.com/joelo/archive/2006/10/16/what-happened-to-smigrate-exe-what-if-i-only-want-to-upgrade-one-site-what-can-i-do-now-with-stsadm-exe.aspx
http://blog.techgalaxy.net/archives/993
So if you wanted to preserve the security info, try using the Export method instead.
Regards,
Rob.
ASKER
Thanks, I had totally missed that. I will check it out in the morning.
strcmd = C_SharePointBin & "\stsadm.exe -o backup -url " & C_SiteURL & " -filename " & sBackupPrefix & "\companyweb.bak -backupmethod full -includeusersecurity"
to this
strcmd = """" & C_SharePointBin & "\stsadm.exe"" -o backup -url " & C_SiteURL & " -filename " & sBackupPrefix & "\companyweb.bak -backupmethod full -includeusersecurity"
Regards,
Rob.