PowerShell script exchange
Post Reply
steri
Influencer
Posts: 24
Liked: 3 times
Joined: Aug 06, 2015 4:34 pm
Contact:

SQL Backup Script

Post by steri »

Hi.

I have an SQL Cluster with direct attached Network Cards in the configuration.
The problem is i can not Backup this Cluster because i can not snapshot this machines with the direct attached network cards in Online state.

Now i need a script to test the server is SQL Cluster active. When it is active do a SQL Cluster change.
After this... Shutdown the server for backup.... Backup the Server.... After Backup is complete start the server again and make it SQL Cluster active again after SQL Sync is complete.

Then start with the second SQL Server

Have anyone practice experience with this solution ? Maybe an example Script ? Thanks a lot

Best Regards

Steri
PTide
Product Manager
Posts: 6551
Liked: 765 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: SQL Backup Script

Post by PTide »

Hi,

I'm not sure whether the offline mode lets you to take a snapshot...If yes, then the best way to do a backup would be to use a combination of pre- and post- job scripts.

Here is a logical schema:

1. Script before job (Backup Job -> Storage -> Advanced -> Advanced):

1.1 Call script insider1.bat inside VM

insider.bat:

Code: Select all

if [ Active ]
 {
 Switch Roles
 }
Shutdown
2. Backup VM

3. Script after job (Backup Job -> Storage -> Advanced -> Advanced):

3.1 Power On
3.2 Call script insider2.bat inside VM

insider2.bat:

Code: Select all

If [ SyncComplete ]
 {
 SetActive(ThisMachine)
 }
 Else
 {
 Wait
 SetActive(ThisMachine)
 }
Such a schema will proccess all VMs in a job in the same way.

If the offline state does not let you to do a snapshot, then you might want to add a few lines utilizing PowerCLI in order to detach your direct I/O NIC temporarily and add it back after backup procedure is finished.

Thank you.
PTide
Product Manager
Posts: 6551
Liked: 765 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: SQL Backup Script

Post by PTide »

P.S. Also please specify what is "direct attached network card"? Is it SR-IOV or Direct path?

Thank you.
steri
Influencer
Posts: 24
Liked: 3 times
Joined: Aug 06, 2015 4:34 pm
Contact:

Re: SQL Backup Script

Post by steri »

Hi.

The method is SR-IOV Passthrough

Regards Steri
PTide
Product Manager
Posts: 6551
Liked: 765 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: SQL Backup Script

Post by PTide »

It's definetily possible to take a snapshot of a powered-off VM with direct I/O device attached. I believe that the same applies to SR-IOV, but I can't tell that for sure - haven't tested that yet. If snapshots are "ok" with powered-off SR-IOV VM then the approach I've mentioned in my first post seems to be a way to go.

Thank you.
steri
Influencer
Posts: 24
Liked: 3 times
Joined: Aug 06, 2015 4:34 pm
Contact:

Re: SQL Backup Script

Post by steri »

You can snapshot a powered off VM

Regards Steri
mad1987
Lurker
Posts: 2
Liked: never
Joined: Oct 02, 2018 12:15 pm
Contact:

Re: SQL Backup Script

Post by mad1987 »

Do you have a sample script?
veremin
Product Manager
Posts: 20406
Liked: 2299 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: SQL Backup Script

Post by veremin »

You should use PowerCLI for that:

Code: Select all

$VM = Get-VM -Name "Name of your VM"
New-Snapshot -VM() -Name "Name of snapshot"
Be aware that example has been written from the memory, so, the required syntax might be slightly different.

Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests