Comprehensive data protection for all workloads
Post Reply
eantonio
Influencer
Posts: 24
Liked: never
Joined: Jan 27, 2015 9:14 pm
Full Name: Emil Antonio
Contact:

Is it possible to trigger a Veeam backup job from within SQL

Post by eantonio »

We want to run a Veeam backup job right after we run a Native SQL Backup. Is it possible to trigger a Veeam backup job from within SQL scheduler? i.e. using a Power Shell script to trigger the job from the SQL server?
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Is it possible to trigger a Veeam backup job from within

Post by veremin »

Why not to schedule native sql backup as pre-freeze script?
larry
Veteran
Posts: 387
Liked: 97 times
Joined: Mar 24, 2010 5:47 pm
Full Name: Larry Walker
Contact:

Re: Is it possible to trigger a Veeam backup job from within

Post by larry »

If the sql command can be run using sqlcmd then create a bat file run your SQL commands ( backup plus what ever you need to do ) then run a PS1 file from the bat to do the veeam stuff you can find examples posted here if not I can find something.

Or better is a Veeam job with a pre bat job that runs your sql commands from a bat file using sqlcmd - I posted example a few years ago. then let veeam do its thing.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Is it possible to trigger a Veeam backup job from within

Post by veremin »

Yep. Larry's nailed it. Why to bother with SQL scheduler, if everything can be run from one console. Just set the appropriate scripts as pre-job activity or pre-freeze scripts, so that, native SQL tools take care about SQL stuff prior to Veeam creates a backup of the VM. Thanks.
eantonio
Influencer
Posts: 24
Liked: never
Joined: Jan 27, 2015 9:14 pm
Full Name: Emil Antonio
Contact:

Re: Is it possible to trigger a Veeam backup job from within

Post by eantonio »

Can you please provide the link where I can get a sample pre & post scripts to run a native sql backup first and then run veeam backup afterwards. Thank you.
dellock6
Veeam Software
Posts: 6137
Liked: 1928 times
Joined: Jul 26, 2009 3:39 pm
Full Name: Luca Dell'Oca
Location: Varese, Italy
Contact:

Re: Is it possible to trigger a Veeam backup job from within

Post by dellock6 »

I wonder even more if the SQL backup is needed at all, since we have support for SQL backups plus restores down to the single transaction natively in our software.
Luca Dell'Oca
Principal EMEA Cloud Architect @ Veeam Software

@dellock6
https://www.virtualtothecore.com/
vExpert 2011 -> 2022
Veeam VMCE #1
eantonio
Influencer
Posts: 24
Liked: never
Joined: Jan 27, 2015 9:14 pm
Full Name: Emil Antonio
Contact:

Re: Is it possible to trigger a Veeam backup job from within

Post by eantonio »

My DBA Admin still want to do a native SQL backup on top of Veeam backup. Can you please provide a link where I can find sample scripts to do this?
larry
Veteran
Posts: 387
Liked: 97 times
Joined: Mar 24, 2010 5:47 pm
Full Name: Larry Walker
Contact:

Re: Is it possible to trigger a Veeam backup job from within

Post by larry »

sqlcmd -S YOUR_SERVER_NAME\SQLName -E -Q "EXEC sp_BackupDatabases @backupLocation='C:\SQL_Backup

You can also run an update script first which we need to do which is why you go this route, update tables, run sql backup in pre veeam let veeam run backup run, done.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Is it possible to trigger a Veeam backup job from within

Post by veremin »

If this request is coming from DB admin, why not to ask him to provide the required scripts that should be executed prior to backup jobs, according to his opinion? He should be well aware of those.
eantonio
Influencer
Posts: 24
Liked: never
Joined: Jan 27, 2015 9:14 pm
Full Name: Emil Antonio
Contact:

Re: Is it possible to trigger a Veeam backup job from within

Post by eantonio »

My DBA gave me this script:

"D:\MSSQL\100\DTS\Binn\dtexec.exe /SQL "Maintenance Plans\Admin-Backup" /SERVER OURSERVERNAMEHERE /CHECKPOINTING OFF /SET "\Package\Full.Disable";false /REPORTING E"

I created a batch file and put this command in there and then added it in the Veeam backup setting _ Storage > Advance Settings > Advance tab > Job Scripts - Run the following script before the job.

Does the batch file get copied to the remote server and then run locally in the remote server? or does it execute from the Veeam server?

If I go to the remote server and run this command, it completes successfully. When I run it from the Veeam job, I get an error "Pre-job script terminated with exit code 1 "
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Is it possible to trigger a Veeam backup job from within

Post by veremin »

Go to job settings -> Guest Processing -> Applications -> add corresponding SQL VM -> edit -> scripts -> require successful script execution -> Windows scripts -> set the mentioned script as pre-freeze one. This way, necessary operations will be performed inside VM prior to backup operations. Thanks.
eantonio
Influencer
Posts: 24
Liked: never
Joined: Jan 27, 2015 9:14 pm
Full Name: Emil Antonio
Contact:

Re: Is it possible to trigger a Veeam backup job from within

Post by eantonio »

case 00933477

Is it possible for me to run a script from a remote server that will run a power shell command to execute a Veeam job in my Veeam server? If so, can you please send me a link with examples. Thanks.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Is it possible to trigger a Veeam backup job from within

Post by veremin »

Invoke expressions might be your way to go. Thanks.
eantonio
Influencer
Posts: 24
Liked: never
Joined: Jan 27, 2015 9:14 pm
Full Name: Emil Antonio
Contact:

Re: Is it possible to trigger a Veeam backup job from within

Post by eantonio »

v.Eremin

The Invoke-Expressions and Invoke-Command cmdlet only runs the files that are local to the server, right? How do I make it so it can execute a power shell script where the file is located on the remote computer?

Another question: Can I install Veeam PowerShell Snapin in another computer that doesnt have Veeam & Backup software installed? If I can do this, then I can run Veeam cmdlets from the remote computer to execute a Veeam backup job in my Veeam server.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Is it possible to trigger a Veeam backup job from within

Post by veremin »

The Invoke-Expressions and Invoke-Command cmdlet only runs the files that are local to the server, right?
Nope, the commands present inside script block will be executed on the remote machine.
Another question: Can I install Veeam PowerShell Snapin in another computer that doesnt have Veeam & Backup software installed? If I can do this, then I can run Veeam cmdlets from the remote computer to execute a Veeam backup job in my Veeam server.
Nope. You can install PS snap-in on the different machine that doesn't have VB&R deployed, but it won't be able to operate with backup server remotely.

Thanks.
Cragdoo
Veeam Vanguard
Posts: 628
Liked: 251 times
Joined: Sep 27, 2011 12:17 pm
Full Name: Craig Dalrymple
Location: Scotland
Contact:

Re: Is it possible to trigger a Veeam backup job from within

Post by Cragdoo »

v.Eremin wrote:Go to job settings -> Guest Processing -> Applications -> add corresponding SQL VM -> edit -> scripts -> require successful script execution -> Windows scripts -> set the mentioned script as pre-freeze one. This way, necessary operations will be performed inside VM prior to backup operations. Thanks.
Apologies for resurrecting an old thread, but I was wonder what credentials/account the script will use on the SQL server ?
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Is it possible to trigger a Veeam backup job from within

Post by veremin »

Either general credentials specified under Guest Processing -> Guest OS credentials or individual ones set in "Credentials..." view. Thanks.
Cragdoo
Veeam Vanguard
Posts: 628
Liked: 251 times
Joined: Sep 27, 2011 12:17 pm
Full Name: Craig Dalrymple
Location: Scotland
Contact:

Re: Is it possible to trigger a Veeam backup job from within

Post by Cragdoo »

thanks for the info.

Another question, do I need to copy the batch file to the target SQL server, or does the Veeam job take care of that for me ?
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Is it possible to trigger a Veeam backup job from within

Post by veremin »

VB&R will take care about it; just specify the correct path to the scripts. Thanks.
Cragdoo
Veeam Vanguard
Posts: 628
Liked: 251 times
Joined: Sep 27, 2011 12:17 pm
Full Name: Craig Dalrymple
Location: Scotland
Contact:

Re: Is it possible to trigger a Veeam backup job from within

Post by Cragdoo »

great ..thank you.
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Google [Bot], Kristina.Zalesakova, kyle.shuberg and 180 guests