Running Symantec Enterprise Vault Scripts by Invoke-Commad

PowerShell script exchange

Running Symantec Enterprise Vault Scripts by Invoke-Commad

Veeam Logoby habibalby » Wed Apr 30, 2014 7:16 pm

Hello,
I used to backup my Symantec Enterprise Vault server using pre&post scripts on Veeam Server, complete guide on how this works posted here in my blog; http://dailyvmtech.wordpress.com/2012/1 ... plication/

The physical server which was hosting Veeam Backup & Replication failed due to hardware error and I rebuild the server from scratch as I wasn't having physical backup image on the server,,, anyway here my question(s) to the issue I'm facing now.

The scripts I used to use are not working even If I run them manually on the Backup server, but works fine on the EVServer which means scripts are working perfectly.

Via Invoke-Command If I run the command manually on the Backup Server (Veeam) it works fine..
Code: Select all
Invoke-Command -ComputerName EVServer -FilePath .\SymantecEV-PretScript.ps1

If I save the script as .ps1 script and i configure Task Scheduler the script doesn't work at all even with PowerShell.exe -File "C:\Scripts\SymantecEV-PreScript.ps1"

SymantecEV-PreScript.ps1
Code: Select all
#Pre-job to set the Symantec Enterprise Server and Site into Backup Mode.

#Reset ArchiveBit on the Store Vaults.

DEL "\\EVServer\EVPartition01cc55b2dc699b70$\IgnoreArchiveBitTrigger.old"
DEL "\\EVServer\EVPartition01cc55b2753ddd30$\IgnoreArchiveBitTrigger.old"
DEL "\\EVServer\EVPartition01cc55b34882a450$\IgnoreArchiveBitTrigger.old"
DEL "\\EVServer\EVPartition01cc55b3725ff520$\IgnoreArchiveBitTrigger.old"

#Site: EV Site

#Set backup mode on site

c:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -psconsolefile "C:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Set-VaultStoreBackupMode -Name '[b]EVSiteName[/b]' -EVServerName evserver -EVObjectType Site}"

#SiteIndexLocations:  EV Site

#Set backup mode on indexes in site

c:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -psconsolefile "C:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Set-IndexLocationBackupMode -EVServerName 'evserver' -EVSiteName [b]'EVSiteName[/b]}"

#Start Veeam Backup Job
Add-PSSnapin VeeamPSSnapin

#Add the name of the backup jobs to be included here. The order in which they are entered is the order in which they will run

$chainedjobs = (“SymantecEV”)

foreach ($jobname in $chainedjobs){
$job = Get-VBRJob -name $jobname
$jobtry = 0
start-VBRJob -job $job
$job.GetLastResult()
if($job.GetLastResult() -eq “Failed”){
do{
Start-Sleep 480
Start-VBRJob -job $job -RetryBackup
$jobtry++
}
while(($jobtry -lt 3) -and ($job.GetLastResult() -eq “Failed”))
}
}


SymantecEV-PostScript.ps1
Code: Select all
#Post-job to Clear the Backup Mode on the Enterprise Site and EVServer.
#Create IgnoreArchiveBitTrigger.txt

echo "Enterprise Vault Trigger File"> "\\EVServer\EVPartition01cc55b2dc699b70$\IgnoreArchiveBitTrigger.txt"
echo "Enterprise Vault Trigger File"> "\\EVServer\EVPartition01cc55b2753ddd30$\IgnoreArchiveBitTrigger.txt"
echo "Enterprise Vault Trigger File"> "\\EVServer\EVPartition01cc55b34882a450$\IgnoreArchiveBitTrigger.txt"
echo "Enterprise Vault Trigger File"> "\\EVServer\EVPartition01cc55b3725ff520$\IgnoreArchiveBitTrigger.txt"

#Clear backup mode from site
c:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -psconsolefile "C:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Clear-VaultStoreBackupMode -Name '[b]EVSiteName[/b]' -EVServerName evserver -EVObjectType Site}"


#Clear backup mode from indexes in site
c:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -psconsolefile "C:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Clear-IndexLocationBackupMode -EVServerName evserver -EVSiteName 'EVSiteName'}"


I'm getting this to work only by manually running the scripts on PowerShell, if I use .bat script such as
Code: Select all
 PowerShell.exe c:\Scripts\PS1.ps1
it doesn't run.

In this situation, how I will be able to run the scripts on the Backup Server against EVServer and the scripts located in the backup Server?

Thanks,
habibalby
Expert
 
Posts: 350
Liked: 23 times
Joined: Mon Jul 18, 2011 9:30 am
Location: Bahrain
Full Name: Hussain Al Sayed

Re: Running Symantec Enterprise Vault Scripts by Invoke-Comm

Veeam Logoby v.Eremin » Mon May 05, 2014 10:51 am

Is the account used for manual script execution and for script execution via Task Scheduler the same? Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Running Symantec Enterprise Vault Scripts by Invoke-Comm

Veeam Logoby habibalby » Tue May 06, 2014 8:10 am

Hi Eremin,

Yes I'm using the same account.
Thanks,
habibalby
Expert
 
Posts: 350
Liked: 23 times
Joined: Mon Jul 18, 2011 9:30 am
Location: Bahrain
Full Name: Hussain Al Sayed

Re: Running Symantec Enterprise Vault Scripts by Invoke-Comm

Veeam Logoby v.Eremin » Tue May 06, 2014 9:11 am

Are you running scripts on 64-bit OS? There are two PS versions in 64-bit OS. So, you can try to specify direct path to either 32 or 64 version and see whether it makes any difference.

Instead of:

Code: Select all
PowerShell.exe -File "C:\Scripts\SymantecEV-PreScript.ps1"


Try either (32):

Code: Select all
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -File "C:\Scripts\SymantecEV-PreScript.ps1


Or (64):

Code: Select all
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File "C:\Scripts\SymantecEV-PreScript.ps1


The required level of execution policy should be also set for both instances.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Running Symantec Enterprise Vault Scripts by Invoke-Comm

Veeam Logoby habibalby » Tue May 06, 2014 9:12 am

Thanks, let me try it will come back to you in awhile.

Regards,
habibalby
Expert
 
Posts: 350
Liked: 23 times
Joined: Mon Jul 18, 2011 9:30 am
Location: Bahrain
Full Name: Hussain Al Sayed

Re: Running Symantec Enterprise Vault Scripts by Invoke-Comm

Veeam Logoby bernardw » Fri Jan 23, 2015 10:18 pm

As an update to this post and to make it a bit easier for people to follow the steps in the future (if anyone else is looking to backup Enterprise Vault with Veeam).

Some things I learned as of Veeam 8:

