Host-based backup of VMware vSphere VMs.
Post Reply
oliverL
Enthusiast
Posts: 82
Liked: 11 times
Joined: Nov 11, 2016 8:56 am
Full Name: Oliver
Contact:

Job Scripts won't work

Post by oliverL »

Hey there,

i'm currently trying to invoke a powershellscript trough the advanced job scripts option with a bat-file, to shutdown and start VMs which have passtrough-devices.

But it seems that the Script isn't either executed or stalled as veeam stays in running pre-job script...

So i have 2 scripts:
1. A bat-file which calls the powershell-script:

Code: Select all

Powershell.exe -Command C:\Backup\powershellskripts\backup_win10_start.ps1
exit
and then the corresponding powershell-script:

Code: Select all

import-module vmware.powercli
connect-viserver vcsa.local
Get-VM Win10 | Shutdown-VMGuest -confirm:$false
disconnect-viserver -confirm:$false
I also made a VICredentialStoreItem so that connect-viserver runs without arguments. The Powershell ExecutionPolicy is set to unrestricted.

Manually calling the batch file from a cmd works and my VM gets shutdown but in Veeam it stays at "running pre-job script" and if i cancel the job it stays at the "running post-job script".
Killing the cmd/powershell process in the task manager also won't change the fact that veeam still trys to run the job-script...

Unfortunately https://helpcenter.veeam.com/docs/backu ... l?ver=95u4

doesn't offer some examples :(

Is there any way to put those scripts which are called in the foreground to see where it stalls? And can we change the timeout values?
Andreas Neufert
VP, Product Management
Posts: 7076
Liked: 1510 times
Joined: May 04, 2011 8:36 am
Full Name: Andreas Neufert
Location: Germany
Contact:

Re: Job Scripts won't work

Post by Andreas Neufert »

It is hard to guess what the issue is.

Did you have started the powershell script with the same user?
Try another script where you just issue a simple command like "copy 1.txt 2.txt" to check if the whole script works that way. Then add one command after each other to check with what command you have the issue. My guess is that you shutdown the VM from itself and this will takes longer as the shutdown happening, so our process is not active anymore and we wait for the timeout (If I remember right something arround 5-10 minutes).

Potentially you need to change your approach because of this. You can use Job Pre script to run the shutdown processes against vcenter. But allow me to ask why you shutdown the VM instead of using the Veeam Guest Processing to backup the VM in consistent state?
oliverL
Enthusiast
Posts: 82
Liked: 11 times
Joined: Nov 11, 2016 8:56 am
Full Name: Oliver
Contact:

Re: Job Scripts won't work

Post by oliverL »

Hi Andreas!

yes, unfortunately it is hard to find out why the scripts won't get trough :(

yes i've manually called the script as the domain-administrator and veeam has been installed the same way. These Scripts are located on the Veeam Backup & Replication Server and i have installed the powercli module on this server.

I need to shutdown the virtual Machine as it has Passtrough-Devices attached. And with Passtrough active VMs can't use hotadd mode while beeing online. But if the VM is offline i can use hotadd thats why i have to trigger those scripts before Veeam touches the VM.

That's why i'm calling the powershell-script with the batch-file which contains the command to shutdown the VM trough the vCenter.

I did make a test with a simple batch which copys a file like you mentioned and it seems to work...

So i need to dig further... but calling powershell from within a bat shouldn't be a problem for veeam - right?
Andreas Neufert
VP, Product Management
Posts: 7076
Liked: 1510 times
Joined: May 04, 2011 8:36 am
Full Name: Andreas Neufert
Location: Germany
Contact:

Re: Job Scripts won't work

Post by Andreas Neufert »

correct it is no issue. As I said if you shutdown the server while we wait for the commands to complete and then the connection is not present anymore to the VM is I think the issue.
So to run it from B&R in the Job pre/post script is I think the way to go.

