Monday, February 19, 2024

Dynamics 365 F&O: Steps to import Database backup into Dev VM machine

This post describes the steps that are followed to restore UAT/Sandbox database (*.bacpac) into Azure Dev virtual machine.

 1. Download *.bacpac file from LCS.

LCS-> Select the project-> Shared Asset Library-> Database backup-> click the respective database file.

It will download the *. bacpac file

2. Save the db backup file in the dev machine's local folder for import.

3.Install SQL Package file in the dev machine.

Download and install SqlPackage - SQL Server | Microsoft Learn

4. Extract the SQL package zip

5. Open CMD prompt as an admin.

6. Navigate to SQL package folder

cd folder_path

7. Execute the following sql package import command.

SqlPackage.exe /a:import /sf:C:\Users\Admin1234\Documents\Backup\dbbackup.bacpac /tsn:localhost /tdn:AXDB_UAT /p:CommandTimeout=1200 /TargetEncryptConnection:False

8. Shrink the current DB's log file

ALTER DATABASE AxDB SET RECOVERY SIMPLE;
USE AxDB;
GO
CHECKPOINT;
GO
DBCC SHRINKFILE(AxDBCopy3_log, 1000); -- 1000 = 1GB
GO

9. After import rename restored DB's name as AxDB


USE master;  
GO  
ALTER DATABASE AxDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
ALTER DATABASE AxDB MODIFY NAME = AxDB_Orig;
GO  
ALTER DATABASE AxDB_Orig SET MULTI_USER;
GO
USE master;  
GO  
ALTER DATABASE AxDB0906 SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
ALTER DATABASE AxDB_UAT MODIFY NAME = AxDB;
GO  
ALTER DATABASE AxDB SET MULTI_USER;
GO

10. Synchronize the application with the DB using Visual Studio


Regards,
Arun S Keerthi











 

No comments:

Post a Comment