PowerShell script exchange
Post Reply
userbit
Lurker
Posts: 1
Liked: never
Joined: Jun 02, 2016 10:34 pm
Contact:

Restore to another server

Post by userbit »

What I need to do might have already been discussed here but I couldnt find it

Im not new to SQL or Powershell, but im going through the example here.
However, I am new to Veeam.
https://helpcenter.veeam.com/backup/pow ... store.html

Need to simply restore one or more db's from a production backup to an instance on a development or test server.

Normally I do this:
- connect to the dev server as my own domain account (i have sysadmin rights)
- copy down the backup from the production server to a folder on the dev server
- set to single user mode
- restore/replace the target db using the backup file
- reset to multiuser mode

So my questions are:
- am I correct, ill need to run the powershell script from the server where Veeam is installed? (or run remote on this server from my workstation?)
- in the example above, what is meant by a "restore point", cant I just get the most recent full backup?
- how can I specify the restore to use my domain credentials, seeing as myself or anyone running a powershell script to do this will likely also be a sysadmin on sql
- will sql credentials also be required even if im wanting to do this in the context my my domain account?
- regarding both credential(s) questions, can I just specify "my_domain\my_login" in both to get both credential types?

So a "complete" script might be something like this, assuming I get the "restore point" part figured out, also I dont care about specific point in time, just the previous day's full backup.
So maybe, Ill need a step that gets that?

Code: Select all

$crmdb = Get-VBRApplicationRestorePoint -SQL -Name "CRM-db" | Sort -Descending | Select -First 1
$guestcreds = Get-VBRCredentials -Name "domain\name"
$sqlcreds = Get-VBRCredentials -Name "domain\name"
$target-server = "DEV-SERVER1"
Start-VBRSQLDatabaseRestore -Database $locations -ServerName $target-server -GuestCredentials $guestcreds -SqlCredentials $sqlcreds -ToPointInTime "10/28/2015 12:33:39 PM"
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Restore to another server

Post by veremin »

- am I correct, ill need to run the powershell script from the server where Veeam is installed? (or run remote on this server from my workstation?)
You can run it either locally or remotely. In the later case leverage Connect-VBRServer commandlet.
- in the example above, what is meant by a "restore point", cant I just get the most recent full backup?
As mentioned in the User Guide, this cmdlet returns restore points of backups that were created with the VSS-aware image processing enabled.

The most recent restore points can be found in the following manner:

Code: Select all

Get-VBRApplicationRestorePoint -SQL -Name "CRM-db" | Sort-Object creationtime -Descending | Select -First 1
- how can I specify the restore to use my domain credentials, seeing as myself or anyone running a powershell script to do this will likely also be a sysadmin on sql
- will sql credentials also be required even if im wanting to do this in the context my my domain account?
- regarding both credential(s) questions, can I just specify "my_domain\my_login" in both to get both credential types?
You have to provide both credentials to authenticate with the target server and credentials to authenticate with the target SQL instance. Otherwise, those would be taken from backup job settings.

The same account can be used twice, if it has required permissions.

Thanks.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 16 guests