PowerShell script exchange
Post Reply
Kiranpn
Enthusiast
Posts: 27
Liked: 2 times
Joined: Mar 18, 2021 4:48 am
Full Name: Kiran Pradhan
Contact:

Stop and restart the Veeam backup during Windows Update

Post by Kiranpn »

Hi Team,
I am wondering about the script:
1.Which stops and disable all the Backup service and stops Veeam SQL Service before windows update,
and checks the windows update and if there is any, starts windows update.

2.After Windows update restarts the Veeam SQL Server service and Backup server.
I have made the script but it doesn't check the windows update. It is only for before windows update and after windows update, which I need to put on task scheduler before and after scheduled windows update time.

It would be great if you could help me on this: :)
1. StopVeeam_1.ps1

Code: Select all

Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue   # Adding VeeamSnapin
Connect-VBRServer -Server "localhost"-Port "9392"                                # To connect Veeam Server
Get-Vbrjob | Stop-Vbrjob                                                                              # Stop Jobs 
Start-Sleep -s 30                                                            #Wait for 30seconds
Get-Vbrjob | Disable-Vbrjob                                                                        # Disable all jobs
Disconnect-VBRServer                                                                          #Disconnect Server
Start-Sleep -s 30                                                            #Wait for 30seconds
Get-Service -computername winabcde -Name MSSQLSERVER | Stop-Service      #Stop SQL Server

2.StartVeeam_1.ps1

Code: Select all

Get-Service -computername winabcde -Name MSSQLSERVER | Start-Service     #Start SQL Server
Start-Sleep -s 30                                                            #Wait for 30seconds
Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue        # Adding VeeamSnapin
Connect-VBRServer -Server "localhost"-Port "9392"                                # To connect Veeam Server
Get-Vbrjob | Enable-Vbrjob                                                                                # Enable all jobs
Start-Sleep -s 30                                                            #Wait for 30seconds
Get-Vbrjob | Start-Vbrjob                                                                                   # Start all Jobs
Regards,
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Stop and restart the Veeam backup during Windows Update

Post by oleg.feoktistov »

Hi Kiran,

First, it is unclear what logic you are intending to implement through powershell: listen to windows update job and manage VBR-related services depending on running windows update job status, list available windows updates, manage VBR-related services and then trigger windows updates manually or else?

Second, the functionality you are asking about is out of scope of this forum. I'd recommend looking into PSWindowsUpdate module though.


Thanks,
Oleg
Kiranpn
Enthusiast
Posts: 27
Liked: 2 times
Joined: Mar 18, 2021 4:48 am
Full Name: Kiran Pradhan
Contact:

Re: Stop and restart the Veeam backup during Windows Update

Post by Kiranpn »

Hi Oleg,
Thank you for the reply.
We have regular windows update every month and currently we are stopping and disabling the Veeam jobs before doing windows update on the server.
Is there any to automate this instead of doing it manually every month?

Regards,
Kiran Pradhan
Mildur
Product Manager
Posts: 8549
Liked: 2223 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Stop and restart the Veeam backup during Windows Update

Post by Mildur »

How often does you backup run?
Ever 24 hours? Every 15 minutes?

Why not scheduling windows updates on the backup server on daytime, when no backups are running?
Normally, the night is there to run backups and on day, the backup server doesn‘t have to many tasks. But it depends on the company of course :)
Product Management Analyst @ Veeam Software
Kiranpn
Enthusiast
Posts: 27
Liked: 2 times
Joined: Mar 18, 2021 4:48 am
Full Name: Kiran Pradhan
Contact:

Re: Stop and restart the Veeam backup during Windows Update

Post by Kiranpn »

Hi Mildur,
unfortunately, it runs on the day time as well.
:D
Regards,
Kiran Pradhan
soncscy
Veteran
Posts: 643
Liked: 312 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey
Contact:

Re: Stop and restart the Veeam backup during Windows Update

Post by soncscy » 1 person likes this post

Kiranpn wrote: May 10, 2021 2:39 am We have regular windows update every month and currently we are stopping and disabling the Veeam jobs before doing windows update on the server.
Is there any to automate this instead of doing it manually every month?
Aren't you overthinking it a little?

Just get all jobs into a list and use Disable-VBRJob after the last backup window but before the update.

Then simply write some script that collects all jobs where the property IsRunning -eq $true. While $RunningJobs -gt 0, collect all jobs with IsRunning -eq $true again, clear out $RunningJobs ( =@() ), and start a sleep for like 15 minutes, and let this loop until $RunningJobs = 0.

Once the loop clears, then your script can do whatever. You can write some logic this way also where if the time counter is greater than some value, assume a job is stuck and email someone to check on whichever jobs are still in the array and active.
Kiranpn
Enthusiast
Posts: 27
Liked: 2 times
Joined: Mar 18, 2021 4:48 am
Full Name: Kiran Pradhan
Contact:

Re: Stop and restart the Veeam backup during Windows Update

Post by Kiranpn »

Thank you, Soncsy.
Yes, you are right :)
I am just wondering, is there any chance to have your above suggestion on script. Sorry, I am just beginner with the powershell and not much idea about writing script.
Or please let me know if you have any other suggestion to improve my powershell script skill.

Once again, thank you very much the comment :)

Regards,
Kiran
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Stop and restart the Veeam backup during Windows Update

Post by oleg.feoktistov » 1 person likes this post

Hi Kiran,

This is out of scope of our powershell forum. The features you are asking about are related to native windows capabilities. I would start searching through the answers in Microsoft community.

Thanks,
Oleg
soncscy
Veteran
Posts: 643
Liked: 312 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey
Contact:

Re: Stop and restart the Veeam backup during Windows Update

Post by soncscy »

>I am just wondering, is there any chance to have your above suggestion on script. Sorry, I am just beginner with the powershell and not much idea about writing script.

Sorry, but I'm afraid I can't commit time to this for the foreseeable future for volunteer purposes. The logic is there, and you just need to explore how Powershell properties work. Maybe you can do a fiver.com advert, as this is pretty simple. Even if you're a n00b, this is a great project to learn on.
Kiranpn
Enthusiast
Posts: 27
Liked: 2 times
Joined: Mar 18, 2021 4:48 am
Full Name: Kiran Pradhan
Contact:

Re: Stop and restart the Veeam backup during Windows Update

Post by Kiranpn »

Thank you Soncscy :)
I will check above.

Regards,
Kiran
Kiranpn
Enthusiast
Posts: 27
Liked: 2 times
Joined: Mar 18, 2021 4:48 am
Full Name: Kiran Pradhan
Contact:

Re: Stop and restart the Veeam backup during Windows Update

Post by Kiranpn »

oleg.feoktistov wrote: May 14, 2021 1:20 pm Hi Kiran,

This is out of scope of our powershell forum. The features you are asking about are related to native windows capabilities. I would start searching through the answers in Microsoft community.

Thanks,
Oleg
Thank you, Oleg :)


Last bumped by Kiranpn on Jun 07, 2021 6:18 am.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 17 guests