PowerShell script exchange
Post Reply
krpi
Novice
Posts: 4
Liked: never
Joined: Oct 05, 2018 11:46 am
Full Name: Martin Krpata
Contact:

Run 2 diferrent maintenance sql job in post-thaw by day in the week

Post by krpi »

Hello,

I have in SQL server maintenance job plan, in Saturday is rebuild indexes and other long maintenance that take hours, other day is something shorter. I want in Saturday after fullbackup run post-thaw script that run maintenance job in SQL and other day run another SQL maintenance job. I want to use Veeam to manage this not Windows or SQL scheduler.

Can somebody help me howto do that? Or point me please to best practice way.

SQL job can be runned by:

Code: Select all

"C:\Program Files\Microsoft SQL Server\110\Tools\Binn\osql.exe" -S SQL01 -E -Q "exec msdb.dbo.sp_start_job 'TEST'"
best regards
Martin
PTide
Product Manager
Posts: 6408
Liked: 724 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Run 2 diferrent maintenance sql job in post-thaw by day in the week

Post by PTide »

Hi,

You should probably use post-job script instead, as post-thaw scripts kick in after a snapshot has been taken, not after the job has finished. Post-job scripts are executed on VBR server - you'll have to make sure that your script can properly start the maintenance routines on the remote server.

Thanks!
krpi
Novice
Posts: 4
Liked: never
Joined: Oct 05, 2018 11:46 am
Full Name: Martin Krpata
Contact:

Re: Run 2 diferrent maintenance sql job in post-thaw by day in the week

Post by krpi »

Can I get information in script that this backup is full or different? Or, have two scripts one for full, one for different?
PTide
Product Manager
Posts: 6408
Liked: 724 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Run 2 diferrent maintenance sql job in post-thaw by day in the week

Post by PTide » 1 person likes this post

You can query VBR server using PowersHell command to find out what kind of backup is running, or you can embed additional check inside the script so that it checks what day is it and, provided that it knows your backup schedule, conclude whether it's full or incremental (Veeam does not do differential backups).

Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests