Start-VEMDBDataRestore

Short Description

Restores MongoDB collections or the entire MongoDB instance.

Applies to

Veeam Backup & Replication

Product Edition: Enterprise Plus, Veeam Universal License

Syntax

This cmdlet provides parameter sets that allow you to:

  • Restore collections to a target MongoDB deployment.

Start-VEMDBDataRestore [-InstancePort <Int32>] [[-InstanceCredentials] <PSCredential>] [-Server <String>] [-SshPort <Int32>] -Credential <VEMDBLinuxCredentials> [-UseTLS] [-UseSystemCertificateAuthority] [-CertificateAuthorityPemFilePath <String>] [-UseX509Authentication] [-ClientCertificateAndKeyPemFilePath <String>] [-ClientKeyPassword <SecureString>] [-Collections] <VEMDBCollectionRestoreOptions[]> [-RestoreAdminDatabase] [-Force] [<CommonParameters>]

  • Restore an entire MongoDB instance to a target Linux machine with MongoDB.

Start-VEMDBDataRestore [-InstancePort <Int32>] [-Server <String>] [-SshPort <Int32>] -Credential <VEMDBLinuxCredentials> [-UseSystemCertificateAuthority] [-CertificateAuthorityPemFilePath <String>] [-Session] <VEMDBRestoreSession> [[-DataFolderPath] <String>] [-ToPointInTimeUTC <DateTime>] [-Force] [<CommonParameters>]

Detailed Description

This cmdlet restores backed-up and published MongoDB collections or the entire backed-up MongoDB instance. After you start a restore job, you can stop the restore process with the Stop-VEMDBDataRestore cmdlet.

Parameters

Parameter

Description

Type

Required

Position

Accept Pipeline Input

Collections

For collections restore.

Specifies the collections and their restore options.

Accepts the VEMDBCollectionRestoreOptions[] object. To get this object, run the New-VEMDBCollectionRestoreOptions cmdlet.

True

0

False

Session

For instance restore.

Specifies a restore session initiated to perform operations with MongoDB.

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

True

0

False

InstanceCredentials

For collections restore.

Specifies the credentials for the target MongoDB instance.

Consider the following:

  • The user must have the root MongoDB role on the target replica set.
  • This parameter is not necessary if you use the UseX509Authentication parameter.

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

True

1

False

DataFolderPath

For instance restore.

Specifies the path to which the cmdlet will restore the MongoDB instance.

Note: If you do not specify this parameter, the instance will be restored to the original location.

String

False

1

False

Credential

Specifies credentials for authenticating to the primary node of the MongoDB deployment or the target MongoDB server.

Note: The user must have root privileges on the target server.

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

True

Named

False

Force

Defines that the cmdlet will overwrite existing MongoDB data with data from the backup.

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

SwitchParameter

False

Named

False

InstancePort

Specifies the port of the target MongoDB instance.

Default: 27017

Int32

False

Named

False

RestoreAdminDatabase

For collections restore.

Defines that the cmdlet will restore the admin database.

SwitchParameter

False

Named

False

Server

Specifies DNS name or IP address of the primary node of the target MongoDB deployment or the target MongoDB server.

String

False

Named

False

SshPort

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

Default: 22

Int32

False

Named

False

UseTLS

For collections restore.

Defines that the cmdlet will connect to the target MongoDB deployment using a secure TLS protocol.

Note: This parameter is obligatory if you use the UseX509Authentication parameter and optional if you use the InstanceCredentials parameter.

SwitchParameter

False

Named

False

CertificateAuthorityPemFilePath

For collections restore.

Specifies the path to the custom Certificate Authority (CA) PEM file used to verify the certificate issued to the MongoDB deployment. You can use this parameter with the UseTLS and UseX509Authentication parameters.

Note: If you use this parameter, do not specify the UseSystemCertificateAuthority parameter.

String

False

Named

False

ClientCertificateAndKeyPemFilePath

For collections restore.

Specifies the path to the PEM file containing the client certificate and the related private key. You can use this parameter with the UseTLS and UseX509Authentication parameters.

String

False

Named

False

ClientKeyPassword

For collections restore.

Defines the password used to decrypt the private key specified in the ClientCertificateAndKeyPemFilePath parameter.

SecureString

False

Named

False

ToPointInTimeUTC

For instance restore.

Specifies a point in time in the UTC format within the restore interval of the MongoDB 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

Named

False

UseSystemCertificateAuthority

