Specify database files SQL target location from PS

PowerShell script exchange

Specify database files SQL target location from PS

Veeam Logoby vburgun » Mon Jun 12, 2017 4:35 pm

Hi
I need to plan the automatic restoration of a database from one server to another.
I thought I could do it with PowerShell.

Unfortunately, the locations of the data and logs are not the same between the two servers.

I can not find a parameter to modify the location of the data with the command "Start-VBRSQLDatabaseRestore".

I tried to create a blank database with the correct parameters on the destination server. But when Veeam restores the database, it overwrites the existing database and recreates a database with default locations.

Code: Select all
invoke-sqlcmd -inputfile "$DatabaseDestination.sql" -serverinstance $ServeurDestination


Code: Select all
Connect-VBRServer -Server $ServeurVeeam
#$LastBackup = (Get-VBRApplicationRestorePoint -SQL -Name "$ServeurSQLSource")[-1]
#$BackuBase = $LastBackup | Get-VBRSQLDatabaseRestoreInterval -Database $Database
$LastBackup = (Get-VBRApplicationRestorePoint -SQL -Name "$ServeurSQLSource")[-1]
$BackuBase = Get-VBRSQLDatabase -ApplicationRestorePoint $LastBackup[0] -Name "$DatabaseSource"
$Interval = Get-VBRSQLDatabaseRestoreInterval -Database $BackuBase
#$Cred = Get-VBRCredentials -Name "OFIVALMO\svc_vea_bck"
Start-VBRSQLDatabaseRestore -Database $BackuBase -ServerName $ServeurDestination -DatabaseName $DatabaseDestination
Disconnect-VBRServer


Can you help me ? Or do you know another way?
vburgun
Lurker
 
Posts: 1
Liked: never
Joined: Mon Jun 12, 2017 4:24 pm
Full Name: vburgun

Re: Specify database files SQL target location from PS

Veeam Logoby dgmyrs » Wed Aug 02, 2017 4:48 pm

Hi, I know this might be a bit late, but hopefully, it is still helpful. From what I have found, there is no way to specify the file location with the powershell commandlets. See powershell-f26/sql-server-default-file-locations-t42895.html for more details on what I have found. To get around this, in my script I have let it restore to the default location and then issue sql commands afterwards to change the file location/name. Not ideal, but it's the only method that works with PowerShell.
dgmyrs
Lurker
 
Posts: 2
Liked: 2 times
Joined: Thu Nov 10, 2016 5:14 pm

Re: Specify database files SQL target location from PS

Veeam Logoby v.Eremin » Thu Aug 03, 2017 11:44 am

We're working on that at the moment. One of the next product release should have this functionality included. Thanks.
v.Eremin
Veeam Software
 
Posts: 14722
Liked: 1102 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Specify database files SQL target location from PS

Veeam Logoby rweis » Thu Apr 19, 2018 2:24 pm

Has this been addressed yet, the commands to specify the file locations with PowerShell?
Randy Weis
Enterprise SE, NA Strategic Accounts
rweis
Veeam Software
 
Posts: 124
Liked: 15 times
Joined: Mon Jun 13, 2011 7:46 pm
Location: South Coast Massachusetts
Full Name: Randy Weis

Re: Specify database files SQL target location from PS

Veeam Logoby v.Eremin » Thu Apr 19, 2018 3:26 pm

Not yet. Thanks.
v.Eremin
Veeam Software
 
Posts: 14722
Liked: 1102 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Specify database files SQL target location from PS

Veeam Logoby rweis » Thu Apr 19, 2018 3:32 pm

I thought I'd found the answer, but this really doesn't address the individual file restore location question. Any idea if this will be added in the near future?

The following is an excerpt from the PowerShell Reference Guide, https://helpcenter.veeam.com/docs/backu ... tml?ver=95
Randy Weis
Enterprise SE, NA Strategic Accounts
rweis
Veeam Software
 
Posts: 124
Liked: 15 times
Joined: Mon Jun 13, 2011 7:46 pm
Location: South Coast Massachusetts
Full Name: Randy Weis

Re: Specify database files SQL target location from PS

Veeam Logoby v.Eremin » Thu Apr 19, 2018 3:35 pm

Correct, plans to add this functionality are still there. Thanks.
v.Eremin
Veeam Software
 
Posts: 14722
Liked: 1102 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 7 guests