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

VIEW SERVER STATE permission on SQL Server?

Hi all, Sometime While trying to Login into a database we face an error message as shown below. --------------------------- Microsoft Dynamics NAV Classic --------------------------- You cannot start Microsoft Dynamics NAV Classic because you do not have the VIEW SERVER STATE permission on SQL Server. Contact your system administrator. --------------------------- OK    ---------------------------

RTC Report It is not possible to instantiate the Visual Studio bridge.

Hi all, As a Navision developers I have Multiple Versions of Navision running in single Machine. As discussed Earlier in the post how to run multiple Version of RTC in single machine. So my machine have following details for RTC Versions - NAV 2009 R2    - is installed. NAV 2009 SP1  - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 SP1 IN\ NAV 2009         - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 IN\ This approach has been working great for execution of Classic and RTC Clients. However, after installing Dynamics NAV 2009 R2, if i tried to view the Layout for an NAV 2009 SP1 Report i was getting the following error: ---------------------------  Microsoft Dynamics NAV Classic  ---------------------------  It is not possible to instantiate  the Visual Studio bridge.  ---------------------------  OK    --------------------------- After searching for the error i figured out the issue was due to - Design change in NA

NAV 2013 R2 - Cumulative update 12 Released.

Hi all, Please find below the details of  Cumulative Update 12 released for Microsoft Dynamics NAV 2013 R2. Title - Cumulative Update 12 for Microsoft Dynamics NAV 2013 R2 Build No. - 38053 Release Date - October, 2014 Local Version Included - AU, AT, BE, CH, DE, DK, ES, FI, FR, IS, IT, NA, NL, NO, NZ, SE, UK, RU Download Link Note: Implementing this cumulative update will require a database conversion unless you have already implemented update rollup 5.