As well please check if you can place the passtrough disks in "unattended disk" mode which potentially enables you to backup the VM with hotadd?
oliverL
Enthusiast
Posts: 82
Liked: 11 times
Joined: Nov 11, 2016 8:56 am
Full Name: Oliver
Contact:

Re: Job Scripts won't work

Post by oliverL »

Hi Andreas,

the Veeam Backup & Replication Server, aswell as the vCenter are online while i want to backup another virtual machine in this environment, therefore everything is available the whole time.

This 3rd virtual machine has USB-Controllers and a GPU passtroughed (no disks). And due to that Hardware-Passtrough i can't snapshot powered on VMs, therefore i need to shutdown these VMs.

Manually calling the bat-file works as i can look into the vcenter if anything is run against my VM :-/
Andreas Neufert
VP, Product Management
Posts: 7076
Liked: 1510 times
Joined: May 04, 2011 8:36 am
Full Name: Andreas Neufert
Location: Germany
Contact:

Re: Job Scripts won't work

Post by Andreas Neufert »

My understanding is that you use the Veeam Guest processing pre and post scripting to run the shutdown VM script within the VM that you backup. When you issue the shutdown script we will immediately loose network connection to the VM and do not "see" that the script is completed. We wait for the timeout which is ~10minutes, then fail the job.

You need to find another method to shutdown the VM... For example to run it as Job pre post script. (Job-Storage-Advanced)
oliverL
Enthusiast
Posts: 82
Liked: 11 times
Joined: Nov 11, 2016 8:56 am
Full Name: Oliver
Contact:

Re: Job Scripts won't work

Post by oliverL »

yes, makes sense, therefore i've said that i use the advanced job options for job scripts at the beginning ;-)

It is really strange.... simple copy bat files are executed without problems but not the bat-file which calls the powershell script :(

It also doesn't seem that Job pre scripts aren't mentioned in the logfiles?

Changing the Account for the veeam-services from local to the same user with whom i'm logged in (domain-admin) also let the script timeout :( If i atleast could put down the timeout value to 10 seconds instead of 5-10 minutes...
Andreas Neufert
VP, Product Management
Posts: 7076
Liked: 1510 times
Joined: May 04, 2011 8:36 am
Full Name: Andreas Neufert
Location: Germany
Contact:

Re: Job Scripts won't work

Post by Andreas Neufert »

OK... can you add full path to the powershell.exe in the script?
oliverL
Enthusiast
Posts: 82
Liked: 11 times
Joined: Nov 11, 2016 8:56 am
Full Name: Oliver
Contact:

Re: Job Scripts won't work

Post by oliverL » 1 person likes this post

Ok, thats my Batchfile which i've put into the advanced pre-job and post-job scripts section (did some further changes):

Code: Select all

C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe -noninteractive -executionpolicy unrestricted -file C:\Backup\powershellskripts\backup_-win10_start.ps1

And then i just tried it with the credentials in the backup_-win10_start.ps1 (as a pre-job script which does the shutdown of the VM)

Code: Select all

import-module vmware.powercli
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore	<-- this might have been my error*1
connect-viserver vcsa.local -User secret -Password secret
Get-VM Win10 | Shutdown-VMGuest -confirm:$false
disconnect-viserver -confirm:$false
*1 Due to the fact that i've started using -noninteractive i thought that it might run under a different userprofile. Therefore i put that into the script so that this doesn't matter (in ISE it is asking you if you want to make the change in PowerCLIConfiguration! As a script it just ignores it).

After making this changes to the scripts, tested the ps1-script in ISE, i did a reboot and started the Backup Job which now executes the script.

Which means, my VM now will get shutdown before Veeam does the hotadd stuff and then bring the VM back online (if the GPU let's it ;-) ).

Would be really great to see such examples in the helpcenter, especially since we can only use bat, exe or cmd files...
https://helpcenter.veeam.com/docs/backu ... l?ver=95u4

(Would be cool if V10 could use Powershell/PowerCLI and Rest-API ;-)

Thanks for the help!
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Google [Bot], mikeely and 57 guests