-
- Expert
- Posts: 122
- Liked: 7 times
- Joined: Mar 27, 2012 10:13 pm
- Full Name: Chad Killion
- Contact:
Pre / Post Job Scripts
All-
I have a backup job which backs up only a single VM. I would like to execute a script before the snapshot for the machine takes place that will actually run on the target VM. Then backup the machine normally, then run another script on the target VM after the backup. I know Veeam allows for running scripts before/after jobs, but these scripts are run locally on the Veeam server, correct? Can I use a powershell script, or am I limited to bat/cmd scripts?
Chad
I have a backup job which backs up only a single VM. I would like to execute a script before the snapshot for the machine takes place that will actually run on the target VM. Then backup the machine normally, then run another script on the target VM after the backup. I know Veeam allows for running scripts before/after jobs, but these scripts are run locally on the Veeam server, correct? Can I use a powershell script, or am I limited to bat/cmd scripts?
Chad
-
- Product Manager
- Posts: 20413
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Pre / Post Job Scripts
Check pre-freeze, past-thaw scripts; seems to be something you're looking for. Thanks.
-
- Expert
- Posts: 122
- Liked: 7 times
- Joined: Mar 27, 2012 10:13 pm
- Full Name: Chad Killion
- Contact:
Re: Pre / Post Job Scripts
so scripts that I specify on the application settings for the VM are executed locally on the VM, ie if I put c:\script.bat, that is referencing the C drive on the VM itself and not the veeam server? The pre-freeze script would be OK, but I would need to run the after-job script not after the snapshot is taken, but rather after the job completes. Can I use powershell scripts on either the pre/post freeze, or the advance settings pre-post job script areas?
-
- Product Manager
- Posts: 20413
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Pre / Post Job Scripts
Scripts should be located on a backup server. During backup, those will be uploaded inside the guests. You can either convert PS script to .bat or make .bat execute PS. Thanks.so scripts that I specify on the application settings for the VM are executed locally on the VM, ie if I put c:\script.bat, that is referencing the C drive on the VM itself and not the veeam server?
-
- Expert
- Posts: 122
- Liked: 7 times
- Joined: Mar 27, 2012 10:13 pm
- Full Name: Chad Killion
- Contact:
Re: Pre / Post Job Scripts
OK, so the scripts available within the pre/post thaw will not work for me. I need to do this on the Storage - Advanced - Advanced Settings for the Veeam job itself as I want the scripts to be run with the start and end of the job, not necessarily with the backed up VM snapshot create. Under what security context are those scripts executed when scheduled from that screen?
-
- Expert
- Posts: 122
- Liked: 7 times
- Joined: Mar 27, 2012 10:13 pm
- Full Name: Chad Killion
- Contact:
Re: Pre / Post Job Scripts
OK, so I have it working for the most part, but I need to pass a variable to the script inside the call from Veeam. I have tried both of the following:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noninteractive -file "C:\Auto\Oracle\StopOracle.ps1 foo"
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noninteractive -file "C:\Auto\Oracle\StopOracle.ps1" foo
But neither of those work as the argument "foo" doesn't get passed to the powershell script. How would I go about passing "foo" to the file I am calling into powershell?
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noninteractive -file "C:\Auto\Oracle\StopOracle.ps1 foo"
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noninteractive -file "C:\Auto\Oracle\StopOracle.ps1" foo
But neither of those work as the argument "foo" doesn't get passed to the powershell script. How would I go about passing "foo" to the file I am calling into powershell?
-
- Product Manager
- Posts: 20413
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Pre / Post Job Scripts
The first variant should, as long as, there is something inside the script expecting an argument:
Once the command is executed $Something should have foo as its value.
Thanks.
Code: Select all
param ([string]$something)
Write-Output $something
Code: Select all
PowerShell.exe -File "C:\Auto\Oracle\StopOracle.ps1 foo"
Thanks.
-
- Expert
- Posts: 122
- Liked: 7 times
- Joined: Mar 27, 2012 10:13 pm
- Full Name: Chad Killion
- Contact:
Re: Pre / Post Job Scripts
I am using the following as top lines of my script, but I don't think the variable is getting sent from the command line in the Veeam script text box:
I will try again and see if maybe I had something wrong.
Code: Select all
IF ($args.length -ne 1){Exit}
Switch ($args){
"foo" {
$oracleserver = "server1"
$batpath = "c:\shutscript.bat"}
"foo2" {
$oracleserver = "server2"
$batpath = "F:\shutscript.bat"}
}
-
- Expert
- Posts: 122
- Liked: 7 times
- Joined: Mar 27, 2012 10:13 pm
- Full Name: Chad Killion
- Contact:
Re: Pre / Post Job Scripts
Yea that definitely doesn't work. I get "Pre-job script teminated with exit code -196608" when I run it as suggested:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noninteractive -file "C:\Auto\Oracle\StopOracle.ps1 foo"
I also tried changing my script to use param instead of $args. Same results.
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noninteractive -file "C:\Auto\Oracle\StopOracle.ps1 foo"
I also tried changing my script to use param instead of $args. Same results.
-
- Product Manager
- Posts: 20413
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Pre / Post Job Scripts
As a first investigation step, I'd probably remove switch statement and add some checks, instead, to see whether the string value is passed to $args properly.
Thanks.
Code: Select all
$args[0] > C:\Check.txt
-
- Lurker
- Posts: 2
- Liked: never
- Joined: Mar 06, 2013 5:25 pm
- Full Name: John Kyriazakos
- Contact:
Re: Pre / Post Job Scripts
Hi all,
Did you manage to find a solution? Although my scripts are working right, Veeam B&R is never happy with the exit code...
Did you manage to find a solution? Although my scripts are working right, Veeam B&R is never happy with the exit code...
-
- Product Manager
- Posts: 6551
- Liked: 765 times
- Joined: May 19, 2015 1:46 pm
- Contact:
Re: Pre / Post Job Scripts
Hi,
That will force your script to return "0" (VBR considers zero as "success")
Thank you.
Have you tried appending the following line to your script?Veeam B&R is never happy with the exit code
Code: Select all
exit /b 0
Thank you.
-
- Novice
- Posts: 7
- Liked: never
- Joined: Dec 17, 2015 11:16 am
- Contact:
[MERGED]: post-job script terminated with exit code 1
I have a task that running gives this error.
The task has a fichero.bat running before launching the JOB
fichero.bat works ok from the console of Microsoft MS-DOS
Can you help me?
The task has a fichero.bat running before launching the JOB
fichero.bat works ok from the console of Microsoft MS-DOS
Can you help me?
-
- Product Manager
- Posts: 6551
- Liked: 765 times
- Joined: May 19, 2015 1:46 pm
- Contact:
Re: Pre / Post Job Scripts
Hi,
Thank you.
If you want to disable a warning message you can force your script to return zero, please see this thread to know how to do that. Anyway I'd check which part of the script throws an error.fichero.bat works ok from the console of Microsoft MS-DOS
Thank you.
-
- Enthusiast
- Posts: 82
- Liked: 33 times
- Joined: Mar 25, 2013 7:37 pm
- Full Name: Lars Pisanec
- Contact:
Re: Pre / Post Job Scripts
I would like to have scripts that run before/after the job, but for the script to run on the target and not on the Veeam server itself.
What do I need this for?
Backup Copy Job, target is a linux server. I would like to mount the backup repository locally before the job starts and unmount it afterwards, so that the repository is only mounted when the job runs and not when it is not needed.
What do I need this for?
Backup Copy Job, target is a linux server. I would like to mount the backup repository locally before the job starts and unmount it afterwards, so that the repository is only mounted when the job runs and not when it is not needed.
-
- Product Manager
- Posts: 5797
- Liked: 1215 times
- Joined: Jul 15, 2013 11:09 am
- Full Name: Niels Engelen
- Contact:
Re: Pre / Post Job Scripts
You could make a script that does this via SSH on the specific Linux server.
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
GitHub: https://github.com/nielsengelen
-
- Veeam Legend
- Posts: 351
- Liked: 36 times
- Joined: Oct 24, 2016 3:56 pm
- Full Name: Marco Sorrentino
- Location: Ancona - Italy
- Contact:
Re: Pre / Post Job Scripts
Has someone done the post job-script to run on a guest Linux VM?
Who is online
Users browsing this forum: Bing [Bot] and 31 guests