Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Business Central onprem BAK file

(1) ShareShare
ReportReport
Posted on by 68
Dear Community 
 
I need BAK File to create a Business Central docker Container. 
 
The Database is very Big and i want to Limit the Size of the BAK File.
 
The reason for this the Container does not get created If the BAK File is too Big.
 
So can somebody give me some good service?
 
Thanks in advance
Categories:
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 74,115 Super User 2024 Season 2 on at
    Business Central onprem BAK file
    As far as I know, it is possible to limit the size of a docker, but not the size of a bak file.
     
    You can export data via the configuration package and then import it from the docker environment.
     
    Hope this helps.
    Thanks.
    ZHU
  • Suggested answer
    gdrenteria Profile Picture
    gdrenteria 12,338 Most Valuable Professional on at
    Business Central onprem BAK file

    Hi, good day
    I hope this can help you, and give you some hints.

    How to reduce size of docker data volume in Docker Desktop for Windows v2 - DEV Community

    Best Regards
    Gerardo

     

  • Suggested answer
    Saif Ali Sabri Profile Picture
    Saif Ali Sabri 370 on at
    Business Central onprem BAK file
    My response was crafted with AI assistance, tailored to provide detailed and actionable guidance for your query.
    If you're trying to create a Business Central On-Premises Docker container but are running into issues because the database backup (BAK file) is too large, there are several approaches you can use to reduce the size of the BAK file or simplify the setup process for your container.

    Below are the steps and options you can follow to resolve this:


    Option 1: Shrink the Database Before Backup

    The size of your BAK file is directly influenced by the size of the database. You can reduce the size of the database before creating the backup by shrinking unused space in the database and clearing old/unnecessary data.

    Steps to Shrink the Database:

    1. Open SQL Server Management Studio (SSMS).
    2. Select your Business Central database.
    3. Right-click the database > Tasks > Shrink > Database.
      • Note: Shrinking will remove unused space but will not delete actual data.
    4. If applicable, shrink the transaction log as well:
      • Right-click the database > Tasks > Shrink > Files.
      • Choose File Type: Log, and shrink the log file.

    Considerations:

    • Shrinking the database does not delete historical data; it only reclaims unused space. If you want to reduce the database size significantly, proceed to the next option (removing unused data).

    Option 2: Reduce the Database by Deleting Old or Test Data

    Large databases in Business Central often contain test data, historical entries, or old audit records that aren't required for container development purposes. You can create a lighter version of the database by:

    1. Clearing Logs and Histories:

      • Delete unnecessary change logs:
        Navigate to Change Log Entries in Business Central and delete old records (if not needed for development).
      • Delete historical job queue entries or posted documents that are not critical for the environment.
    2. Export and Truncate Specific Data:

      • Use SQL Server Management Studio (SSMS) to truncate large tables that are not needed for your container.
        Example:
        sql 
        DELETE FROM [MyDatabase].[dbo].[SomeLargeTable];
        Common large tables include:
        • Change Log Entries
        • Job Queue Entries
        • Archived Documents
        • Historical or posted ledger entries.
    3. Backup the Reduced Database:

      • After removing unnecessary data, create the BAK file:
        sql 
        BACKUP DATABASE [MyDatabase]
        TO DISK = 'C:\Path\MyReducedDatabase.bak'
        WITH COMPRESSION, INIT;
      • Using the WITH COMPRESSION option will significantly reduce the BAK file size.

    Option 3: Use SQL Backup Compression Tools

    If you cannot reduce the size of the database significantly by truncating data, you can still compress the BAK file using external tools.

    SQL Backup Compression Options:

    1. Use Built-In Compression:

      • While creating the backup, use the WITH COMPRESSION option:
        sql 
        BACKUP DATABASE [MyDatabase]
        TO DISK = 'C:\Path\CompressedDatabase.bak'
        WITH COMPRESSION;
      • This often reduces the file size by 30-70%, depending on your database contents.
    2. Zip the BAK File:

      • After creating the backup file, compress it using a zip utility (e.g., 7-Zip or WinRAR). Docker containers typically support importing compressed files.

    Option 4: Export Only the Required Companies

    If your Business Central database contains multiple companies, exporting only the company or companies you need can dramatically reduce the database size.

    Steps to Export a Single Company:

    1. Open Business Central On-Premises.
    2. Navigate to Administration > Companies.
    3. Export the company data to a new database:
      • Run the Export-NAVData PowerShell command:
        powershell 
        Export-NAVData -DatabaseServer "MySQLServer" -DatabaseName "MyDatabase" -CompanyName "MyCompany" -FileName "C:\Path\MyCompanyData.navdata"
    4. Create a new database for your Docker container and import the company data:
      • Create a blank database.
      • Use the Import-NAVData command to import the company data:
        powershell 
        Import-NAVData -DatabaseServer "MySQLServer" -DatabaseName "MyNewDatabase" -FileName "C:\Path\MyCompanyData.navdata"
    5. Create a BAK file of the new database.

    This approach is particularly useful if the database size is inflated due to data for unused companies.


    Option 5: Use Microsoft-Supplied Docker Images

    If the sole purpose of your container is to develop or test, consider using Microsoft's pre-built Docker images for Business Central instead of uploading your own database.

    Steps:

    1. Pull a lightweight Business Central Docker image:

      powershell 
      docker pull mcr.microsoft.com/businesscentral/onprem:14.8.35602.0
      • Replace the version number with the version of your choice (e.g., 24.x for BC24).
    2. Use the pre-built image and import your extensions or configurations separately.

    Advantages:

    • Saves time and avoids dealing with large databases.
    • You can still restore custom databases later if needed.

    Option 6: Split the BAK File

    If you still cannot reduce the database size enough, you can split the BAK file into multiple smaller parts using SQL Server’s backup splitting feature. This allows you to manage large files more efficiently when working with Docker.

    Steps:

    1. Use the WITH FORMAT and WITH FILE options to create split backups:
      sql 
      BACKUP DATABASE [MyDatabase]
      TO DISK = 'C:\Path\Part1.bak',
      DISK = 'C:\Path\Part2.bak',
      DISK = 'C:\Path\Part3.bak'
      WITH FORMAT, INIT, COMPRESSION;
    2. Combine the files in the Docker container when restoring the database.

    Option 7: Use a Lightweight Test Database

    If you're still facing challenges with a large database, consider using a demo database for your container. Microsoft provides sample Business Central databases for testing purposes:

    1. Download the demo database for Business Central On-Premise from the Microsoft PartnerSource or Docs site.
    2. Restore this database and use it in your Docker container setup.

    Final Notes

    • Always work with a copy of your production database to avoid unintentional data loss.
    • If you're using Azure or third-party tools, you can also transfer large backups for optimization (e.g., Azure SQL backups offer built-in compression).
    • Monitor your Docker logs for any specific errors if the container fails to create with the large database.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans