web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :

Restore a Production Database on a Cloud-hosted Environment

Said Nikjou Profile Picture Said Nikjou 251

Some customers have been reporting errors (File contains corrupted data) when they are trying to import the bacpac files on developer boxes.

pastedimage1643655303465v1.png

The recommendation is to use the SQLPakage tools to import the bacpac using CMD command.

Here you have the step by stet procedure:

1. Restore a bacpac file with SqlPackage.exe

  • Download the bacpac file from the LCS Asset library and copy to C:\Temp\BkData.
  • Rename downloaded backpac file to Backup.bacpac.
  • Right-click and unblock Backup.bacpac

pastedimage1643655365673v2.png

  • Download the latest version of SqlPackage.exe to your downloads folder.

https://docs.microsoft.com/en-us/sql/tools/sqlpackage-download?view=sql-server-ver15#get-sqlpackage-net-core-for-windows

  • Extract the SqlPackage to C:\Temp\SqlPackage

pastedimage1643655392980v3.png

  • Open elevated command session and change directory to point to your SqlPackage directory.CD C:\Temp\SqlPackage
  • Run the following command to restore the production database.

 

SqlPackage.exe /a:import /d:True /mp:4 /p:Storage=memory/sf:C:\Temp\BkData\Backup.bacpac /tsn:localhost /tdn:backup /p:CommandTimeout=120000

pastedimage1643655423830v4.png

Note: Depending on the database size this step could takes several hours.

2. Stop the services

Stop the following services after the data restore is complete.

  • a) Management Reporter 2012 Process Service
  • b) Microsoft Dynamics 365 for Operations Batch Management Service
  • c) Microsoft Dynamics 365 for Operations Data import Export Framework Service
  • d) World Wide Web Publishing Service

 3. Open SQL Server Management Studio (SSMS)

Open SQL Server Management Studio (SSMS) and connect to the database engine.

  • a)Rename AxDB to AxDB_old
  • b) Rename backup to AxDB

pastedimage1643655626524v5.png

4. Restart the services

  • a) Management reporter 2012 process service
  • b) Microsoft Dynamics 365 for Operations – Batch Management service
  • c) Microsoft Dynamics 365 for Operations – Data import/Export Framework service
  • d) World Wide Web Publishing Service

5. Provisioning tool

Launch the Admin User Provisioning tool from the desktop

K:\AOSService\PackagesLocalDirectory\Bin\AdminUserProvisioning.exe

pastedimage1643655691848v6.png

pastedimage1643655698556v7.png

pastedimage1643655704838v8.png

Thanks for reading, 

Said

Acknowledgments: I want to thank my colleague Amy Flowers (Customer Engineer) for her contributions and peer review.

Comments

*This post is locked for comments

  • Community member Profile Picture Community member
    Posted at
    Restore a Production Database on a Cloud-hosted Environment
    So nearly right.

    Use below something probably changed since above was posted.
     
    SqlPackage.exe /a:import /d:True /mp:4 /p:Storage=memory /sf:C:\Temp\BkData\Backup.bacpac /tsn:localhost /tdn:backup /p:CommandTimeout=120000 /ttsc:true
  • Maciej Obojski Profile Picture Maciej Obojski 610
    Posted at
    Hi Said, good article! 2 observations from my side: 1. Admin provisioning tool is not provided any more on newer DEV boxes - you probably should update the article to reflect it 2. You seem to have added 3 more parameters to official Docs command (MaxParallelism, Diagnostics, Storage=Memory parameter). Could you elaborate a bit more as to what these do and how exactly they help with the import process? Thanks, Maciej