Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Unanswered

Database Restore .bacpac file to Development VM

Posted on by 419
 RDP Block issue resolve 
 

Restore .bacpac file to DEV VM D365 FO

 

Restore .bacpac file to Development VM

Steps:
 
1.       Take Backup of AxDB database from Development VM
 
2.       Open Command Prompt (Run as Administrator)



Go To Path (Version Folder might be differ, SQL)

cd /C://Program Files (x86)//Microsoft SQL Server//140//DAC//bin/



C://Program Files (x86)//Microsoft SQL Server//140//DAC//bin>
 
3.       Command to Execute



SqlPackage.exe /a:import /sf:C://TEMP//VWD365FUT3backup.bacpac /tsn:localhost /tdn:AxDB_ENV_DDMMYYYY /p:CommandTimeout=1200

//
SqlPackage.exe /a:import /sf:C://Users//Admin7f04592810//Downloads//uatbackup.bacpac /tsn:localhost /tdn:AxDB_fromProd /p:CommandTimeout=50000 /ttsc:True
//
Note: Process will take some more time
 
4.       Open SQL, Run this below script
 
CREATE USER axdeployuser FROM LOGIN axdeployuser
EXEC sp_addrolemember
'db_owner', 'axdeployuser'

CREATE USER axdbadmin FROM LOGIN axdbadmin
EXEC sp_addrolemember
'db_owner', 'axdbadmin'

CREATE USER axmrruntimeuser FROM LOGIN axmrruntimeuser
EXEC sp_addrolemember
'db_datareader', 'axmrruntimeuser'
EXEC sp_addrolemember 'db_datawriter', 'axmrruntimeuser'

CREATE USER axretaildatasyncuser FROM LOGIN axretaildatasyncuser
EXEC sp_addrolemember
'DataSyncUsersRole', 'axretaildatasyncuser'

CREATE USER axretailruntimeuser FROM LOGIN axretailruntimeuser
EXEC sp_addrolemember
'UsersRole', 'axretailruntimeuser'
EXEC sp_addrolemember 'ReportUsersRole', 'axretailruntimeuser'

CREATE USER axdeployextuser FROM LOGIN axdeployextuser
EXEC sp_addrolemember
'DeployExtensibilityRole', 'axdeployextuser'

CREATE USER [NT AUTHORITY//NETWORK SERVICE] FROM LOGIN [NT AUTHORITY//NETWORK SERVICE]
EXEC sp_addrolemember
'db_owner', 'NT AUTHORITY//NETWORK SERVICE'

UPDATE T1
SET T1.storageproviderid = 0
, T1.accessinformation = ''
, T1.modifiedby = 'Admin'
, T1.modifieddatetime = getdate()
FROM docuvalue T1
WHERE T1.storageproviderid = 1 --Azure storage

DROP PROCEDURE IF EXISTS SP_ConfigureTablesForChangeTracking
DROP PROCEDURE IF EXISTS SP_ConfigureTablesForChangeTracking_V2
GO
-- Begin Refresh Retail FullText Catalogs
DECLARE @RFTXNAME NVARCHAR(MAX);
DECLARE @RFTXSQL NVARCHAR(MAX);
DECLARE retail_ftx CURSOR FOR
SELECT OBJECT_SCHEMA_NAME(object_id) + '.' + OBJECT_NAME(object_id) fullname FROM SYS.FULLTEXT_INDEXES
WHERE FULLTEXT_CATALOG_ID = (SELECT TOP 1 FULLTEXT_CATALOG_ID FROM SYS.FULLTEXT_CATALOGS WHERE NAME = 'COMMERCEFULLTEXTCATALOG');
OPEN retail_ftx;
FETCH NEXT FROM retail_ftx INTO @RFTXNAME;


BEGIN TRY
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT 'Refreshing Full Text Index ' + @RFTXNAME;
EXEC SP_FULLTEXT_TABLE @RFTXNAME, 'activate';

SET @RFTXSQL = 'ALTER FULLTEXT INDEX ON ' + @RFTXNAME + ' START FULL POPULATION';
EXEC SP_EXECUTESQL @RFTXSQL;
FETCH NEXT FROM retail_ftx INTO @RFTXNAME;

END
END TRY
BEGIN CATCH
PRINT error_message()

END CATCH

CLOSE retail_ftx;
DEALLOCATE retail_ftx;
-- End Refresh Retail FullText Catalogs
 
ALTER DATABASE [<your AX database name>] SET CHANGE_TRACKING = ON (CHANGE_RETENTION = 6 DAYS, AUTO_CLEANUP = ON) GO
 
5.       Stop following services
 
a.       Management Reporter 2012 process Service
 
b.      Microsoft Dynamics 365 Unified Operations: Batch Management Service
 
c.       World Wide Web Publishing Service
 
6.       Rename DB
 
a.       AxDB to AxDB_Orig
 
b.      AxDB_DDMMYYYY (New Restored DB) to AxDB

Use Script

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 <Restore DB name> SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE <Restore DB name> MODIFY NAME = AxDB ;
GO 
ALTER DATABASE AxDB SET MULTI_USER
GO
THis is one
 
7.       Start following services
 
a.       Management Reporter 2012 process Service
 
b.      Microsoft Dynamics 365 Unified Operations: Batch Management Service
 
c.       World Wide Web Publishing Service
 
d.      Start IIS website from IIS manager


Build Model and Sync DB
 

Open DEV URL and check once
 
 
tool to convert backpack file
 
command 
SqlPackage.exe /a:import /sf:C://Users//Admin7f04592810//Downloads//uatbackup.bacpac /tsn:localhost /tdn:AxDB_fromProd /p:CommandTimeout=50000 /ttsc:True
 
 
 
 
 
  • Martin Dráb Profile Picture
    Martin Dráb 230,214 Most Valuable Professional on at
    Database Restore .bacpac file to Development VM
    But please note that this is a discussion forum. If you want to share, not to discuss, please use a blog instead of a forum.

    Also, I've moved the question from the AX forum and removed the prefix "D365FO", because it's not needed when asking in a D365Fo forum.
  • Hana Xue Profile Picture
    Hana Xue Microsoft Employee on at
    D365FO Database Restore .bacpac file to Development VM
    Hi,
    Thank you for sharing useful information on this forum and thank you for your contribution to the forum. This will help more users.
    Best Regards,
    Hana

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans