Skip to main content

NAV 2013 R2 - How to Restore Selected companies With Multi Tenancy - Powershell (Using Direct Database & Service Tier).

Hi all,

In this post we will list down the steps to restore backup taken in Previous Post using power shell Using Direct Database & Service Instance For a MultiTenant Database.

If you haven't read the Previous post, please refer to Index of Posts.

UPDATE - IF you face issues of Schema During This Process Please refer the Post Here for Issue Resolution.

Below is the Details of my Companies in Each Tenant -





From the Task Performed in Earlier Posts Backup From Powershell, i have below files as shown Below -



Let's check the Content of Backup Taken Via Emport-NavData.

Microsoft have provided a Commandlet for the same i.e  Get-NAVDataFile.
This Commandlet takes file Location and Name as parameter and returns the details of Content of the backup File.

Open Powershell and Let's check the two file content using Get-NAVDataFile =
--------------------------------------------------------------
Get-NAVDataFile -FileName "c:\Tenant1_Company_C_Backup.navadata"
---------------------------------------------------------------



--------------------------------------------------------------
Get-NAVDataFile -FileName "C:\Tenant1_CompanyA_B_Backup.navadata"
--------------------------------------------------------------



In Today's post we will restore -

 * Company A to My Tenant 2
 * Company B to My Tenant 3
 * Company C to My Tenant 5

Let's try to Restore the backups.

Steps -

1.Search for Import-NAVData Commandlet in Command Addin.

2. If you see there are multiple options in Import-NAVData as listed below (For Database Options)-

1. UseDatabase_AllCompanies
2. UseDatabase_SomeCompanies
3. UseNST_AllCompanies
4. UseNST_SomeCompanies

1 & 2 can be used even if the server instance is stopped or not available.
3 & 4 can only be used if the server instance is running.

We will be demonstrating 2 & 4 as 1 & 3 are like SQL Restore.

2. UseDatabase_SomeCompanies

I am using the Backup taken From Direct Database Connection as per earlier Post.
File Name - Tenant1_CompanyA_B_Backup.navadata

Below are parameters of the command-lets 2 -

1.  Database Name - The Database name in which you want to Restore. (In Multitenancy this will be the Tenant Database Name)
2.  File Name - The File Path and name where backup is placed (ends with Extension => .navdata).
3.  ApplicationDatabaseName - The Name of Database which Contain Only Application Objects.
4.  ApplicationDatabaseServer - The Name of Database Server Where the Application Database Exist.
5.  Company Name - Name of the Company You want to Restore from Backup.
    * IF Company Name contain multiple Words put it in ''.
6.  Database Server - Server Name where the database is placed.
7.  Include Application - Want application objects or not.
8.  Include Application Data - Want  data that defines the application in the database.
9.  Include Global Data - Want Data common to all companies or not.

As shown below is the parameters set for the restore.



Below is the command generated for the two selected companies restore.
-------------------------------------------------------------------------
Import-NAVData -DatabaseName MyTenant2 -FileName C:\Tenant1_CompanyA_B_Backup.navadata -ApplicationDatabaseName MultiTenant_Application_Database -ApplicationDatabaseServer INDEL-SXD6995NB -CompanyName A -Confirm -DatabaseServer INDEL-SXD6995NB
-------------------------------------------------------------------------
** As i only need data specific to Company A & B, i will not select IncludeApplication, IncludeApplicationData & IncludeGlobalData.

In the Similar way the Command to Restore Company B on Tenant MyTenant 3 below is the command -
-------------------------------------------------------------------------
Import-NAVData -DatabaseName MyTenant3 -FileName C:\Tenant1_CompanyA_B_Backup.navadata -ApplicationDatabaseName MultiTenant_Application_Database -ApplicationDatabaseServer INDEL-SXD6995NB -CompanyName B -Confirm -DatabaseServer INDEL-SXD6995NB
-------------------------------------------------------------------------

Run the command and backup will be restored in the database.



4. UseNST_SomeCompanies

I am using the Backup taken From Direct Database Connection as per earlier Post.
File Name - Two_Comapniesbackup_Service.navdata

Below are parameters of the command-lets 4 -

1.  FileName - The File Path and name where backup is placed (ends with Extension => .navdata).
2.  ServerInstance - Name of Service on Which database is connected in which you want to restore.
3.  CompanyName - Name of the Company You want to Restore from Backup.
    * IF Company Name contain multiple Words put it in ''.
4.  IncludeApplicationData - Want  data that defines the application in the database.
5.  Include Global Data - Want Data common to all companies or not.
6.  Tenant - Name of the Tenant on which you want to restore the Company.

As shown below is the parameters set for the restore.



Below is the command generated for the two selected companies restore.
-------------------------------------------------------------------------
Import-NAVData -FileName c:\Tenant1_Company_C_Backup.navadata -ServerInstance MultiTenantBackup -CompanyName C -Confirm -Tenant MyTenant5
-------------------------------------------------------------------------
** As i only need data specific to Company C, i will not select IncludeApplication, IncludeApplicationData & IncludeGlobalData.

Run the command and backup will be restored in the database.


Hope you find the information useful.

With this post the series related to Backup and Restore selected companies in NAV 2013 R2 have been finished.

Stay tuned for more.

Regards,
Saurav Dhyani
saurav-nav.blogspot.com

Comments

Popular posts from this blog

BC 21 and Higher - PowerShell Cmdlet (Replacement of Business Central Administration).

Hi Readers, As discussed in last article about deprecating of Business Central Administration, there are few common actions that we use in administration till Business Central 20. For our on-prem customers, we will still require doing activities. As Microsoft suggest we need to start using PowerShell cmdlet.    Let's see how to do those via PowerShell, or Administration Shell. I will be keep adding commands as you comment to this article.

Send Mail with Attachment From Navision.

Hi all, We have seen how to save a report into PDF and how to send mail to a customer. Let's link these two post in one i.e. Mailing statement to a customer into PDF Format. This article is part of the Series. Please Refer  Table of Content here . If you have the old objects set let me brief you what I will be changing - 

MSDYN365BC - Data Upgrade To Microsoft Dynamics 365 Business Central on premises.

Hi Readers, We have already talked about the number of steps for upgrading to Business Central on Premises from different NAV versions. After that article, I received multiple requests for an article which list down steps for Data Migration. In this article, we will discuss steps of data migration to MSDYN365BC (on-Prem) from NAV 2017. For this article, I am considering a Cronus Demo Database without any customization. For an actual upgrade project, we will have to complete object merge using compare and Merge process. After the Merge Process, the next step is data migration. Let's discuss those steps. Direct Upgrade to Microsoft Dynamics 365 Business Central (on-Prem) is from following versions - 1. NAV 2015. 2. NAV 2016. 3. NAV 2017. 4. NAV 2018.