Start-VEPSQLInstanceRestore

Short Description

Restores a backed-up PostgreSQL instance.

Applies to

Veeam Backup & Replication

Product Edition: Enterprise, Enterprise Plus, Veeam Universal License

Syntax

This cmdlet provides parameter sets that allow you to:

  • Restore a PostgreSQL instance to a Windows-based machine.

Start-VEPSQLInstanceRestore [-Instance] <VEPSQLInstance> [[-ToPointInTimeUTC] <DateTime>] -WindowsCredentials <PSCredential> [-ServerName <String>] [-DataDirectory <String>] [-PostRestoreAction <VEPSQLPostRestoreAction>] [-Force] [-TablespacePath <String[]>] [-Tablespace <VEPSQLTableSpace[]>] [-Port <Int32>] [<CommonParameters>]

  • Restore a PostgreSQL instance to a Linux-based machine.

Start-VEPSQLInstanceRestore [-Instance] <VEPSQLInstance> [[-ToPointInTimeUTC] <DateTime>] -LinuxCredentials <VEPSQLLinuxCredential> [-ServerName <String>] [-DataDirectory <String>] [-PostRestoreAction <VEPSQLPostRestoreAction>] [-SshPort <Int32>] [-Force] [-TablespacePath <String[]>] [-Tablespace <VEPSQLTableSpace[]>] [-Port <Int32>] [<CommonParameters>]

Detailed Description

This cmdlet restores a backed-up PostgreSQL instance.

Parameters

Parameters

Parameter

Description

Type

Required

Position

Accept Pipeline Input

Instance

Specifies a PostgreSQL instance that the cmdlet will restore.

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

True

0

True (ByValue)

ToPointInTimeUTC

Specifies the point in time in the UTC format within a restore interval of the PostgreSQL instance.

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

If you do not use this parameter, the cmdlet will restore the instance to the point in time when the restore point for which you started the restore session was created.

DateTime

False

1

False

LinuxCredentials

For restore to a Linux machine.

Specifies Linux credentials. The cmdlet will use these credentials to connect to the target PostgreSQL server.

Accepts the VEPSQLLinuxCredential object. To get this object, run the New-VEPSQLLinuxCredential cmdlet.

True

Named

True (ByValue)

WindowsCredentials

For restore to a Windows machine.

Specifies Windows credentials. The cmdlet will use these credentials to connect to the target PostgreSQL server.

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

True

Named

True (ByValue)

ServerName

For restore to another server.

Specifies DNS name or IP address of the target PostgreSQL server. The cmdlet will restore a PostgreSQL instance to that server.

String

False

Named

False

DataDirectory

Specifies a path to the data directory for the restored PostgreSQL instance. The cmdlet will restore the specified instance to the specified data directory.

String

False

Named

False

PostRestoreAction

Specifies the action with the restored PostgreSQL instance.

  • Promote — use this option to start the instance after restore. The instance will operate in a regular way as a production instance.
  • Pause — use this option to start the instance after restore. The instance will operate but will not accept incoming TCP connections. This option is useful, for example, if you want to verify the state of the PostgreSQL database after restore.
  • Shutdown — use this option to restore the instance without starting the instance after the restore process is completed.

Default: Promote

VEPSQLPostRestoreAction

False

Named

False

SshPort

Specifies the SSH port number. The cmdlet will use this port to connect to the Linux machine.

Default: 22

Int32

False

Named

False

Force

Defines that the cmdlet will replace the target PostgreSQL instance with the instance from the backup.

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

SwitchParameter

False

Named

False

TablespacePath

Specifies an array of tablespace paths for the restored PostgreSQL instance. The cmdlet will restore PostgreSQL tablespaces to locations specified in this array.

Note: This parameter must be used together with the Tablespace parameter.

String[]

False

Named

False

Tablespace

Specifies an array of tablespace names for the restored PostgreSQL instance. The cmdlet will restore tablespaces specified in this array.

Note:

  • For every PostgreSQL tablespace, you must assign a specific tablespace path.
  • This parameter must be used together with the TablespacePath parameter.

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

False

Named

False

Port

Specifies the port to connect to the restored PostgreSQL instance.

Int32

False

Named

False

<CommonParameters>

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

Output Object

The cmdlet returns the VEPSQLInstanceRestore object that contains information about the restore process for the PostgreSQL instance.

Examples

Example 1. Restoring PostgreSQL Instance to Original Server

This example shows how to restore a backed-up PostgreSQL instance to a target PostgreSQL server. The restore operation will start with the following settings:

  • The cmdlet will use the credentials specified in the backup job.
  • The cmdlet will restore the instance to the point in time when the restore point for which you started the restore session was created.
  • The cmdlet will restore the instance to the original PostgreSQL server.

$session = Get-VEPSQLRestoreSession

$instance = Get-VEPSQLInstance -Session $session[0] -DataDirectory /var/lib/pgsql/13/data

$restore = Start-VEPSQLInstanceRestore -Instance $instance

Perform the following steps:

  1. Run the Get-VEPSQLRestoreSession cmdlet. Save the result to the $session variable.

The cmdlet will return an array of active restore sessions. Note the ordinal number of the necessary restore session. In this example, it is the first restore session in the array.

  1. Run the Get-VEPSQLInstance cmdlet. Set the $session variable as the Session parameter value. Specify the DataDirectory parameter value. Save the result to the $instance variable.
  2. Run the Start-VEPSQLInstanceRestore cmdlet. Set the $instance variable as the Instance parameter value. Save the result to the $restore variable to be able to use it with other cmdlets.

Example 2. Restoring PostgreSQL Instance to Another Linux Server

This example shows how to restore a backed-up PostgreSQL instance to a target Linux-based PostgreSQL server. The restore operation will start with the following settings:

  • The cmdlet will use custom Linux credentials to connect to the target Linux machine.
  • The cmdlet will restore the instance to a specific point in time.
  • The cmdlet will restore the instance to another PostgreSQL server.
  • The cmdlet will restore the instance to a specific data directory.
  • The cmdlet will restore tablespaces of the PostgreSQL instance to specific paths.

$session = Get-VEPSQLRestoreSession

$time = Get-Date -Date "2026-06-24 13:00:00"

$timeutc = $time.ToUniversalTime()

$securepassword = Read-Host -Prompt "Enter password" -AsSecureString

$credentials = New-VEPSQLLinuxCredential -Account "postgres" -Password $securepassword -ElevateAccountToRoot

$instance = Get-VEPSQLInstance -Session $session[0] -DataDirectory /var/lib/pgsql/13/data

$tbsp = @("/ssd1/postgresql/data","/ssd2/postgresql/data2")

$tbsplist = Get-VEPSQLTablespace -Instance $instance

$restore = Start-VEPSQLInstanceRestore -Instance $instance -ToPointInTimeUTC $timeutc -ServerName srv01.tech.local -LinuxCredentials $credentials -DataDirectory /var/lib/pgsql/13/database -TablespacePath $tbsp -Tablespace $tbsplist -SshPort 23 -Port 5555

Perform the following steps:

  1. Run the Get-VEPSQLRestoreSession cmdlet. Save the result to the $session variable.

The cmdlet will return an array of active restore sessions. Note the ordinal number of the necessary restore session. In this example, it is the first restore session in the array.

  1. Run the Get-Date cmdlet. Specify the Date parameter value to set the point in time to which the instance must be restored. Save the result to the $time variable.
  2. Convert the scheduled time to the UTC format using the ToUniversalTime() method. Save the result to the $timeutc variable.
  3. Run the Read-Host cmdlet. Specify the Prompt parameter value. Provide the AsSecureString parameter. Save the result to the $securepassword variable.
  4. Run the New-VEPSQLLinuxCredential cmdlet. Specify the Account parameter value. Set the $securepassword variable as the Password parameter value. Provide the ElevateAccountToRoot parameter. Save the result to the $credentials variable.
  5. Run the Get-VEPSQLInstance cmdlet. Set the $session variable as the Session parameter value. Specify the DataDirectory parameter value. Save the result to the $instance variable.
  6. Declare the $tbsp variable. Assign to this variable the array of tablespace paths for the restored PostgreSQL instance.
  7. Run the Get-VEPSQLTablespace cmdlet to get the list of tablespace names for the restored PostgreSQL instance. Set the $instance variable as the Instance parameter value. Save the result to the $tbsplist variable.
  8. Run the Start-VEPSQLInstanceRestore cmdlet. Specify the following settings:
  • Set the $instance variable as the Instance parameter value.
  • Set the $timeutc variable as the ToPointInTimeUTC parameter value.
  • Specify the ServerName parameter value.
  • Set the $credentials variable as the LinuxCredentials parameter value.
  • Specify the DataDirectory parameter value.
  • Set the $tbsp variable as the TablespacePath parameter value.
  • Set the $tbsplist variable as the Tablespace parameter value.
  • Specify the SshPort parameter value.
  • Specify the Port parameter value.

Save the result to the $restore variable to be able to use it with other cmdlets.

Example 3. Restoring PostgreSQL Instance to Another Windows Server

This example shows how to restore a backed-up PostgreSQL instance to a target Windows-based PostgreSQL server. The restore operation will start with the following settings:

  • The cmdlet will use custom Windows credentials to connect to the target Windows machine.
  • The cmdlet will restore the instance to the latest state on the backup file.
  • The cmdlet will restore the instance to another PostgreSQL server.
  • The cmdlet will select the instance located in the C:\Program Files\PostgreSQL\18\data data directory.

$session = Get-VEPSQLRestoreSession

$instance = Get-VEPSQLInstance -Session $session[0] -DataDirectory "C:\Program Files\PostgreSQL\18\data"

$credential = Get-Credential

$restore = Start-VEPSQLInstanceRestore -Instance $instance -ServerName srv02.tech.local -WindowsCredentials $credential -Port 5555

Perform the following steps:

  1. Run the Get-VEPSQLRestoreSession cmdlet. Save the result to the $session variable.

The cmdlet will return an array of active restore sessions. Note the ordinal number of the necessary restore session. In this example, it is the first restore session in the array.

  1. Run the Get-VEPSQLInstance cmdlet. Set the $session variable as the Session parameter value. Specify the DataDirectory parameter value. Save the result to the $instance variable.
  2. Run the Get-Credential cmdlet to create a credential object. Enter credentials that will be used for authenticating to the target PostgreSQL machine. Save the result to the $credential variable.
  3. Run the Start-VEPSQLInstanceRestore cmdlet. Specify the following settings:
  • Set the $instance variable as the Instance parameter value.
  • Specify the ServerName parameter value.
  • Set the $credential variable as the WindowsCredentials parameter value.
  • Specify the Port parameter value.

Save the result to the $restore variable to be able to use it with other cmdlets.

Related Commands

Page updated 2026-06-25

Page content applies to build 13.1.1.18