Tuesday, June 17, 2014

NAV 2013 R2 - How to Backup and Restore Selected companies CONCEPT.

Hi all,

The most awaited feature in NAV 2013 R2 by most of the consultants around the globe have been finally come as a work around. All Thanks to Microsoft Product Team.

In this post we will see the various ways of taking the Backup of the Database available in NAV 2013 R2 and in subsequent posts we will see how to take backup using Powershell and Windows Client.

** The NAV 2013 R2 Should Have the Build 7.1.36987.
** Uninstall the Previous Version of NAV 2013 R2 and install the latest build.

UPDATE - IF you face issues of Schema During This Process Please refer the Post Here for Issue Resolution.

Post in this series -

1. The Concept (This Post).

Without Tenants -
2.   Backup Using Direct Connection to Database.            
3.   Backup Using Service Tier.                                        
4.   Backup Using Windows Client.                                  
5.   Restore Using Direct Connection to Database.          
6.   Restore Using Service Tier.                                      
7.   Restore Using Windows Client.                                

With Tenants - 



THEORY - 

In earlier versions of Microsoft Dynamics NAV, we could move or copy all or part of the data in a database by using the Microsoft Dynamics NAV backup functionality.

In Microsoft Dynamics NAV 2013 R2, the support for the .fbk files was removed.

But With Cumulative Update 8 for Microsoft Dynamics NAV 2013 R2, Microsoft introduce Windows PowerShell cmdlets so you can export data from a Microsoft Dynamics NAV database and import it into another Microsoft Dynamics NAV database. We can also export and import data in the Microsoft Dynamics NAV Windows client and the Microsoft Dynamics NAV Web client.

The Way Around for .bak have been released.

IMPORTANT THINGS TO REMEMBER- 

When we export data to a .navdata file, we must import the data into a database that is compatible with the data in the .navdata file.

For example, we cannot import a company into a database that has a different database schema, and you cannot import Microsoft Dynamics NAV 2013 data into a Microsoft Dynamics NAV 2013 R2 database.

Also, you must import a company into a database that contains the data and application that the company's data depends on. This means that you must import a company into a database that is based on the same application as in the database that the company was exported from.

What to Export - 

We can export specific sets of data, such as a company or other data. Below are the details of what is exported depending on your choices.

Company => Exports the specified company or companies, or all companies in the database. This includes the company-specific business data but no other data.

Global data => Exports data that is common to all companies in the database. This includes the report list, user IDs, and printer selections, but no company-specific business data.

Application data => Exports the data that defines the application in the database. This includes the permissions, permission sets, profiles, and style sheets.

Application Exports => all application objects. Data is not included. This is similar to exporting all objects to an .fob file.


What to Import - 

We can import all data from a .navdata file, or you can choose the data that you want to import.

For example, if the file contains four companies, you can choose to import only one company. Similarly, if the file contains all data, you can choose to import only global data, for example. To import applications, you must use the Import-NAVData Windows PowerShell cmdlet.

You can import other data, such as companies, in the Microsoft Dynamics NAV Windows client and the Microsoft Dynamics NAV Web client. You can export and import the four types of data in different combinations. However, you must maintain database integrity and not leave databases in a state when you cannot open Microsoft Dynamics NAV.

Windows PowerShell Cmdlets - 

You can import and export companies and data in the Microsoft Dynamics NAV 2013 R2 Administration Shell. The cmdlets take different parameter sets depending on how you connect to the database that you want to export data from or import data into. You can access the database through the Microsoft Dynamics NAV Server instance, or you can access the database directly as described in the following table.

Access => Through the Microsoft Dynamics NAV Server instance =>

Use Parameter sets that include –ServerInstance when the database that you want to access is mounted against a Microsoft Dynamics NAV Server instance. The user account for the Microsoft Dynamics NAV Server instance must have access to write to the location that is specified by the –FileName parameter.

Access => Through a direct connection to the database =>

Use parameter sets that include –DatabaseServer and –DatabaseName when the Microsoft Dynamics NAV Server instance is stopped or not available. For example, if you want to import an updated application into a database, you stop the service so that users cannot access the database. You must have access to write to the location that is specified by the –FileName parameter.

In multitenant deployments of Microsoft Dynamics NAV, if you export or import business data, you must specify the ID of the tenant database. If you export or import applications, you must specify the application database and database server. You can only import application data if the specified tenant is mounted with the –AllowAppDatabaseWrite parameter.

C/AL Functions You can use the following C/AL functions to handle export and import of data programmatically:

EXPORTDATA Function (Database) 
IMPORTDATA Function (Database) 
DATAFILEINFORMATION Function (Database) 

We start tomorrow morning with database backup using direct connection to database and will continue the series in multiple posts to make it easy to understand.

Stay tuned for more.

Regards,
Saurav Dhyani
saurav-nav.blogspot.com

No comments:

Post a Comment