Thursday, June 26, 2014

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

No comments:

Post a Comment