PowerShell script exchange
Post Reply
manuel.aigner
Enthusiast
Posts: 35
Liked: 5 times
Joined: Sep 25, 2017 8:25 am
Full Name: Manuel Aigner
Contact:

[FEATURE REQUEST] Assign SQL log shipping server to object

Post by manuel.aigner »

Hi there,

I can't find any cmdlet which is able to assign designated log shipping servers to a job object for transaction log backup.
It's only possible to enable or disable auto selection. If it's disabled, no log shipping server is selected -> therefore useless... this config can't work.

It's necessary in our environment to declare this servers because only a few veeam servers are (firewall) permitted to do this.

ATM there are two options for us:

#1 Let auto select enabled.
Log backup jobs will work, but takes longer then necessary because many connection trials will fail (Firewall) until the right veeam server has found.

#2 Configure it manually via GUI.
URGH... I've automated everything. It's not nice to do only this thing manually (big potential for human mistakes).
tsightler
VP, Product Management
Posts: 6035
Liked: 2860 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: [FEATURE REQUEST] Assign SQL log shipping server to obje

Post by tsightler » 2 people like this post

Here's a workaround that I've used with a few other cases. It makes one call directly to a .NET function, so it's unsupported, but it seems to work just fine as long as you pass it valid data. If you somehow pass the call with the wrong host ID it can leave you in a state where the GUI will give an error about a missing ID and not open the VSS dialog (yes, I had this happen with a customer that didn't fully understand how to use it and passed the proxy ID instead of the Host ID). This is easily fixed by removing the bad entry from the OijProxies table. Basically, it's only one unsupported call to a very simple function, so I consider this fairly safe if you validate the information you are submitting is accurate, i.e. the correct object-in-job ID and the correct host ID for the log shipping server. Also, you can repeat the call to add more log shipping servers.

Code: Select all

# Get the Job
$Job = Get-VBRJob -Name "<Backup_Job_Name>"

# Get the Job object to set VSS Options
$SqlOij = Get-VBRJobObject -Job $Job -Name "<Job_Object_Name>"

# Get the Server object for the log server
$LogServer = Get-VBRServer -Type Windows -Name "<Log_Server_Name>"

# Set the SQL VSS for manual log shipping server
$SqlOij.VssOptions.SqlBackupOptions.ProxyAutoSelect = $false

# Add a server as a log shipping server for this object
[Veeam.Backup.Core.COijProxy]::Create($SqlOij.Id, $LogServer.Id, 0)

# Save the VSS Options
Set-VBRJobObjectVssOptions -Object $SqlOij -Options $SqlOij.VssOptions
manuel.aigner
Enthusiast
Posts: 35
Liked: 5 times
Joined: Sep 25, 2017 8:25 am
Full Name: Manuel Aigner
Contact:

Re: [FEATURE REQUEST] Assign SQL log shipping server to obje

Post by manuel.aigner »

Hi Tom,

many thanks, I'll check this. But I think that will help :D
manuel.aigner
Enthusiast
Posts: 35
Liked: 5 times
Joined: Sep 25, 2017 8:25 am
Full Name: Manuel Aigner
Contact:

Re: [FEATURE REQUEST] Assign SQL log shipping server to obje

Post by manuel.aigner »

Update:
Works perfectly :)
filipsmeets
Enthusiast
Posts: 37
Liked: 3 times
Joined: Jun 26, 2019 3:28 pm
Full Name: Filip Smeets
Contact:

Log shipping

Post by filipsmeets »

Is there a way to configure which log shipping servers should be used through powershell?

Guest Processing --> Enable Application Aware Processing --> Applications --> Edit --> SQL --> Log Shipping Servers.
Egor Yakovlev
Product Manager
Posts: 2581
Liked: 708 times
Joined: Jun 14, 2013 9:30 am
Full Name: Egor Yakovlev
Location: Prague, Czech Republic
Contact:

Re: [FEATURE REQUEST] Assign SQL log shipping server to object

Post by Egor Yakovlev »

Hi Filip,
I have moved your post to the existing feature request thread.
There is no native object property for Log Shipping Server yet, however please check a workaround provided by Tom.
Hope that helps!
Sven M.
Novice
Posts: 6
Liked: never
Joined: May 08, 2017 11:19 am
Full Name: Sven Moeller
Contact:

Re: [FEATURE REQUEST] Assign SQL log shipping server to object

Post by Sven M. »

Hello,

I can confirm that this script works for set a new log shipping server but my question is:
How is the command for remove a log shipping server?

Thanks for your help.
Sven
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: [FEATURE REQUEST] Assign SQL log shipping server to object

Post by oleg.feoktistov »

HI Sven,

To remove it we still need to dive into unsupported stuff. Here is the script:

Code: Select all

# Get the Job
$Job = Get-VBRJob -Name "Backup job"

# Get all log shipping servers per job
$proxy = [Veeam.Backup.Core.COijProxy]::GetOijProxiesByJob($job.Id)
# Delete log shipping server by index 0
[Veeam.Backup.Core.COijProxy]::Delete($proxy[0].Id) 
If you want to just remove the server and assign automatic selection, don't forget to also set ProxyAutoSelect to true:

Code: Select all

# Get the Job object to set VSS Options
$SqlOij = Get-VBRJobObject -Job $Job -Name "Object name"

# Set the SQL VSS for manual log shipping server
$SqlOij.VssOptions.SqlBackupOptions.ProxyAutoSelect = $true

# Save the VSS Options
Set-VBRJobObjectVssOptions -Object $SqlOij -Options $SqlOij.VssOptions
Thanks,
Oleg
Sven M.
Novice
Posts: 6
Liked: never
Joined: May 08, 2017 11:19 am
Full Name: Sven Moeller
Contact:

Re: [FEATURE REQUEST] Assign SQL log shipping server to object

Post by Sven M. »

Hello Oleg,

thanks for your reply and sorry for my delay... I'll test it asap and let you know... thanks.

Regards
Sven
Sven M.
Novice
Posts: 6
Liked: never
Joined: May 08, 2017 11:19 am
Full Name: Sven Moeller
Contact:

Re: [FEATURE REQUEST] Assign SQL log shipping server to object

Post by Sven M. »

Hello Oleg,

I could test a bit and usually I'm able to delete log shipping server but I'm not clear how does it works because:
on this position "[Veeam.Backup.Core.COijProxy]::DELETE($SqlOij.Id, $LogServer.Id, 0)" the script delete one of my selected server. I mean my sql server has 5 possibities log shipping servers activated and one of this would deleted. If I can run the whole script (for my job) five times and all log shipping are deleted. For a worlaround I cat set my log shipping servers which I will use again.

It would be nice if I can delete a log shippinmg server by name or something like that.

It's possisble? ;)

Otherwise thanks fpr your help and I can use the workaround.

Regards
Sven
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: [FEATURE REQUEST] Assign SQL log shipping server to object

Post by oleg.feoktistov »

Hi Sven,

To parse it by name, just add filtering to the Get method:

Code: Select all

# Get all log shipping servers per job
$proxy = [Veeam.Backup.Core.COijProxy]::GetOijProxiesByJob($job.Id) | where {$_.Proxy.Name -eq 'host-name'}
Thanks,
Oleg
Sven M.
Novice
Posts: 6
Liked: never
Joined: May 08, 2017 11:19 am
Full Name: Sven Moeller
Contact:

Re: [FEATURE REQUEST] Assign SQL log shipping server to object

Post by Sven M. »

Hi Oleg,

thanks for your reply and I'll test it soon and will let you know.

Regards
Sven
Sven M.
Novice
Posts: 6
Liked: never
Joined: May 08, 2017 11:19 am
Full Name: Sven Moeller
Contact:

Re: [FEATURE REQUEST] Assign SQL log shipping server to object

Post by Sven M. »

Hello Oleg,

I could test your script successfully... thank you.

Regards
Sven
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests