Skip to main content

NAV 2013 R2 - HowTo Backup a Multi Tenant Environment?

Hi all,

We had seen how to create a Multi Tenant Environment with NAV 2013 R2 earlier.

But what if i want to do a backup of the Multi Tenant Environment and Restore it on a Different Server. How can i achieve it as in my SQL now i have multiple databases.

So let's see how we can achieve it.

** References - Waldo Blog. Thanks to Waldo for sharing the Information, i have tried to append the steps listed in the Video.

Scenario -
I have a Multi tenant Environment Created with Multiple Tenants (5) and Application Objects. I want to Backup the whole Environment and Restore it on New Server.




Steps - (Before Starting the process, lets see the environment creation steps)

1. Created a Service MultiTenantBackup as shown Below.




2. Restored a Cronus W1 Databases, Copied the Company for 4 Times as shown below. Renamed Companies to Tenant 1 to Tenant 5.





3. Created the MultiTenant Environment using the Powershell Command, as shown below.
* You can refer the Blog articles listed here if you want to see how to create a multiTenant Environment.




As you can see that i have 5 Tenants databases in SQL and a Application Database.

4. For Backup all the Tenant and Application database at a Specified Location, i have used Below Powershell Command.
* Powershell should be Run as Administrator. How to Open Powershell?
--------------------------------------------------------------------------------------
# Powershell Command to Take Backup of Tenant and Application Database.
# Author - Waldo
# Modified By - Saurav Dhyani
# Blog - saurav-nav.blogspot.com
# Parameters Need to Specify Before Running Command - 
# ServiceInstance - Name of Service Instance You want to Backup.
# BackupLocation - Path Where you want Backup to be Stored.

$ServiceInstance = 'MultiTenantBackup'
$BackupLocation = 'C:\D DRIVE\Multitenancy\Backup\Tenants\'

#Backup the Application Database
$NavApplication = Get-NAVApplication $ServiceInstance
$AppDatbaseName = $NavApplication.'Database Name'
$AppDataBackupFileName = $BackupLocation + $NavApplication.'Database Name' + '.bak'
Get-Variable AppDataBackupFileName
Backup-SqlDatabase -ServerInstance $NavApplication.'Database Server' -Database $NavApplication.'Database Name' -BackupFile $AppDataBackupFileName -BackupAction Database

#Backup All the Tenant Databases
$NavTenants = Get-NAVTenant $ServiceInstance
Foreach ($NavTenant in $NavTenants)
{
 $TenantBackupFileName = $BackupLocation + $NavTenant.Databasename + '.bak'
 Get-Variable TenantBackupFileName
 Backup-SqlDatabase -ServerInstance $NavTenant.DatabaseServer -Database $NavTenant.Databasename -BackupFile $TenantBackupFileName -BackupAction Database
}
----------------------------------------------------------------------------------------

You can download the Powershell command from the SkyDrive Link. Link is available at end of the Post.

5. Let's Understand the Command.

At the Beginning of the Command we set two Parameters i.e -
 1. Service Instance = The name of Service Tier we want to Backup.
 2. Backup Location = The Path Where we want our Databases Backup Should be Placed.

Then Using Powershell we get the application database Name attached to the Service Instance, Provided the File Name and by using SQLPS Backup Command we Placed the Backup at the Specified Location.

* For other Parameters During Backup you can look at Backup-SQLDatabase Command Parameters in Powershell Command Addin Window.

After Backup of the Application Database, we look for Tenants Mounted in the Service Instance and then for each Tenant in the Instance we Run the SQLPS Backup Database Commandlet to backup the tenant Databases.
Here is what happens when i execute the commandlet.



Let's Naviage to Folder and see the Backup done by the Powershell script.



You can download the Powershell command from my SkyDrive.

File Name - Command 7 - NAV 2013 R2 - Backup a Multi Tenant Environment

In Next post we will try to restore the backup in a new environment.

Hope you find the information useful.

Regards,
Saurav Dhyani
www.sauravdhyani.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.