Skip to main content

Import DB backup from .BacPac file in D365 F&O using CMD

Hello Devs!

This is one of the most quickest way to import DB from .Bacpac file. Bacpac files are those which are generated from Tier 2 or higher environments as a DB backup.  


Alternate Approach ----> Using wizard

Prerequisites:
1) Access to LCS folder Asset library --> Database Backup











Incase you don't see the folder ask your project owner to give you the access.


Step 1: 
Download the file and save it in local non-user directory. 

Step 2:

- Services to be stopped

  • World Wide Web Publishing Service

  • Management Reporter 2012 Process Service

  • Microsoft Dynamics 365 Unified Operations: Batch Management Service

  • Microsoft Dynamics 365 Unified Operations: Data Import Export Framework Service

- Download SqlPackage.Exe. 
Download link : https://learn.microsoft.com/en-us/sql/tools/sqlpackage/sqlpackage-download?view=sql-server-ver15


Extract it and Open CMD as admin. 

Step 3 : 
Navigate to directory where you have extracted the SqlPackage.Exe folder using cmd and execute the command.

In my case the command look like this,

C:\SqlPackageExe>SqlPackage.exe /a:import /sf:C:\DB\AFP-D365-UATbackup.bacpac /tsn:LOCALHOST /tdn:AxDB /p:CommandTimeout=6000 /TargetEncryptConnection:False


Note:
You can replace C:\DB\AFP-D365-UATbackup.bacpac from your folder path where DB backup file is palced.

tsn (target server name) – The name of the Microsoft SQL Server instance to import into.
tdn (target database name) – The name of the database to import into. The database should not already exist.
sf (source file) – The path and name of the file to import from. 






Normally you can set as "CommandTimeout=120", but It depends on the you DB size and it could be changed as per requirement if there is any error of timeout while importing DB. 




Once the import is completed drop the AXDB and rename the imported database to AXDB and run the database synchronization.

Comments