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 -
# 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.

Saurav Dhyani


Popular posts from this blog

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 - 

Future - What Next After NAV 2016. Code Name - Madeira...

Hi All, While Browsing web I came across some article which says about next release of Microsoft Dynamics NAV. Let's see the History of Code Names Given to Previous Version  - NAV 2013 - Code Name 'Sicily' NAV 2015 - Code Name 'CRETE' NAV 2016 - Code Name 'CORFU' And as we all know that all these are the Islands.

Download Microsoft Dynamics Business Central on Premises 2020 Wave 2 Release.

 Hi Readers, As Expected Microsoft have released #msdyn365bc 2020 wave 2 is available.  This article provides details of the new release. The 2020 release wave 2 for Business Central delivers a wealth of new features. Read What's new in 2020 Release Wave 2 here .  Dynamics NAV Customers upgrading to Business Central on Prem will be able to run business central on premises, move to cloud or choose a hybrid approach.