Defines that the cmdlet will use the Certificate Authority (CA) store of the mount server associated with the backup repository to verify the certificate issued to the MongoDB deployment. You can use this parameter with the UseTLS and UseX509Authentication parameters.

Note: If you use this parameter, do not specify the CertificateAuthorityPemFilePath parameter.

SwitchParameter

False

Named

False

UseX509Authentication

For collections restore.

Defines that the cmdlet will use X.509 authentication to connect to the target MongoDB deployment.

Note: If you use this parameter, do not specify the InstanceCredentials and UseTLS parameters.

SwitchParameter

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

The cmdlet returns the VEMDBRestore object, that contains information about the status of the MongoDB restore job.

Notes

Start-VEMDBDataRestore replaces the deprecated cmdlet Start-VEMDBRestoreJob. The old cmdlet still works (as an alias of the new cmdlet, with identical functionality), but it may be removed in a future version.

Examples

Example 1. [For Collections Restore] Restoring Specific Collection with Default Settings

This example shows how to restore a MongoDB collection to the original location. The collection will retain the original name. This example will also restore the admin database to the original location.

$session = Get-VEMDBRestoreSession

$database = Get-VEMDBDatabase -Session $session[0] -Name "employees"

$collection = Get-VEMDBCollection -Database $database

$restoreoptions = New-VEMDBCollectionRestoreOptions -Collection $collection[0] -NewCollectionName "home office"

$instancecreds = Get-Credential

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

$servercreds = New-VEMDBLinuxCredentials -Account "root" -Password $securepassword

$restore = Start-VEMDBDataRestore -Collections $restoreoptions -InstanceCredentials $instancecreds -Server mongodb02 -Credential $servercreds -RestoreAdminDatabase

Perform the following steps:

  1. Run the Get-VEMDBRestoreSession 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 our example, it is the first restore session in the array.

  1. Run the Get-VEMDBDatabase cmdlet. Set the $session variable as the Session parameter value and select the necessary session. Specify the Name parameter value. Save the result to the $database variable.
  2. Run the Get-VEMDBCollection cmdlet. Set the $database variable as the Database parameter value. Save the result to the $collection variable.
  3. Run the New-VEMDBCollectionRestoreOptions cmdlet. Set the $collection variable as the Collection parameter value and specify the necessary collection. Specify the NewCollectionName parameter value. Save the result to the $restoreoptions variable.
  4. Run the Get-Credential cmdlet to specify the credentials to authenticate to the MongoDB replica set. Save the result to the $instancecreds variable.
  5. Run the Read-Host cmdlet. Specify the Prompt parameter value. Provide the AsSecureString parameter. Save the result to the $securepassword variable.
  6. Run the New-VEMDBLinuxCredentials cmdlet. Specify the Account parameter value. Set the $securepassword variable as the Password parameter value. Save the result to the $servercreds variable.
  7. Run the Start-VEMDBDataRestore cmdlet. Specify the following settings:
  • Set the $restoreoptions variable as the Collections parameter value.
  • Set the $instancecreds variable as the InstanceCredentials parameter value.
  • Specify the Server parameter value.
  • Set the $servercreds variable as the Credential parameter value.
  • Provide the RestoreAdminDatabase parameter.

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

Example 2. [For Collections Restore] Restoring All Collections in Replica Set with Default Settings

This example shows how to restore all MongoDB collections in the replica set to the original location. Each collection will be restored with the original name, to the same database as on the backup. If any of the collections exist on the target server, the cmdlet will overwrite them without issuing a prompt.

$session = Get-VEMDBRestoreSession

$collections = Get-VEMDBCollection -Session $session[0]

$restoreoptionsarray = @()

foreach ($collection in $collections) {

   $restoreoption = New-VEMDBCollectionRestoreOptions -Collection $collection

   $restoreoptionsarray += $restoreoption

}

$instancecreds = Get-Credential

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

$servercreds = New-VEMDBLinuxCredentials -Account "root" -Password $securepassword

$restore = Start-VEMDBDataRestore -Collections $restoreoptionsarray -InstanceCredentials $instancecreds -Server mongodb02 -Credential $servercreds -Force

