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

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.

Error After Restore SQL Backup of NAV 2013 Database

Hi all, we are facing a conman issue during restoring a SQL Database backup restored for NAV 2013. While Trying to run object from Object Designer we get below listed error (even the service is configured properly) - --------------------------- Microsoft Dynamics NAV Development Environment --------------------------- There are no NAV Server instances available for this database. You must ensure that a NAV Server instance is running and is configured to use the database before you perform this activity. --------------------------- OK    ---------------------------