PowerShell script exchange
Post Reply
csmall
Enthusiast
Posts: 30
Liked: 2 times
Joined: Mar 20, 2018 1:19 pm
Full Name: Colin Small
Contact:

Restoring a SQL database Question

Post by csmall »

If I restore a SQL database to a target server other than the original that contains no databases, the entire database will be restored and I have confirmed this works with the script I am using.

My question is, after the database has been restored once in full to the target server, is it possible with powershell to from that point on only restore incremental changes? It would be great to have a quicker restore than restoring the entire database and replacing the existing one each time it runs.
csmall
Enthusiast
Posts: 30
Liked: 2 times
Joined: Mar 20, 2018 1:19 pm
Full Name: Colin Small
Contact:

Re: Restoring a SQL database Question

Post by csmall »

The restorepoint selected to be restored is an incremental.

Is this the expected behavior?

Restorepoint = Incremental
If no database exists on the target: The full database is restored to the target.
If the database already exists on the target: Only the incremental changes are restored to the target.
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Restoring a SQL database Question

Post by veremin »

Can you provide us with the script, so that we can understand the situation better? Thanks!
csmall
Enthusiast
Posts: 30
Liked: 2 times
Joined: Mar 20, 2018 1:19 pm
Full Name: Colin Small
Contact:

Re: Restoring a SQL database Question

Post by csmall »

The script is a work in progress but I think my question is more generic than the specifics of the script.

If I do a restore to a target that has no databases from an incremental restorepoint, it restores the entire database in full (I get this).

I was wondering if I run the same restore again from a newer incremental restorepoint, will it overwrite the entire database again or will it restore the differences?

I plan on testing this tomorrow after tonight's incremental runs. I already preformed the full restore from last nights incremental.

There is a behavior I don't understand though when it comes to getting the available restore points, maybe you can answer this one.

When running Get-VBRApplicationRestorePoint -SQL -Name NAME_OF_BACKED_UP_SERVER it seems to return all possible restorepoints from both backups and backup copies. When I ran the restore mentioned above it actually used the backup copy instead of the backup.

How can I force it to only use the backups and not the backup copies? I ask because the backup copies will eventually exist off site and I do not want to do a restore over the WAN. Is there a way to filter and only use backups and no backup copies for restores from powershell?
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Restoring a SQL database Question

Post by veremin »

You should explicitly provide the restore point created by a backup job to Start-VESQLREstoreSession cmdlet. Thanks!
csmall
Enthusiast
Posts: 30
Liked: 2 times
Joined: Mar 20, 2018 1:19 pm
Full Name: Colin Small
Contact:

Re: Restoring a SQL database Question

Post by csmall »

I think I am basically doing that but using the older command Start-VBRSQLDatabaseRestore.

The latest restorepoint is captured with

Code: Select all

Get-VBRApplicationRestorePoint -SQL -Name SERVER_NAME | Where-Object {$_.CreationTime -ge $LatestBackupDate}|Sort-Object -Descending | Select -First 1
and

Code: Select all

Get-VBRSQLDatabase -ApplicationRestorePoint RESTOREPOINT_FROM_ABOVE -Name DATABASE_NAME
followed by

Code: Select all

Start-VBRSQLDatabaseRestore -Database DATABASE_TO_RESTORE -ServerName TARGET_SERVER_NAME -InstanceName " " -DatabaseName DATABASE_NAME -GuestCredentials guestcreds -SqlCredentials sqlcreds -Force
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Restoring a SQL database Question

Post by veremin »

Then, it means the latest restore point is the one created by backup copy job. By the way, you should switch to using new VESQL cmdlets, as support for old ones will be discontinued soon. Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 31 guests