Help Center
Choose product document...
Veeam Backup & Replication 9.5 Update 4
Veeam Explorers PowerShell Reference

Export-VESQLDatabase

Short Description

Exports Microsoft SQL databases.

Applies to

Product Edition: Community, Standard, Enterprise, Enterprise Plus

Syntax

Export-VESQLDatabase [-Database] <VESQLDatabase> -Path <string> [-ToPointInTime <datetime>] [-ServerName <string>] [-InstanceName <string>] [-Port <int>] [-UseSQLAuthentication] [-SqlCredentials <pscredential>] [-GuestCredentials <pscredential>] [-ToBackupFile] [-EnableCompression] [-Force] [<CommonParameters>]

Detailed Description

This cmdlet allows you to export Microsoft SQL databases with the following options:

  • Export Microsoft SQL databases to the specified folder.
  • Export to the backup file. In this case, the cmdlet will create a new .bak file. Use the ToBackupFile parameter to export to the file.

Parameters

Parameter

Description

Required

Position

Accept
Pipeline
Input

Accept
Wildcard
Characters

Database

Specifies a Microsoft SQL database that you want to export.

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

True

0

True (ByValue)

False

Path

Specifies the export destination. The cmdlet will export a Microsoft SQL database to the following destinations:

  • The folder - use this option to export the database to the specified folder.
  • The .bak file - use this option to export the database to the backup file. Use the ToBackupFile parameter to export to the backup file.

NOTE: To overwrite the

existing file, use the Force

parameter.

True

Named

False

False

ToPointInTime

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

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

False

Named

False

False

ServerName

Specifies a staging server.

NOTE: This parameter is required for export with the following options:

  • Export with the ToPointInTime option.
  • Export to the .bak file.

False

Named

False

False

InstanceName

For export to another location. Specifies a name of the Microsoft SQL staging instance. The cmdlet will export a Microsoft SQL database to that instance.

False

Named

False

False

Port

Specifies a port number. The cmdlet will use this port to connect to the staging server.

False

Named

False

False

SqlCredentials

Specifies credentials to authenticate against the Microsoft SQL server. If you do not specify Microsoft SQL credentials, the cmdlet will use the current account credentials.

False

Named

False

False

UseSQLAuthentication

Indicates that the cmdlet will use the SQL authentication to connect to the staging Microsoft SQL server.

False

Named

False

False

GuestCredentials

Specifies credentials to authenticate with the target server.

False

Named

False

False

ToBackupFile

Indicates that the cmdlet creates the backup of a Microsoft SQL database.

False

Named

False

False

EnableCompression

For the ToBackupFile parameter.

Indicates that the cmdlet will compress the Microsoft SQL database backup.

NOTE: This option is available only if your version of the Microsoft SQL server supports the compression option.

False

Named

False

False

Force

Indicates that the cmdlet will overwrite the following files:

  • The .bak file that you specify in the Path parameter.
  • Microsoft SQL database files in case they are located in the target folder.

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

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

False

Named

False

False

<CommonParameters>

This cmdlet supports Microsoft PowerShell common parameters. For more information on common parameters, see Microsoft Docs.

Example 1

This example shows how to export a Microsoft SQL database to the specified folder.

  1. Run the Get-VESQLRestoreSession cmdlet to get a restore session for a Microsoft SQL database. Save the result to the $session variable.
  2. Run the Get-VESQLDatabase cmdlet with the $session variable and the Name parameter to specify the Microsoft SQL database that you want to export.
  3. Run the Export-VESQLDatabase cmdlet with the $database variable. Use the Path parameter to specify the folder, to which you want to export the Microsoft SQL database.

$session = Get-VESQLRestoreSession

$database = Get-VESQLDatabase -Session $session[0] -Name "SQLDatabase"

Export-VESQLDatabase -Database $database -Path "C:\SQLExport"

Example 2

This example shows how to export a Microsoft SQL database to the .bak file. The cmdlet will export the database and will create a new .bak file.

  1. Run the Get-VESQLRestoreSession cmdlet to get a restore session for a Microsoft SQL database. Save the result to the $session variable.
  2. Run the Get-VESQLDatabase cmdlet with the $session variable and the Name parameter to specify the Microsoft SQL database that you want to export.
  3. Run the Export-VESQLDatabase cmdlet with the $database variable. Use the following parameters to specify restore options:
  • Use the Server parameter to specify the staging server
  • Use the ToBackupFile parameter to export the database to the .bak file
  • Use the Path parameter to specify the .bak filename

$session = Get-VESQLRestoreSession

$database = Get-VESQLDatabase -Session $session[0] -Name "SQLDatabase"

Export-VESQLDatabase -Database $database -Path "C:\export\Export.bak" -Server  "StagingServer" -ToBackupFile

Example 3

This example shows how to export a Microsoft SQL database to the specified point in time state.

  1. Run the Get-VESQLRestoreSession cmdlet to get a restore session for a Microsoft SQL database. Save the result to the $session variable.
  2. Run the Get-VESQLDatabase cmdlet with the $session variable and the Name parameter to specify the Microsoft SQL database that you want to export.
  3. Run the Get-VESQLDatabaseRestoreInterval cmdlet with the $database variable to get details about the available restore period of the Microsoft SQL database. Save the result to the $restoreinterval variable.
  4. Run the Export-VESQLDatabase with the $database variable. Use the following parameters to specify restore options:
  • Use the Server parameter to specify the staging server
  • Use the $restoreinterval variable with the ToUtc property for the ToPointInTime parameter to specify the latest restore point of the database.

$session = Get-VESQLRestoreSession

$database = Get-VESQLDatabase -Session $session[0] -Name "SQL database"

$restoreinterval = Get-VESQLDatabaseRestoreInterval -Database $database

Export-VESQLDatabase -Database $database -Path "C:\export\Export.bak" -Server "StagingServer" -ToPointInTime $restoreinterval.ToUtc

Related Commands

Veeam Large Logo

User Guide for VMware vSphere

User Guide for Microsoft Hyper-V

Enterprise Manager User Guide

Veeam Cloud Connect Guide

Veeam Agent Management Guide

Veeam Explorers User Guide

Backup and Restore of SQL Server Databases

Veeam Plug-ins for Enterprise Applications

PowerShell Reference

Veeam Explorers PowerShell Reference

RESTful API Reference

Required Permissions

Veeam Availability for Nutanix AHV

Veeam Backup for Microsoft Office 365 Documentation

Veeam ONE Documentation

Veeam Agent for Windows Documentation

Veeam Agent for Linux Documentation

Veeam Management Pack Documentation