Perform the following steps:

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

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

  1. Run the Get-VEMDBCollection cmdlet. Set the $session variable as the Session parameter value and select the necessary restore session. Save the result to the $collections variable.
  2. Declare the $restoreptionsarray variable. Assign an empty array to this variable.
  3. Run the New-VEMDBCollectionRestoreOptions cmdlet and set the $collection variable as the Collection parameter value. Use the ForEach statement to apply the same restore options to each collection in the $collections variable.
  4. Run the Get-Credential cmdlet to specify the credentials to authenticate to the MongoDB replica set. Save the result to the $instancecreds variable.
  5. Run the Read-Host cmdlet. Specify the Prompt parameter value. Provide the AsSecureString parameter. Save the result to the $securepassword variable.
  6. Run the New-VEMDBLinuxCredentials cmdlet. Specify the Account parameter value. Set the $securepassword variable as the Password parameter value. Save the result to the $servercreds variable.
  7. Run the Start-VEMDBDataRestore cmdlet. Specify the following settings:
  • Set the $restoreoptionsarray variable as the Collections parameter value.
  • Set the $instancecreds variable as the InstanceCredentials parameter value.
  • Specify the Server parameter value.
  • Set the $servercreds variable as the Credential parameter value.
  • Provide the Force parameter.

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

Example 3. [For Collections Restore] Restoring Collections with TLS Protocol

This example shows how to restore specific MongoDB collections to another location. The collections will be restored with different names, to a new database. This example uses a custom SSH port to connect to the target server and it will use the TLS protocol to connect to the target MongoDB deployment.

$session = Get-VEMDBRestoreSession

$database = Get-VEMDBDatabase -Session $session[0] -Name "locations"

$collections = Get-VEMDBCollection -Database $database

$restoreoption1 = New-VEMDBCollectionRestoreOptions -Collection $collections[0] -NewCollectionName "kyoto" -NewDatabaseName "users"

$restoreoption2 = New-VEMDBCollectionRestoreOptions -Collection $collections[1] -NewCollectionName "sydney" -NewDatabaseName "users"

$restoreoptionsarray = @($restoreoption1, $restoreoption2)

$instancecreds = Get-Credential

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

$servercreds = New-VEMDBLinuxCredentials -Account "root" -Password $securepassword

$restore = Start-VEMDBDataRestore -Collections $restoreoptionsarray -InstanceCredentials $instancecreds -Server "srv18" -Credential $servercreds -InstancePort 27017 -SshPort 23 -UseTLS -UseSystemCertificateAuthority

Perform the following steps:

  1. Run the Get-VEMDBRestoreSession 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 our example, it is the first restore session in the array.

  1. Run the Get-VEMDBDatabase cmdlet. Set the $session variable as the Session parameter value and select the necessary session. Specify the Name parameter value.
  2. Run the Get-VEMDBCollection cmdlet. Set the $database variable as the Database parameter value.
  3. Run the New-VEMDBCollectionRestoreOptions cmdlet. Set the $collection variable as the Collection parameter value and specify the necessary collection. Specify the NewCollectionName parameter value. Save the result to the $restoreoptions1 variable to use it with other cmdlets.
  4. Run the New-VEMDBCollectionRestoreOptions cmdlet. Set the $collection variable as the Collection parameter value and specify the necessary collection. Specify the NewCollectionName parameter value. Save the result to the $restoreoptions2 variable to use it with other cmdlets.
  5. Declare the $restoreptionsarray variable. Assign the $restoreoptions1 and $restoreoptions2 variables to this variable.
  6. Run the Get-Credential cmdlet to specify the credentials to authenticate to the MongoDB replica set. Save the result to the $instancecreds variable.
  7. Run the Read-Host cmdlet. Specify the Prompt parameter value. Provide the AsSecureString parameter. Save the result to the $securepassword variable.
  8. Run the New-VEMDBLinuxCredentials cmdlet. Specify the Account parameter value. Set the $securepassword variable as the Password parameter value. Save the result to the $servercreds variable.
  9. Run the Start-VEMDBDataRestore cmdlet. Specify the following settings:
  • Set the $restoreoptionsarray variable as the Collections parameter value.
  • Set the $instancecreds variable as the InstanceCredentials parameter value.
  • Specify the Server parameter value.
  • Set the $servercreds variable as the Credential parameter value.
  • Specify the InstancePort parameter value.
  • Specify the SshPort parameter value.
  • Provide the UseTLS parameter.
  • Provide the UseSystemCertificateAuthority parameter.

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

Example 4. [For Collections Restore] Restoring Collections with X.509 Authentication

This example shows how to restore specific MongoDB collections to another location. The collections will be restored with different names, to a new database. This example uses X509 authentication to connect to the target MongoDB deployment.

$session = Get-VEMDBRestoreSession

$database = Get-VEMDBDatabase -Session $session[0] -Name "locations"

$collections = Get-VEMDBCollection -Database $database

$restoreoption1 = New-VEMDBCollectionRestoreOptions -Collection $collections[0] -NewCollectionName "seoul" -NewDatabaseName "users"

$restoreoption2 = New-VEMDBCollectionRestoreOptions -Collection $collections[1] -NewCollectionName "doha" -NewDatabaseName "users"

$restoreoptionsarray = @($restoreoption1, $restoreoption2)

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

$servercreds = New-VEMDBLinuxCredentials -Account "root" -Password $securepassword

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

$restore = Start-VEMDBDataRestore -Collections $restoreoptionsarray -Server "srv15" -Credential $servercreds -InstancePort 27018 -UseTLS -UseX509Authentication -CertificateAuthorityPemFilePath "C:\Users\Administrator\Documents\MongoDB\certs\CA.pem" -ClientCertificateAndKeyPemFilePath "C:\Users\Administrator\Documents\MongoDB\certs\client.pem" -ClientKeyPassword $keypassword

Perform the following steps:

  1. Run the Get-VEMDBRestoreSession 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 our example, it is the first restore session in the array.

  1. Run the Get-VEMDBDatabase cmdlet. Set the $session variable as the Session parameter value and select the necessary session. Specify the Name parameter value.
  2. Run the Get-VEMDBCollection cmdlet. Set the $database variable as the Database parameter value.
  3. Run the New-VEMDBCollectionRestoreOptions cmdlet. Set the $collection variable as the Collection parameter value and specify the necessary collection. Specify the NewCollectionName parameter value. Save the result to the $restoreoptions1 variable to use it with other cmdlets.
  4. Run the New-VEMDBCollectionRestoreOptions cmdlet. Set the $collection variable as the Collection parameter value and specify the necessary collection. Specify the NewCollectionName parameter value. Save the result to the $restoreoptions2 variable to use it with other cmdlets.
  5. Declare the $restoreptionsarray variable. Assign the $restoreoptions1 and $restoreoptions2 variables to this variable.
  6. Run the Read-Host cmdlet. Specify the Prompt parameter value. Provide the AsSecureString parameter. Save the result to the $securepassword variable.
  7. Run the New-VEMDBLinuxCredentials cmdlet. Specify the Account parameter value. Set the $securepassword variable as the Password parameter value. Save the result to the $servercreds variable.
  8. Run the Read-Host cmdlet. Specify the Prompt parameter value. Provide the AsSecureString parameter. Save the result to the $keypassword variable.
  9. Run the Start-VEMDBDataRestore cmdlet. Specify the following settings:
  • Set the $restoreoptionsarray variable as the Collections parameter value.
  • Specify the Server parameter value.
  • Set the $servercreds variable as the Credential parameter value.
  • Specify the InstancePort parameter value.
  • Provide the UseTLS parameter.
  • Provide the UseX509Authentication parameter.
  • Specify the CertificateAuthorityPemFilePath parameter value.
  • Specify the ClientCertificateAndKeyPemFilePath parameter value.
  • Set the $keypassword variable as the ClientKeyPassword parameter value.

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

Example 5. [For Collections Restore] Restoring Collections to Point-in-Time State

This example shows how to restore specific MongoDB collections to a point-in-time state. To do this, the instance to which the collections belong must be published to a point-in-time state on the target server. For more information, see Publishing MongoDB Instance to Restore Collections to Point-in-Time State. The collections will be restored with different names, to a new database.

$publishedcollections = Get-VEMDBPublishedCollection -Instance "mongodb02:27018"

$restoreoption = New-VEMDBCollectionRestoreOptions -PublishedCollection $publishedcollections[0] -NewCollectionName "yokohama" -NewDatabaseName "users"

$restoreoption2 = New-VEMDBCollectionRestoreOptions -PublishedCollection $publishedcollections[1] -NewCollectionName "busan" -NewDatabaseName "users"

$restoreoptionsarray = @($restoreoption1, $restoreoption2)

$instancecreds = Get-Credential

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

$servercreds = New-VEMDBLinuxCredentials -Account "root" -Password $securepassword

$restore = Start-VEMDBDataRestore -Collections $restoreoptionsarray -Server "srv15" -InstanceCredentials $instancecreds -Credential $servercreds -InstancePort 27017

Perform the following steps:

  1. Run the Get-VEMDBPublishedCollection cmdlet. Save the result to the $publishedcollections variable.

