03-02-2012 01:28 AM
I saw the backup scripts that is in window cmd file to put EV into the backup mode. I was wondering, has anyone converted that to a vbs? I can run the command in VBS, but the output is blank when using the the windows redirect.
Solved! Go to Solution.
03-05-2012 06:11 PM
Ok, i switched the script to Powershell. I found a netapp script that will backup the LUNS which I am calling within this script. Does someone have a better script that is able to put the devices in backupmode and take a Snapshot of the LUNS?
Also, I put the program to sleep for 30 minutes to provide ample time for my SQL backups to complete.
Here is the code written in PowerShell:
$date = (Get-Date).toString('dd-MM-yyyy_hh_mm_ss')
$OutFile="D:\Scripts\Logs\BackupLog_$date.txt"
New-Item –ItemType file $OutFile
$oldfilename="L:\Enterprise Vault Stores\SiteExchangeVS Ptn1\ignorearchivebittrigger.old"
If (Test-Path $oldfilename)
{
Remove-Item $oldfilename
Add-Content $OutFile "Deleted $oldfilename"
}
Add-Content $OutFile "--------------------Starting Setting BU Mode--------------------`r`n"
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile "D:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Clear-
VaultStoreBackupMode -Name EVSite -EVServerName evserver.domain.com -EVObjectType Site}" 2>&1 >> $OutFile
Add-Content $OutFile "`r`n--------------------Finished Setting BU Mode--------------------`r`n"
Add-Content $OutFile "`r`n---------Set Backup Mode on vault store group-------------`r`n"
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile "D:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Set-
VaultStoreBackupMode -Name 'Exchange Group' -EVServerName evserver.domain.com -EVObjectType VaultStoreGroup}" 2>&1 >> $OutFile
Add-Content $OutFile "`r`n--------------------Finished Setting Backup Mode on vault store group--------------------`r`n`r`n"
Add-Content $OutFile "`r`n---------Set backup mode on vault store-------------`r`n"
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile "D:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Set-
VaultStoreBackupMode -Name SiteExchangeVS -EVServerName evserver.domain.com -EVObjectType VaultStore}" 2>&1 >> $OutFile
Add-Content $OutFile "`r`n--------------------Finished Setting Backup Mode on vault store--------------------`r`n`r`n"
Add-Content $OutFile "`r`n ---------Set backup mode on indexes in site-------------`r`n"
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile "D:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Set-
IndexLocationBackupMode -EVServerName evserver.domain.com -EVSiteName EVSite}" 2>&1 >> $OutFile
Add-Content $OutFile "`r`n ---------Finished Setting backup mode on indexes in site-------------`r`n`r`n"
Add-Content $OutFile "`r`n--------------------End Setting BU Mode--------------------`r`n`r`n"
Add-Content $OutFile "--------------------Setting Powershell Execution Policy--------------------`r`n"
Set-ExecutionPolicy RemoteSigned
Add-Content $OutFile "`r`n--------------------Finished Setting Powershell Execution Policy--------------------`r`n`r`n"
Add-Content $OutFile "`r`n--------------------Starting LUN SnapShot Script--------------------`r`n"
cscript.exe d:\scripts\snapshot.vbs 2>&1 >>$OutFile
Add-Content $OutFile "`r`n--------------------Finished LUN SnapShot Script--------------------`r`n`r`n"
Add-Content $OutFile "`r`n--------------------Starting Sleep Mode for 30 Minutes----------------`r`n`r`n"
Start-Sleep -s 1800
Add-Content $OutFile "`r`n--------------------Starting Clearing BU Mode--------------------`r`n`r`n"
Add-Content $OutFile "`r`n--------------------Creating New Trigger File--------------------`r`n"
New-Item –ItemType file "L:\Enterprise Vault Stores\SiteExchangeVS Ptn1\ignorearchivebittrigger.txt" 2>&1 >> $OutFile
Add-Content $OutFile "`r`n--------------------Finsihed Creating New Trigger File--------------------`r`n`r`n"
Add-Content $OutFile "`r`n----------Clear backup mode from site-------------`r`n"
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile "D:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Clear-
VaultStoreBackupMode -Name EVSite -EVServerName evserver.domain.com -EVObjectType Site}" 2>&1 >> $OutFile
Add-Content $OutFile "`r`n----------Finished Clearing backup mode from site-------------`r`n`r`n"
Add-Content $OutFile "`r`n---------Clear backup mode from vault store group-------------`r`n"
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile "D:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Clear-
VaultStoreBackupMode -Name 'Exchange Group' -EVServerName evserver.domain.com -EVObjectType VaultStoreGroup}" 2>&1 >> $OutFile
Add-Content $OutFile "`r`n---------Finished Clearing backup mode from vault store group-------------`r`n`r`n"
Add-Content $OutFile "`r`n---------Clear backup mode from vault store-------------`r`n"
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile "D:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Clear-
VaultStoreBackupMode -Name SiteExchangeVS -EVServerName evserver.domain.com -EVObjectType VaultStore}" 2>&1 >> $OutFile
Add-Content $OutFile "`r`n---------Finished Clearing backup mode from vault store-------------`r`n`r`n"
Add-Content $OutFile "`r`n---------Clear backup mode from indexes in site-------------`r`n"
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile "D:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Clear-
IndexLocationBackupMode -EVServerName evserver.domain.com -EVSiteName EVSite}" 2>&1 >> $OutFile
Add-Content $OutFile "`r`n---------Finsished Clearing backup mode from indexes in site-------------`r`n`r`n"
Add-Content $OutFile "`r`n--------------------End Clearing BU Mode--------------------`r`n`r`n"
Add-Content $OutFile "`r`n--------------------Program Finished--------------------`r`n`r`n"
03-02-2012 02:58 AM
Why would you like to use a VBS script ?
Putting EV into backup mode is done by PowerShell commands, so normally it should not be difficult to create a vbs script with PowerShell commands.
03-02-2012 04:43 AM
I know, but when i tried "C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile D:\Program Files (x86)\Enterprise Vault\EVShell.psc1 -command "& {Clear-VaultStoreBackupMode -Name EVSite -EVServerName evserver1 -EVObjectType Site}>> D:\scripts\logs\logs.txt" it runs sucessfully but the logs of the powershell does not get captured by the logs.
03-02-2012 07:07 AM
This looks like it will help you http://www.activexperts.com/activmonitor/windowsmanagement/powershell10/0098/
03-02-2012 07:44 AM
The issue is that the powershell errors will be part of powershell and not the batch/command line run.
So you need to capture the errors from within powershell and not the command line.
So to take your command you could do:
"C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile D:\Program Files (x86)\Enterprise Vault\EVShell.psc1 -command "& {Clear-VaultStoreBackupMode -Name EVSite -EVServerName evserver1 -EVObjectType Site >>D:\scripts\logs\logs.txt; $error>>D:\scripts\logs\logs.txt}
So the first >>D:\scripts\logs\logs.txt will just capture the standard output
Then there is a second command being run which is used to output the $error variable (if any) to the same file "; $error>>D:\scripts\logs\logs.txt".
You should be able to use 2>>D:\scripts\logs\logs.txt (2 is the normal error stream in powershell) but for some reason the indexbackupmode errors are not captured in that stream but the $error variable do get updated.
Which is why I've added that second command.
Hope that helps.
Fredrik
03-02-2012 08:39 AM
The solution sounds good, but it errors with invalid charachters.
03-02-2012 09:34 AM
Worked for me, I can see in the copy/paste that a " is missing at the end.
So maybe that is the reason if you didn't add it yourself.
Worked for me when I tested it :)
03-05-2012 10:00 AM
This is my line of code:
cmdSite="C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile " & chr(34) & "D:\Program Files (x86)\Enterprise Vault\EVShell.psc1" & chr(34) & " -command " & chr(34) & "& {Set-VaultStoreBackupMode -Name EVSite -EVServerName evservername -EVObjectType Site >>" & sWorkingFileName & "; $error >>"& sWorkingFileName & "}"
The command runs without errors.
The file gets created, but nothing shows up in the file. The variable sWorkingFileName does work since if I do an echo of the command and copy the output directly into a command window, the log file gets created with the following text "S u c c e s s f u l l y s e t b a c k u p m o d e o n t h e v a u l t s t o r e s o n E n t e r p r i s e V a u l t s e r v e r ' e v servername .domain . c o m ' .
S u c c e s s f u l l y s e t b a c k u p m o d e o n a l l v a u l t s t o r e s i n s i t e ' E V S i t e ' .
This is the command when I do any echo to display. If I copy and paste the below command in a cmd window, it works great.
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile "D:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Set-VaultStoreBackupMode -Name EVSite -EVServerName evservername -EVObjectType Site >>D:\Scripts\Logs\Backuplog20120305-125506.txt; $error >>D:\Scripts\Logs\Backuplog20120305-125506.txt}
03-05-2012 01:50 PM
So if I understand you correctly the command works from command line but not when it's launched from the vbscript ?
Any reason why you need to use vbscript at all?
Also if there are no errors then there is no error text added to the file.
So what happens if you use the wrong server name so that you know that the command will fail?
03-05-2012 06:11 PM
Ok, i switched the script to Powershell. I found a netapp script that will backup the LUNS which I am calling within this script. Does someone have a better script that is able to put the devices in backupmode and take a Snapshot of the LUNS?
Also, I put the program to sleep for 30 minutes to provide ample time for my SQL backups to complete.
Here is the code written in PowerShell:
$date = (Get-Date).toString('dd-MM-yyyy_hh_mm_ss')
$OutFile="D:\Scripts\Logs\BackupLog_$date.txt"
New-Item –ItemType file $OutFile
$oldfilename="L:\Enterprise Vault Stores\SiteExchangeVS Ptn1\ignorearchivebittrigger.old"
If (Test-Path $oldfilename)
{
Remove-Item $oldfilename
Add-Content $OutFile "Deleted $oldfilename"
}
Add-Content $OutFile "--------------------Starting Setting BU Mode--------------------`r`n"
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile "D:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Clear-
VaultStoreBackupMode -Name EVSite -EVServerName evserver.domain.com -EVObjectType Site}" 2>&1 >> $OutFile
Add-Content $OutFile "`r`n--------------------Finished Setting BU Mode--------------------`r`n"
Add-Content $OutFile "`r`n---------Set Backup Mode on vault store group-------------`r`n"
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile "D:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Set-
VaultStoreBackupMode -Name 'Exchange Group' -EVServerName evserver.domain.com -EVObjectType VaultStoreGroup}" 2>&1 >> $OutFile
Add-Content $OutFile "`r`n--------------------Finished Setting Backup Mode on vault store group--------------------`r`n`r`n"
Add-Content $OutFile "`r`n---------Set backup mode on vault store-------------`r`n"
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile "D:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Set-
VaultStoreBackupMode -Name SiteExchangeVS -EVServerName evserver.domain.com -EVObjectType VaultStore}" 2>&1 >> $OutFile
Add-Content $OutFile "`r`n--------------------Finished Setting Backup Mode on vault store--------------------`r`n`r`n"
Add-Content $OutFile "`r`n ---------Set backup mode on indexes in site-------------`r`n"
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile "D:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Set-
IndexLocationBackupMode -EVServerName evserver.domain.com -EVSiteName EVSite}" 2>&1 >> $OutFile
Add-Content $OutFile "`r`n ---------Finished Setting backup mode on indexes in site-------------`r`n`r`n"
Add-Content $OutFile "`r`n--------------------End Setting BU Mode--------------------`r`n`r`n"
Add-Content $OutFile "--------------------Setting Powershell Execution Policy--------------------`r`n"
Set-ExecutionPolicy RemoteSigned
Add-Content $OutFile "`r`n--------------------Finished Setting Powershell Execution Policy--------------------`r`n`r`n"
Add-Content $OutFile "`r`n--------------------Starting LUN SnapShot Script--------------------`r`n"
cscript.exe d:\scripts\snapshot.vbs 2>&1 >>$OutFile
Add-Content $OutFile "`r`n--------------------Finished LUN SnapShot Script--------------------`r`n`r`n"
Add-Content $OutFile "`r`n--------------------Starting Sleep Mode for 30 Minutes----------------`r`n`r`n"
Start-Sleep -s 1800
Add-Content $OutFile "`r`n--------------------Starting Clearing BU Mode--------------------`r`n`r`n"
Add-Content $OutFile "`r`n--------------------Creating New Trigger File--------------------`r`n"
New-Item –ItemType file "L:\Enterprise Vault Stores\SiteExchangeVS Ptn1\ignorearchivebittrigger.txt" 2>&1 >> $OutFile
Add-Content $OutFile "`r`n--------------------Finsihed Creating New Trigger File--------------------`r`n`r`n"
Add-Content $OutFile "`r`n----------Clear backup mode from site-------------`r`n"
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile "D:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Clear-
VaultStoreBackupMode -Name EVSite -EVServerName evserver.domain.com -EVObjectType Site}" 2>&1 >> $OutFile
Add-Content $OutFile "`r`n----------Finished Clearing backup mode from site-------------`r`n`r`n"
Add-Content $OutFile "`r`n---------Clear backup mode from vault store group-------------`r`n"
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile "D:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Clear-
VaultStoreBackupMode -Name 'Exchange Group' -EVServerName evserver.domain.com -EVObjectType VaultStoreGroup}" 2>&1 >> $OutFile
Add-Content $OutFile "`r`n---------Finished Clearing backup mode from vault store group-------------`r`n`r`n"
Add-Content $OutFile "`r`n---------Clear backup mode from vault store-------------`r`n"
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile "D:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Clear-
VaultStoreBackupMode -Name SiteExchangeVS -EVServerName evserver.domain.com -EVObjectType VaultStore}" 2>&1 >> $OutFile
Add-Content $OutFile "`r`n---------Finished Clearing backup mode from vault store-------------`r`n`r`n"
Add-Content $OutFile "`r`n---------Clear backup mode from indexes in site-------------`r`n"
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile "D:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Clear-
IndexLocationBackupMode -EVServerName evserver.domain.com -EVSiteName EVSite}" 2>&1 >> $OutFile
Add-Content $OutFile "`r`n---------Finsished Clearing backup mode from indexes in site-------------`r`n`r`n"
Add-Content $OutFile "`r`n--------------------End Clearing BU Mode--------------------`r`n`r`n"
Add-Content $OutFile "`r`n--------------------Program Finished--------------------`r`n`r`n"
03-06-2012 08:26 AM
i'm curious to understand what all this accomplished that the basic batch script calling powershell commands didnt do for you.
03-06-2012 08:35 AM
1) What started this process was the program that I was going to use could only run vbs, so I thought it would be fun converting the script to vbs.
2) I also needed to change the outut file, so once I was changing that, I needed to add additional code.
3) I wanted to add the Snapdrive backup within the script, which is powershell.
4) Then I encountered issues running with vbs, so as suggested, I ran this in powershell. Yes, after all this work, I could have combined both basic scripts and call it a day. But what fun would that be?:)
Now all I need is for this script to communicate to SQL and verify the SQL backups were completed sucessfully and then continue to remove the backup mode.