Export-VESQLDatabase

In this article

    Short Description

    Exports backed-up Microsoft SQL databases.

    Applies to Veeam Backup & Replication

    Product Edition: Community, Standard, Enterprise, Enterprise Plus, Veeam Universal License

    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 backup file.

    Parameters

    Parameter

    Description

    Type

    Required

    Position

    Accept Pipeline Input

    Accept Wildcard Characters

    Database

    Specifies a Microsoft SQL database. The cmdlet will export this database.

    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. Specify the ToBackupFile parameter to export to the backup file.

    Note: To overwrite the existing file, use the Force parameter.

    String

    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.

    Datetime

    False

    Named

    False

    False

    ServerName

    Specifies a staging server.

    Note: This parameter is required if you want to export a Microsoft SQL database with the following options:

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

    String

    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.

    String

    False

    Named

    False

    False

    Port

    Specifies a port number that will be used to connect to the staging server.

    Int32

    False

    Named

    False

    False

    SqlCredentials

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

    PSCredential

    False

    Named

    False

    False

    UseSQLAuthentication

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

    SwitchParameter

    False

    Named

    False

    False

    GuestCredentials

    Specifies credentials to authenticate to the target server.

    PSCredential

    False

    Named

    False

    False

    ToBackupFile

    Defines that the cmdlet will create the backup of a Microsoft SQL database.

    SwitchParameter

    False

    Named

    False

    False

    EnableCompression

    For the ToBackupFile parameter.

    Defines 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.

    SwitchParameter

    False

    Named

    False

    False

    Force

    Defines 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.

    SwitchParameter

    False

    Named

    False

    False

    <CommonParameters>

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

    Examples

    Export-VESQLDatabaseExample 1. Exporting to Specific Folder

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

    $session = Get-VESQLRestoreSession

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

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

    Perform the following steps:

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

    The Get-VESQLRestoreSession cmdlet will return an array of restore sessions. Mind the ordinal number of the necessary restore session (in our example, it is the first restore session in the array).

    1. Run the Get-VESQLDatabase cmdlet. Set the $session variable as the Session parameter value. Specify the Name parameter value.
    2. Run the Export-VESQLDatabase cmdlet. Set the $database variable as the Database parameter value. Specify the Path parameter value.

    Export-VESQLDatabaseExample 2. Exporting to Bak. File

    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.

    $session = Get-VESQLRestoreSession

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

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

    Perform the following steps:

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

    The Get-VESQLRestoreSession cmdlet will return an array of restore sessions. Mind the ordinal number of the necessary restore session (in our example, it is the first restore session in the array).

    1. Run the Get-VESQLDatabase cmdlet. Set the $session variable as the Session parameter value. Specify the Name parameter value.
    2. Run the Export-VESQLDatabase cmdlet. Specify the following settings:
    • Set the $database variable as the Database parameter value.
    • Specify the Path parameter value.
    • Specify the Server parameter value.
    • Define the ToBackupFile parameter.

    Export-VESQLDatabaseExample 3. Exporting to Specific Point in Time State

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

    $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

    Perform the following steps:

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

    The Get-VESQLRestoreSession cmdlet will return an array of restore sessions. Mind the ordinal number of the necessary restore session (in our example, it is the first restore session in the array).

    1. Run the Get-VESQLDatabase cmdlet. Set the $session variable as the Session parameter value. Specify the Name parameter value.
    2. Run the Get-VESQLDatabaseRestoreInterval cmdlet. Set the $database as the Database parameter value. Save the result to the $restoreinterval variable.
    3. Run the Export-VESQLDatabase cmdlet. Specify the following settings:
    • Set the $database as the Database parameter value.
    • Specify the Path parameter value.
    • Specify the Server parameter value.
    • Set the $restoreinterval variable with the ToUtc property for the ToPointInTime parameter to specify the latest restore point of the database.

    Related Commands

    I want to report a typo

    There is a misspelling right here:

     

    I want to let the Veeam Documentation Team know about that.