Setup the VM backup with Pre and Post scripts (found under "guest Processing">Applications> Add a VM >Scripts

The Pre and Post scripts must be batch files. They are files that run on the VM being backed up and as the computer account.
the batch script needs to run a Powershell script with the Invoke command such as
Code: Select all
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe Invoke-Command -ComputerName EVServerName -FilePath c:\temp\BackupEV-clearBackupmode.ps1


The content of the scripts continue to be the same as habibalby posted even in Enterprise Vault 11.1

I found the Pre and post VM script are the easiest to use as the freezing of the computer happens every time the backup of the Enterprise Vault server is run which also means it is not necessarily frozen when the other VMs are being backed up.
bernardw
Influencer
 
Posts: 22
Liked: 4 times
Joined: Wed Feb 20, 2013 6:21 pm

Re: Running Symantec Enterprise Vault Scripts by Invoke-Comm

Veeam Logoby habibalby » Mon Jun 01, 2015 5:24 pm

Part of my plan which I wrote today for the Exchange migration is to eliminate EV Server and use Exchange Archive features.. This will free me from Slow Backup due to the fact EV is very heavy VM.

Thanks,
habibalby
Expert
 
Posts: 350
Liked: 23 times
Joined: Mon Jul 18, 2011 9:30 am
Location: Bahrain
Full Name: Hussain Al Sayed

Re: Running Symantec Enterprise Vault Scripts by Invoke-Comm

Veeam Logoby ccampbell » Thu Jul 02, 2015 4:26 pm

This post, along with habibalby's prior wordpress post has saved me quite a bit of time in setting up Veeam for EV backup. Thank you.

I have one question in reference to the shift from running Veeam side to invoking on the EV server. I'll probably find the answer pretty easily in the documentation, but I figure it might be helpful for future users to record it here. My suspicion is that it no longer makes sense to launch the backup job from the powershell script itself since Veeam will run the pre-thaw. Is this accurate?

It does seem like we could make this a bit more robust by checking the return values of the scripts or verifying backup mode with the appropriate powershell commands. I don't have much time left to work on this now, but I'll post code if I get to it. Unless somebody else has a script they'd like to share???

Thanks again!
ccampbell
Lurker
 
Posts: 2
Liked: never
Joined: Thu Jul 02, 2015 4:01 pm
Full Name: Clinton J. Campbell

Re: Running Symantec Enterprise Vault Scripts by Invoke-Comm

Veeam Logoby v.Eremin » Fri Jul 03, 2015 10:11 am

I agree, now as we have pre-thaw scripts, it might be worth indeed placing the referenced scripts inside backup job, so that, everything is setup within one place. Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Running Symantec Enterprise Vault Scripts by Invoke-Comm

Veeam Logoby ccampbell » Sat Jul 04, 2015 4:25 am

I made some progress, but I'm still having a bit of trouble. The script modifications aren't too bad. Within the .bat files, I simply complete with "exit /b %errorlevel%" to terminate the batch job and pass back the error level of the previous command. I was a bit more particular with the powershell. I decided that within the pre backup script, I wanted to be sure to clear backup mode if either of my powershell commands returned an error. The following block seems sufficient:

Code: Select all
if ($LastExitCode -ne 0) {
    c:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -psconsolefile "C:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Clear-VaultStoreBackupMode -Name 'sitename' -EVServerName servername -EVObjectType Site}"
    c:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -psconsolefile "C:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Clear-IndexLocationBackupMode -EVServerName servername -EVSiteName 'sitename'}"
    throw "Exec: $ErrorMessage"
}


I did notice some flaky behavior with the Set/Clear-BackupMode commandlets, and I may update these scripts with a version that verifies the actual state using the Get-BackupMode command lets. First, I'm aiming for a fully working test.

Now, where I'm running into issues is how to set up the actual jobs. Enterprise Vault runs on its own VM while we have a separate application VM for the SQL Server hosting the Vault databases. I currently run pre-thaw on the first of the listed servers and post-thaw on the second. Since the servers backup in parallel, I'm not sure this is sufficient (still seeing errors on my scripts). I am thinking about separating the jobs since we can tell the database server to begin immediately after the Vault server completes. I was also planning to give the Powershell guide a look to see if there was a good way to hold the post-thaw until backup processing completes (note there is a way to set a script to run pre/post-job), but I was having permission issues with this approach.
ccampbell
Lurker
 
Posts: 2
Liked: never
Joined: Thu Jul 02, 2015 4:01 pm
Full Name: Clinton J. Campbell

Re: Running Symantec Enterprise Vault Scripts by Invoke-Comm

Veeam Logoby v.Eremin » Mon Jul 06, 2015 11:21 am

Post-thaw script runs, when VSS snapshot is created. So, I don't think it's possible to let it wait till the whole processing is finished.

The post-job activity might be a better idea, indeed. Can you tell us what particular permission issue you had?

Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Running Symantec Enterprise Vault Scripts by Invoke-Comm

Veeam Logoby omitv » Mon Aug 10, 2015 12:30 pm

I started in a new company and here they have created the pre and post scripts to run in the Enterprise Vault server as scheduled tasks before the Veeam backup kicks in. This has worked but in june the backups have no longer been able to backup the EV database and transaction logs (or that's what Enterprise Vault management console complains). In my previous job I had the backups run with pre and post scripts in the Veeam server.

Pre script:
REM Pre-job to set the Symantec Enterprise Server and Site into Backup Mode.
REM Reset ArchiveBit on the Store Vaults.

DEL "E:\MailVault\Partition1\IgnoreArchiveBitTrigger.old"
DEL "G:\MailVault2\Partition1\IgnoreArchiveBitTrigger.old"


REM Set backup mode to site

C:\WINDOWS\SysWOW64\windowspowershell\v1.0\powershell -psconsolefile "d:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Set-VaultStoreBackupMode -Name EVsite -EVServerName EVserver -EVObjectType Site}"


Post script:
REM Post-job to Clear the Backup Mode on the Enterprise Site and EVServer.
REM Create IgnoreArchiveBitTrigger.txt

echo "Enterprise Vault Trigger File"> "E:\MailVault\Partition1\IgnoreArchiveBitTrigger.txt"
echo "Enterprise Vault Trigger File"> "G:\MailVault2\Partition1\IgnoreArchiveBitTrigger.txt"


REM Clear backup mode from site

C:\WINDOWS\SysWOW64\windowspowershell\v1.0\powershell -psconsolefile "d:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {Clear-VaultStoreBackupMode -Name EVsite -EVServerName EVserver -EVObjectType Site}"

When I run the pre script the archive files are deleted and the vault stores are set to backup mode (Indexes are not in backup mode). The post script also takes the vault stores from backup mode so it seems to work also. What am I missing here?
omitv
Influencer
 
Posts: 15
Liked: never
Joined: Sun Sep 29, 2013 2:37 pm

Re: Running Symantec Enterprise Vault Scripts by Invoke-Comm

Veeam Logoby v.Eremin » Wed Aug 12, 2015 2:51 pm

This has worked but in june the backups have no longer been able to backup the EV database and transaction logs (or that's what Enterprise Vault management console complains).

Can you elaborate on that? Did you get any specific error? Or the script didn't seem to work at all?
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Running Symantec Enterprise Vault Scripts by Invoke-Comm

Veeam Logoby omitv » Fri Aug 21, 2015 6:57 am

I just found out that they moved the Veeam to another server and it hasn't worked since.

I have returned to the way that I had it running in my previous employer. I have a prescript.bat that is initiated by Windows task scheduler which runs a powershell script:

Code: Select all
#Pre-job to set the Symantec Enterprise Server and Site into Backup Mode.
#Reset ArchiveBit on the Store Vaults.

DEL "\\ARCHIVE-2\EVPartition01cc011476c3aa10$\IgnoreArchiveBitTrigger.old"
DEL "\\ARCHIVE-2\EVPartition01ce9fd766f4d730$\IgnoreArchiveBitTrigger.old"

#Site: EV Site

#Set backup mode on site
c:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -psconsolefile “C:\Program Files (x86)\Enterprise Vault\EVShell.psc1” -command “& {Set-VaultStoreBackupMode -Name ‘Mysite’ -EVServerName enterprisevault.mydomain.fi -EVObjectType Site}”

#SiteIndexLocations:  EV Site

#Set backup mode on indexes in site
c:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -psconsolefile “C:\Program Files (x86)\Enterprise Vault\EVShell.psc1” -command “& {Set-IndexLocationBackupMode -EVServerName enterprisevault.mydomain.fi -EVSiteName ‘Mysite’}”

#Start Veeam Backup Job

Add-PSSnapin VeeamPSSnapin

# Add the name of the backup jobs to be included here. The order in which they are entered is the order in which they will run

$chainedjobs = (“Archive-2”)

foreach ($jobname in $chainedjobs){
$job = Get-VBRJob -name $jobname
$jobtry = 0
start-VBRJob -job $job

$job.GetLastResult()
if($job.GetLastResult() -eq “Failed”){
do{
Start-Sleep 480
Start-VBRJob -job $job -RetryBackup
$jobtry++
}
while(($jobtry -lt 3) -and ($job.GetLastResult() -eq “Failed”))
}
}


And then the post script that is configured in the backup job properties.
Code: Select all
#Post-job to Clear the Backup Mode on the Enterprise Site and EVServer.
#Create IgnoreArchiveBitTrigger.txtecho “Enterprise Vault Trigger File”> “\\EVServer\EVPartition01cc55b2dc699b70$\IgnoreArchiveBitTrigger.txt”
echo “Enterprise Vault Trigger File”> “\\ARCHIVE-2\EVPartition01cc011476c3aa10$\IgnoreArchiveBitTrigger.txt”
echo “Enterprise Vault Trigger File”> “\\ARCHIVE-2\EVPartition01ce9fd766f4d730$\IgnoreArchiveBitTrigger.txt”
#Clear backup mode from site

c:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -psconsolefile “C:\Program Files (x86)\Enterprise Vault\EVShell.psc1” -command “& {Clear-VaultStoreBackupMode -Name ‘Mysite’ -EVServerName enterprisevault.mydomain.fi -EVObjectType Site}”

#Clear backup mode from indexes in site

c:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -psconsolefile “C:\Program Files (x86)\Enterprise Vault\EVShell.psc1” -command “& {Clear-IndexLocationBackupMode -EVServerName enterprisevault.mydomain.fi -EVSiteName ‘Mysite’}”


The pre script successfully sets the vault and indexes in to backup mode but it fails with the rest of the code (starting the veeam backup job). The post script successfully removes the vault stores and indexes from backup mode. When I run the prescript with the account that is also set to run the Veeam services I receive following errors:
Code: Select all
Successfully set backup mode on the vault stores on Enterprise Vault server 'archive.Dittmar.fi'.
Successfully set backup mode on all vault stores in site 'Dittmar'.
Successfully set backup mode on all index locations on Enterprise Vault server 'archive.Dittmar.fi'.
Successfully set backup mode on all index locations in site 'Dittmar'.
Add-PSSnapin : The Windows PowerShell snap-in 'VeeamPSSnapin' is not installed on this computer.
At S:\scripts\PreJob.ps1:19 char:1
+ Add-PSSnapin VeeamPSSnapin
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (VeeamPSSnapin:String) [Add-PSSnapin], PSArgumentException
    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand

Get-VBRJob : The term 'Get-VBRJob' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At S:\scripts\PreJob.ps1:26 char:8
+ $job = Get-VBRJob -name $jobname
+        ~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-VBRJob:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

start-VBRJob : The term 'start-VBRJob' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At S:\scripts\PreJob.ps1:28 char:1
+ start-VBRJob -job $job
+ ~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (start-VBRJob:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

You cannot call a method on a null-valued expression.
At S:\scripts\PreJob.ps1:30 char:1
+ $job.GetLastResult()
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At S:\scripts\PreJob.ps1:31 char:4
+ if($job.GetLastResult() -eq "Failed"){
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

PS S:\scripts>


And I have run the installer stated in the following article: http://www.veeam.com/kb1489 and rebooted the server but that didn't have any affect.

Ps. I have a support ticket opened (case 00993987)
omitv
Influencer
 
Posts: 15
Liked: never
Joined: Sun Sep 29, 2013 2:37 pm

Re: Running Symantec Enterprise Vault Scripts by Invoke-Comm

Veeam Logoby v.Eremin » Fri Aug 21, 2015 12:19 pm

I think PowerShell snap-in reinstallation might be required here. Let me know how the process goes. Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Next

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 6 guests