Restore-VESQLDatabase

Short Description

Restores a backed-up Microsoft SQL database.

Applies to

Veeam Backup & Replication

Product Edition: Enterprise, Enterprise Plus, Veeam Universal License

Syntax

Restore-VESQLDatabase [-Database] <VESQLDatabase> [-DatabaseName <String>] [-ServerName <String>] [-InstanceName <String>] [-Port <Int32>] [-SqlCredentials <PSCredential>] [-UseSQLAuthentication] [-GuestCredentials <PSCredential>] [-ToPointInTimeUtc <DateTime>] [-AvailabilityGroupName <String>] [-TargetFolder <String>] [-File <VESQLDatabaseFile[]>] [-TargetPath <String[]>] [-Force] [-RecoveryState <RestoreMode>] [-StandbyFilePath <String>] [<CommonParameters>]

Detailed Description

This cmdlet restores a backed-up Microsoft SQL database. You can restore a Microsoft SQL database to the original location or to another location.

Parameters

Parameter

Description

Type

Required

Position

Accept Pipeline Input

Database

Specifies a Microsoft SQL Server database that you want to restore.

Accepts the VESQLDatabase object. To get this object, run the Get-VESQLDatabase cmdlet.

True

0

True (ByValue)

DatabaseName

For restore to another location.

Specifies a name for the restored Microsoft SQL Server database on the target location. The database will be restored with the specified name.

String

False

Named

False

ServerName

For restore to another location.

Specifies DNS name or IP address of a Microsoft SQL target server. The cmdlet will restore a Microsoft SQL database to the specified target server.

String

False

Named

False

InstanceName

For restore to another location.

Specifies the name of the target instance. The cmdlet will restore the Microsoft SQL Server database to the specified target instance.

String

False

Named

False

Port

Specifies a port number that will be used to connect to the target Microsoft SQL Server machine.

Int32

False

Named

False

SqlCredentials

Specifies SQL credentials for authenticating to Microsoft SQL Server on the target machine.

Note: If you do not specify SQL credentials, the cmdlet will use the current account credentials. If these credentials do not work, the cmdlet will use the credentials specified in the backup job.

Accepts the PSCredential object. To get this object, run the Get-Credential cmdlet.

False

Named

False

UseSQLAuthentication

Defines that the cmdlet will use SQL authentication to connect to Microsoft SQL Server on the target machine.

Note: If you omit this parameter, the cmdlet will use credentials specified in the SQLCredentials parameter to connect to both Microsoft SQL Server and to the guest OS.

SwitchParameter

False

Named

False

GuestCredentials

Specifies credentials for authenticating to the target machine. If these credentials do not work, the cmdlet will use the credentials specified in the backup job.

Consider the following:

  • If you omit this parameter, the cmdlet will use the credentials specified in the SqlCredentials parameter to connect to both Microsoft SQL Server and to the guest OS.
  • If you do not specify SQL credentials, the cmdlet will use the current account credentials.

Accepts the PSCredential object. To get this object, run the Get-Credential cmdlet.

False

Named

False

ToPointInTimeUtc

Specifies a point in time in UTC within the restore interval of a Microsoft SQL database.

The cmdlet will restore the database to the state of the specified point in time.

DateTime

False

Named

False

AvailabilityGroupName

Specifies the name of the AlwaysOn availability group. The cmdlet will add a Microsoft SQL database to the specified group.

String

False

Named

False

TargetFolder

For restoring Microsoft SQL database files to one location.

Specifies the destination folder. The cmdlet will restore all database files to that folder.

Note: This parameter is not available if you use the TargetPath parameter.

String

False

Named

False

File

Specifies an array of file names for Microsoft SQL databases.

Accepts the VESQLDatabaseFile[] object. To get this object, run the Get-VESQLDatabaseFile cmdlet.

False

Named

False

TargetPath

Specifies a target path array. The cmdlet will restore Microsoft SQL database files to the locations specified in the target path array.

Consider the following:

  • For every Microsoft SQL database file, you must assign a specific file path.
  • This parameter is not available if you use the TargetFolder parameter.

String[]

False

Named

False

Force

Defines that the cmdlet will overwrite an existing Microsoft SQL database with a Microsoft SQL database from the backup.

Note: The cmdlet will show no prompt before executing the command.

SwitchParameter

False

Named

False

RecoveryState

Specifies the restore scenario.

  • Recovery — use this option to leave a Microsoft SQL database in the ready to use state. With this option, you will not be able to restore additional transaction logs.
  • NoRecovery — use this option to leave a Microsoft SQL database in the non-operational state and to avoid rolling back uncommitted transactions. Use this option to restore transaction logs that are backed up with a third-party tool.
  • StandBy — use this option to leave the Microsoft SQL database in the read-only mode. It allows you to undo uncommitted transactions. The undo actions are saved in a standby file so that the recovery effects can be reversed.

Default: Recovery

RestoreMode

False

Named

False

StandbyFilePath

For the StandBy parameter.

Specifies a location for the standby file with the uncommitted transactions.

String

False

Named

False

<CommonParameters>

This cmdlet supports Microsoft PowerShell common parameters. For more information on common parameters, see the About CommonParameters section of Microsoft Docs.

Output Object

None.

Examples

Restore-VESQLDatabaseExample 1. Restoring Microsoft SQL Server Database to Original Location

Restore-VESQLDatabaseExample 2. Restoring Microsoft SQL Server Database to Specific Folder

Restore-VESQLDatabaseExample 3. Restoring Microsoft SQL Server Database Files to Specific Path Array

Restore-VESQLDatabaseExample 4. Restoring Microsoft SQL Server Database to Point in Time State

Related Commands

Page updated 4/4/2025

Page content applies to build 12.3.1.1139