New-NAVDatabase
New-NAVDatabase
Creates a new Microsoft Dynamics NAV database from a backup file.
Syntax
Parameter Set: MultipleDestinations
New-NAVDatabase [-FilePath] <String> -DatabaseName <DatabaseName> [-DatabaseInstance <DatabaseInstance> ] [-DatabaseServer <DatabaseServer> ] [-DataFilesDestinationPath <String> ] [-Force] [-LogFilesDestinationPath <String> ] [-ServiceAccount <String> ] [-Timeout <Int32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: SingleDestination
New-NAVDatabase [-FilePath] <String> -DatabaseName <DatabaseName> [-DatabaseInstance <DatabaseInstance> ] [-DatabaseServer <DatabaseServer> ] [-DestinationPath <String> ] [-Force] [-ServiceAccount <String> ] [-Timeout <Int32> ] [-Confirm] [-WhatIf] [ <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, but they must be located on the same computer as SQL Server.
You can use this cmdlet to restore a database to a remote SQL Server instance.
Parameters
-DatabaseInstance<DatabaseInstance>
Specifies the name of the SQL Server instance that the database is restored to.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-DatabaseName<DatabaseName>
Specifies the name that you want 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>
Specifies 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>
Specifies the destination path for the data files for 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? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-DestinationPath<String>
Specifies the destination path for both data files and transaction log files for 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.
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? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-FilePath<String>
Specifies the path to the database backup file. The backup file must be located on the same computer as SQL Server.
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 |
-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 the destination path for transaction log 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 transaction log 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 transaction log file are changed. You can specify a file path only if the database that you restore contains a single transaction log file. If you specify a file path and the database contains multiple transaction log 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? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-ServiceAccount<String>
Specifies the 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 https://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 |
-Confirm
Prompts you for confirmation before running the cmdlet.
Required? |
false |
Position? |
named |
Default Value |
false |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Required? |
false |
Position? |
named |
Default Value |
false |
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.
MDF and LDF
This cmdlet generates a new database based on the specified backup file. The output includes the data files (.mdf) and the translation log files (.ldf).
Examples
-------------------------- EXAMPLE 1 --------------------------
Description
This example restores a database and preserves the original file names and locations.
PS C:\> 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 --------------------------
Description
This example restores a database, moves transaction log files and data files to the new location 'C:\newdestination', and preserves the original file names.
PS C:\> 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