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?
--------------------------------------------------------------------------------------
$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
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
Post a Comment