Restore/move D365 database

Restore data base from same tenant (company)

1. Open as Administrator PowerShell
Install if not installed d365fo tools in power shell
- Install-Module -Name d365fo.tools
- Invoke-D365InstallSqlPackage

2. Restore database
if BACPAC file
in powershell
- Import-D365Bacpac -ImportModeTier1 -BacpacFile "C:\temp\CLI TEST1backup.bacpac" -NewDatabaseName "AxDB_20211104" -ShowOriginalProgress

if BAK file go to Microsoft SQL Server Management Studio
Databases node / Right click / Restore Database...
General / Source / Device / click ... button
Click add button select BAK file and click OK and then again OK
Destination / Database change to AxDB_20211104 (date)
Files page (at right)
make sure that Restore As columnt has different files from Original File Name, change from AXDB_FromProdRep1 to AXDB_20211104_FromProdRep1, both lines
Click OK to start process

3. Stop environment
powershell
- Stop-D365Environment
Open IIS manager / Application Pools / AOSService / stop
Close all visual studio. Re open visual studio. Check tray for IISExpress. Right click in tray and Exit

4. Switch databases
In powershell
- Switch-D365ActiveDatabase -SourceDatabaseName "AxDB_20211104" -DestinationSuffix "_old"
Where _old is postfix for currently used AxDB, it will be called AxDB_old

5. Start environment
In powershell
- Start-D365Environment
Open IIS manager / Application Pools / AOSService / start
Close all visual studio. Re open visual studio.
Dynamics 365 / Synchronize database...

For tier2 environments like UAT it is possible to do it from LCS:
Open full environment details
Maintain / Move database
Export database - fill create BACPAC file and upload it to LCS
Import database - will import database from BACPAC file from LCS

To take backups in Microsoft SQL Server Management Studio
Righr click on data base Tasks / Back Up...
Back up type : Full
Destination / Back up to: Disk
Files - change the file name of back up for example AxDB_20211103.bak
Backup Options: Compression can be enabled - Set backup compression: Compress backup. LCS has limit of 14 Gb to upload. Therefore might be usefull.
Also shrink DB might be used: https://daxonline.org/1734-axdb-shrink.html

D365FO documentation:
https://github.com/d365collaborative/d365fo.tools/tree/development/docs

BAK/BACKBAK difference:
https://www.sqlservercentral.com/forums/topic/diff-between-bak-and-backpac-files



 

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags