If you like DNray Forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...

 

SQL Server Database Backup Problem

Started by Gelpannetly, Feb 17, 2024, 12:25 AM

Previous topic - Next topic

GelpannetlyTopic starter

In Microsoft SQL server, I encountered an issue with the backup copy of the database. When importing data from the old database to the new one using SQL Server Management Studio, the files base.ldf and base.mdf were created, along with several folders containing images and files with names like 20200721_092815_00000000010000000000000000035948. However, in the old database, these images and files were directly in the base.ldf and base.mdf files.



The problem arises from the fact that the data and images were not imported into the mdf database file during the import process. As a result, it's not possible to create a full database backup. The backup file (.bak) that was created is much smaller (57 MB) compared to the old full-fledged backup which was 60 GB.

I need assistance in understanding why the data and images were not included in the mdf file during the import process and how to resolve this issue. Can someone help me understand how to ensure that the data and images are properly imported into the mdf file and enable the creation of a full-size database backup? Any insights or assistance on this matter would be greatly appreciated.
  •  


Vanesill

To resolve this issue, let's start by checking the import process configuration and options in SQL Server Management Studio. When importing data, there are settings that control how the import process handles file storage and allocation. It's important to ensure that the settings are configured to include both data and images in the mdf file. This can be achieved by selecting the appropriate options during the import process or by adjusting the database settings post-import.

Another aspect to consider is the filegroup configuration. Filegroups allow for the organization and allocation of database objects across multiple files. By reviewing the filegroup setup, we can ensure that the data and images are placed in the correct filegroups within the mdf file.

Additionally, it's crucial to verify the file paths and locations for the imported data and images. The file paths should align with the mdf file and filegroups to ensure that the data is stored within the database file.

Once the import process and filegroup configurations are reviewed and adjusted as needed, we can proceed with testing the import to ensure that the data and images are properly included in the mdf file.

Regarding the creation of a full-size database backup, once the data and images are correctly stored in the mdf file, the backup process should encompass the entire database, including all data and images, resulting in a full-fledged backup file.

It's vital to thoroughly review the import settings, filegroup configurations, and file paths to ensure that the data and images are properly included in the mdf file. By addressing these aspects, we can work towards resolving the issue and enabling the creation of a comprehensive database backup.

Let's explore some code examples in the context of resolving the database import issue in Microsoft SQL Server.

1. Import Process Configuration:
When using SQL Server Management Studio to import data, you can use the following SQL query as an example to ensure that the data and images are included in the mdf file during the import process:

USE [YourDatabaseName]
GO
EXECUTE sp_addumpdevice 'disk', 'import_device', 'C:\Path\To\Your\BackupFile.bak'
RESTORE FILELISTONLY FROM DISK = 'C:\Path\To\Your\BackupFile.bak'


This query checks the file list from the backup file to see which files are available for restoration. You can then proceed to restore the backup, ensuring that the appropriate options are selected to include data and images in the mdf file.

2. Filegroup Configuration:
To review and adjust the filegroup configuration, you can use the following SQL query as a starting point:

ALTER DATABASE YourDatabaseName ADD FILEGROUP images_fg
ALTER DATABASE YourDatabaseName ADD FILE (NAME = 'logical_name', FILENAME = 'C:\Path\To\Your\ImagesFile.mdf') TO FILEGROUP images_fg


This query creates a new filegroup named 'images_fg' and adds a file for storing images to this filegroup. By organizing the images in a separate filegroup, you can manage their storage within the database more effectively.

3. File Paths and Locations:
To verify and align the file paths and locations for the imported data and images, you can use the following SQL query as an example:

ALTER DATABASE YourDatabaseName MODIFY FILE (NAME = 'logical_name', FILENAME = 'C:\Path\To\Your\DataFile.mdf')

This query modifies the file path for the data file to ensure that it aligns with the mdf file and filegroups, thereby ensuring that the data is stored within the database file.

These code examples provide a glimpse of how SQL queries can be utilized to configure and manage the import process, filegroup setup, and file paths within Microsoft SQL Server. It's important to tailor these examples to your specific database and file organization, taking into account the nuances of your environment.
  •  

OventeeVole

One of the most efficient ways to duplicate MySQL without risking structural or table errors is by employing the DROP—CREATE method. This method is adept at ensuring a seamless replication of the original database structure and content. For instance, the MySQL backup plugin in Handy Backup software utilizes this approach to generate a series of MySQL commands encapsulated in a text file, thus facilitating the restoration of the initial table configuration.

Moreover, when dealing with images stored in an external directory with only links referenced in the database, it is preferable to directly back up the images from the external location using a specialized photo and image backup feature. This method ensures a comprehensive and accurate duplication of the entire database content while minimizing the risk of data discrepancies.
  •  

rebygk

The backup method used will determine whether the database is fully backed up. If the backup file contains binary code, such as in the Handy Backup program (MS SQL plugin), then theoretically all contents should be copied.
However, if the backup is in the form of SQL commands recreating the database, then pictures are not saved. In this case, it's necessary to find the static location where they are stored and back it up separately.
  •  


If you like DNray forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...