The cmdlet will return an array of published collections. Note the ordinal number of the necessary published collections. In our example, it is the first two published collections in the array.

  1. Run the New-VEMDBCollectionRestoreOptions cmdlet. Set the $publishedcollections variable as the PublishedCollection parameter value and specify the necessary collection. Specify the NewCollectionName parameter value. Save the result to the $restoreoptions1 variable to use it with other cmdlets.
  2. Run the New-VEMDBCollectionRestoreOptions cmdlet. Set the $publishedcollections variable as the PublishedCollection parameter value and specify the necessary collection. Specify the NewCollectionName parameter value. Save the result to the $restoreoptions2 variable to use it with other cmdlets.
  3. Declare the $restoreptionsarray variable. Assign the $restoreoptions1 and $restoreoptions2 variables to this variable.
  4. Run the Get-Credential cmdlet. Save the result to the $instancecreds variable.
  5. Run the Read-Host cmdlet. Specify the Prompt parameter value. Provide the AsSecureString parameter. Save the result to the $securepassword variable.
  6. Run the New-VEMDBLinuxCredentials cmdlet. Specify the Account parameter value. Set the $securepassword variable as the Password parameter value. Save the result to the $servercreds variable.
  7. Run the Start-VEMDBDataRestore cmdlet. Specify the following settings:
  • Set the $restoreoptionsarray variable as the Collections parameter value.
  • Specify the Server parameter value.
  • Set the $instancecreds variable as the InstanceCredentials parameter value.
  • Set the $servercreds variable as the Credential parameter value.
  • Specify the InstancePort parameter value.

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

Example 6. [For Instance Restore] Restoring Entire MongoDB Instance

This example shows how to restore the entire instance to a target Linux machine with MongoDB. If the specified path on the target server is not empty, the cmdlet will overwrite its contents without issuing a prompt.

$session = (Get-VEMDBRestoreSession)[0]

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

$servercreds = New-VEMDBLinuxCredentials -Account "root" -Password $securepassword

$restore = Start-VEMDBDataRestore -Session $session -DataFolderPath "/var/lib/mongodb" -InstancePort 27018 -Server "mongodb01" -SshPort 23 -Credential $servercreds -Force

Perform the following steps:

  1. Run the Get-VEMDBRestoreSession cmdlet. Select the necessary restore session returned by this command and save it to the $session variable. In our example, it is the first session in the array.
  1. Run the Read-Host cmdlet. Specify the Prompt parameter value. Provide the AsSecureString parameter. Save the result to the $securepassword variable.
  2. Run the New-VEMDBLinuxCredentials cmdlet. Specify the Account parameter value. Set the $securepassword variable as the Password parameter value. Save the result to the $servercreds variable.
  3. Run the Start-VEMDBDataRestore cmdlet. Specify the following settings:
  • Set the $session variable as the Session parameter value.
  • Specify the DataFolderPath parameter value.
  • Specify the InstancePort parameter value.
  • Specify the Server parameter value.
  • Specify the SshPort parameter value.
  • Set the $servercreds variable as the Credential parameter value.
  • Provide the Force parameter.

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

Example 7. [For Instance Restore] Restoring Entire MongoDB Instance to Point-in-Time State

This example shows how to restore the entire instance to a target Linux machine with MongoDB, as of a specific point-in-time state on the backup file. If the specified path on the target server is not empty, the cmdlet will overwrite its contents without issuing a prompt.

$session = (Get-VEMDBRestoreSession)[0]

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

$timeutc = $time.ToUniversalTime()

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

$servercreds = New-VEMDBLinuxCredentials -Account "root" -Password $securepassword

$restore = Start-VEMDBDataRestore -Session $session -DataFolderPath "/var/lib/mongodb" -InstancePort 27018 -Server "mongodb01" -Credential $servercreds -ToPointInTimeUTC $timeutc -Force

Perform the following steps:

  1. Run the Get-VEMDBRestoreSession cmdlet. Select the necessary restore session returned by this command and save it to the $session variable. In our example, it is the first 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-VEMDBLinuxCredentials cmdlet. Specify the Account parameter value. Set the $securepassword variable as the Password parameter value. Save the result to the $servercreds variable.
  5. Run the Start-VEMDBDataRestore cmdlet. Specify the following settings:
  • Set the $session variable as the Session parameter value.
  • Specify the DataFolderPath parameter value.
  • Specify the InstancePort parameter value.
  • Specify the Server parameter value.
  • Set the $servercreds variable as the Credential parameter value.
  • Set the $timeutc variable as the ToPointInTimeUTC parameter value.
  • Provide the Force parameter.

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

Related Commands

Page updated 8/10/2025

Page content applies to build 13.0.0.4967