Restoring a Dynamics NAV Application from a .NAVDATA File

imageIn recent releases of NAV Microsoft have been gradually moving features from the development environment (the artist formerly known as “classic client”) to the Windows client.

When the RoleTailored Client was first released with NAV 2009 you still required the classic client to create, delete and rename companies, to manage users and security roles and to backup and restore company-specific data. All of those tasks can now be completed in the Windows client.

These days you can also backup and restore your application objects which contain your business logic and C/AL code via the client. Notice the enticing checkbox labelled “Application” on the right.

This makes a lot of sense with the drive to separate the database and client tiers. Microsoft want you to host your service tier and database in Azure. That’s great for easily scalable hardware, geographical redundancy and service availability. Not so good if you still need to make a direct connection to the database layer to do half your administration tasks.

Incidentally, if you have no idea what half of that last paragraph means but got a general impression that is it something good that you could benefit from why not call our sales team? I digress.

Search for “Export data to a file” in the menu to find this page. NAV will create a .navdata file with your selected data.

Great. Now what do you do with that file? Follow these steps to restore the data to another database.

1. Create an empty SQL database

The first step is to create an empty SQL database on the target SQL server. Note, this should be a completely empty SQL database, not a newly created NAV database. You can use SQL Server Management Studio to do this. Don’t create a new database using the NAV client.

2. Unleash PowerShell

Like a lot of the subjects I’ve covered in recent posts, PowerShell is central to this task. This is in part due to the fact that as developers we love to do things that look complicated – firing commands into a shell window feels so much better than using UI – but more than that, PowerShell has a huge capacity to automate your database and server administration tasks.

Go through the back catalogue for help getting started with PowerShell:

Fire up PowerShell ISE and load NAV 2015’s management.dll module. If the NAV server installation is at the default path, the command will look like this:

Import-Module “C:\Program Files\Microsoft Dynamics NAV\80\Service\Microsoft.Dynamics.Nav.Management.dll”

Refresh the command add-on (View, Show Command Add-on) and find the Import-NAVData command. You’ll notice that there are four different ways to execute this command, indicated by the four tabs. For full information about the different options see MSDN.

I’m going to use the UseDatabase_AllCompanies option.

Check the AllCompanies box and enter the DatabaseName (and DatabaseServer if you are not running PowerShell on the SQL server). Enter the path to your .navdata file in the FilePath box. Hit the IncludeApplication box.

Click Run at the bottom of the command add-on window and PowerShell will work its magic. The ‘Application’ part of the backup will be restored to the database and convert your empty shell of a SQL database into an empty NAV database.

3. Connect NAV Service Tier

By now you’ve got a valid NAV database that you can connect a NAV service tier to. Once that is connected you will be able to log in with the client and run the “Import from a Data File” to import the rest of your backed up data.

And we’re done. Cool.

2 thoughts on “Restoring a Dynamics NAV Application from a .NAVDATA File”

  1. I have a question, when I try to restore backup from CU4 in a CU1 NAV 2015 version I got an error when trying to restore it (which obviously I don’t get when I try to restore a CU1 version), my doubt is if I try to restore the same backup (from CU4) into a CU8 NAV 2015 version, is it going to give me the same error?

  2. Hi Fabrizio,
    Is there a reason you can’t use the CU4 PowerShell module to restore your backup? Generally speaking it is a good idea to use the tools from the correct CU to manage NAV e.g. the server administration tool will only work with services of the same build as the tool.

Leave a Reply