New-NAVDatabase

New-NAVDatabase

Creates a new Microsoft Dynamics NAV database from a backup file.

Syntax

Parameter Set: __AllParameterSets
New-NAVDatabase [-FilePath] <String> -DatabaseName <String> [-DatabaseInstance <String> ] [-DatabaseServer <DatabaseServer> ] [-Force] [-ServiceAccount <String> ] [-Timeout <Int32> ] [ <CommonParameters>]

Parameter Set: MultipleDestinations
New-NAVDatabase [-FilePath] <String> -DatabaseName <String> -DataFilesDestinationPath <String> -LogFilesDestinationPath <String> [-DatabaseInstance <String> ] [-DatabaseServer <DatabaseServer> ] [-Force] [-ServiceAccount <String> ] [-Timeout <Int32> ] [ <CommonParameters>]

Parameter Set: SingleDestination
New-NAVDatabase [-FilePath] <String> -DatabaseName <String> -DestinationPath <String> [-DatabaseInstance <String> ] [-DatabaseServer <DatabaseServer> ] [-Force] [-ServiceAccount <String> ] [-Timeout <Int32> ] [ <CommonParameters>]

Detailed Description

Use the New-NAVDatabase cmdlet to restore a database from a backup file. You can specify the location of transaction log files and data files.

You can use this cmdlet to restore a database to a remote SQL Server instance.

Parameters

-DatabaseInstance<String>

The name of the SQL Server instance to which the database is restored.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-DatabaseName<String>

The name to use for the restored database.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-DatabaseServer<DatabaseServer>

The name of the computer that is running SQL Server.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-DataFilesDestinationPath<String>

Destination path for data files of the restored database. The path can be a UNC path or a path on the local computer.

You can specify either a directory path or a file path.

If you specify a directory path, then the location for data files is changed but the original file names are preserved.

If you specify a file path, then both the location and the file name of the data file is changed. You can specify a file path only if the database that you restore contains a single data file. If you specify a file path and the database contains multiple data files, then the restore operation fails.

If you do not specify the following parameters, then the database files are restored to their original locations: DestinationPath, DataFilesDestinationPath, LogFilesDestinationPath

If you specify the local computer for the DatabaseServer parameter, then if the directory that you specify does not exist, it is created automatically.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-DestinationPath<String>

Destination path for both data files and transaction log files of the restored database. The path can be a UNC path or a path on the local computer.

You must specify a directory path. If you specify a file path, then the restore operation fails. The path can be a UNC path or a path on the local computer.

If you do not specify the following parameters, then the database files are restored to their original locations: DestinationPath, DataFilesDestinationPath, LogFilesDestinationPath.

If you specify the local computer for the DatabaseServer parameter, then if the directory that you specify does not exist, it is created automatically.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-FilePath<String>

Path to the database backup file.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-Force

Specifies that you want to overwrite the existing database during the restore operation.

If you use this parameter, then the existing database is overwritten, regardless of whether the backup file contains a backup of the existing database or a different database.

If the database that you specify in the DatabaseName parameter exists but the backup file in the location that you specify in the FilePath parameter does not contain a backup of the existing database that you specified, then you must use the Force parameter to overwrite the database with the backup.

If the database that you specify in the DatabaseName parameter exists and the backup file contains a backup of the existing database that you specified, then you do not need to use the Force parameter to restore the database.

If you specify data files or transaction log files for a different database from the database that you specify in the DatabaseName parameter, then the restore operation fails. In this case, the Force parameter does not force the database to be overwritten.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-LogFilesDestinationPath<String>

Specifies that you want to overwrite the existing database during the restore operation.

If you use this parameter, then the existing database is overwritten, regardless of whether the backup file contains a backup of the existing database or a different database.

If the database that you specify in the DatabaseName parameter exists but the backup file in the location that you specify in the FilePath parameter does not contain a backup of the existing database that you specified, then you must use the Force parameter to overwrite the database with the backup.

If the database that you specify in the DatabaseName parameter exists and the backup file contains a backup of the existing database that you specified, then you do not need to use the Force parameter to restore the database.

If you specify data files or transaction log files for a different database from the database that you specify in the DatabaseName parameter, then the restore operation fails. In this case, the Force parameter does not force the database to be overwritten.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-ServiceAccount<String>

Logon account that runs the Microsoft Dynamics NAV Server instance. This account is given the appropriate permissions to the database when you run the cmdlet. For more information, see Provisioning the Microsoft Dynamics NAV Server Account in the MSDN Library at http://go.microsoft.com/fwlink/?LinkID=281888.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-Timeout<Int32>

The time (in seconds) to wait before terminating an attempt to execute a command on SQL Server, such as reading content or restoring the database from a .bak file.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • None or System.String

    You can pipe a string that contains one of the following to the cmdlet: LogFilesDestinationPath, FilePath, DestinationPath, DataFilesDestinationPath, DatabaseInstance, or DatabaseName.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • None

    This cmdlet does not generate any output.

Examples

-------------------------- EXAMPLE 1 --------------------------

This example restores a database and preserves the original file names and locations.

C:\PS>New-NavDatabase C:\Backups\backup1.bak –DatabaseName NewDatabase –Verbose | fl
VERBOSE: NavCommand.BeginProcessing

VERBOSE: NavCommand.ProcessRecord

VERBOSE: Restoring database 'NewDatabase' from backup file: 'C:\Backups\backup1.bak'... 

VERBOSE: Restore of database 'NewDatabase' from file 'C:\Backups\backup1.bak' has been completed successfully. 


DatabaseName     : NewDatabase

DatabaseInstance : MSSQLSERVER

DatabaseServer   : server1.cronus.com


VERBOSE: NavCommand.EndProcessing

-------------------------- EXAMPLE 2 --------------------------

This example restores a database, moves transaction log files and data files to the new location 'C:\newdestination', and preserves the original file names.

C:\PS>New-NAVDatabase C:\Backups\backup.bak -DestinationPath c:\newdestination -DatabaseName NewDatabase -Verbose
VERBOSE: NavCommand.BeginProcessing

VERBOSE: NavCommand.ProcessRecord

VERBOSE: Restoring database 'NewDatabase' from backup file: 'C:\Backups\backup.bak'... 

VERBOSE: Restore of database 'NewDatabase' from file 'C:\Backups\backup.bak' has been completed successfully. 



DatabaseName                            DatabaseInstance                        DatabaseServer

------------                            ----------------                        --------------

NewDatabase                             MSSQLSERVER                             server1.cronus.com

VERBOSE: NavCommand.EndProcessing