Data backup method and device, electronic equipment and storage medium
By identifying the differential data between the master disk and the child disk, only the actual changed data is backed up, which solves the problem of slow backup files bloating and recovery speed caused by traditional backup methods, and achieves the effect of saving storage space and speeding up recovery speed.
Patent Information
- Application Number
- CN202411648043.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2025-03-28
AI Technical Summary
When handling cloning RBD, traditional backup methods fail to fully consider their cloning properties, resulting in the volume of backup files swelling, increasing the time and resource consumption of backup and restore, and affecting system performance and user experience.
By obtaining the initial data of the master disk and the backup data of the child disk, the difference data is determined, that is, the data whose contents of the child disk and the master disk are different in the same data area, and the difference data is written to the backup file used to restore the child disk.
Only backing up the actual changing data reduces the volume of backup files, saves storage space and storage costs, speeds up data restoration, and meets the needs of fast backup and recovery in modern cloud computing environments.
Smart Images

Figure CN119718775A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of block storage technology, and in particular to a data backup method, device, electronic device and storage medium. Background Art
[0002] In the cloud computing environment, Ceph, as an excellent open source distributed storage system, is widely used to meet data storage needs. Ceph provides three interfaces: object storage, block storage, and file storage. Among them, RADOS Block Device (RBD) is a block device service provided by Ceph to the outside world, which is often used for the rapid provisioning of virtual machines. Through the cloning function, users can quickly generate multiple subvolumes from the snapshot of the base image as the system disk of the virtual machine to improve resource utilization efficiency.
[0003] However, traditional backup methods often fail to fully consider the clone properties when dealing with cloned RBDs. This results in that during the backup process, especially when the cloned RBD rewrites less data, most of the data saved in the backup is still the unchanged data of the master disk. This situation not only causes the backup file size to expand when backing up or restoring multiple sub-disks cloned from the same master disk, but also increases the time and resource consumption required for backup and restoration, thereby affecting the overall system performance and user experience. Summary of the invention
[0004] The embodiments of the present disclosure provide a data backup method, device, electronic device and storage medium, aiming to solve the problems existing in the above-mentioned background technology.
[0005] In order to solve the above technical problems, the present disclosure is implemented as follows: In a first aspect, an embodiment of the present disclosure provides a data backup method, the method comprising: Acquire the initial data of the mother disk and the backup data of the child disk cloned from the mother disk; Determine differential data from the sub-disk according to the initial data of the master disk and the backup data of the sub-disk, wherein the differential data is data with different contents in the same data area between the sub-disk and the master disk; The differential data is written into a backup file for restoring the backup data of the sub-disk.
[0006] Optionally, after writing the difference data into a backup file for restoring the backup data of the sub-disk, the method further comprises: Determine shared data from the master disk according to the initial data of the master disk and the backup data of the child disk, and determine that the shared data occupies a first data area of the master disk, wherein the shared data is data with the same content in the same data area of the master disk and the child disk; Reading the difference data from the backup file, and determining that the difference data occupies the second data area of the sub-disk; The shared data is written into a data area of the restoration disk corresponding to the first data area, and the differential data is written into a data area of the restoration disk corresponding to the second data area. The restoration disk is a blank disk with a capacity consistent with that of the master disk.
[0007] Optionally, writing the difference data into a backup file for restoring the backup data of the sub-disk includes: Determine whether there is erase space on the sub-disk, the erase space being an erased data area in the sub-disk; In the case that there is erased space on the sub-disk, erased information of the erased space and the difference data are written into the backup file.
[0008] Optionally, determining whether there is erase space on the sub-disk includes: Determine a plurality of data objects corresponding to the backup data of the sub-disk; Determining an allocation status of each of the plurality of data objects; For the multiple data objects, when it is detected that the allocation status of any data object is incompletely allocated, the data area where the incompletely allocated backup data of the data object is located is determined as the erase space on the sub-disk.
[0009] Optionally, after writing the difference data into a backup file for restoring the backup data of the sub-disk, the method further comprises: Determine shared data from the master disk according to the initial data of the master disk and the backup data of the child disk, and determine that the shared data occupies a first data area of the master disk, wherein the shared data is data with the same content in the same data area of the master disk and the child disk; Reading the differential data and erasure information of the erased space from the backup file, and determining that the differential data occupies the second data area of the sub-disk; Writing the shared data into a data area of the restoration disk corresponding to the first data area, and writing the difference data into a data area of the restoration disk corresponding to the second data area, wherein the restoration disk is a blank disk with the same capacity as the master disk; Determining, according to the erasure information, a historical erasure operation of the sub-disk, wherein the historical erasure operation is performed on an erase space of the sub-disk; An erasing operation corresponding to the historical erasing operation is performed on the restoration disk.
[0010] Optionally, writing the difference data into a backup file for restoring the backup data of the sub-disk includes: Determining the capacity of the master disk and the historical minimum capacity of the child disk; Determining the size of the overlapping space between the master disk and the sub-disk according to the capacity of the master disk and the historical minimum capacity of the sub-disk; Determining whether the capacity of the master disk is consistent with the size of the overlapping space; In the case that the capacity of the master disk is inconsistent with the size of the overlapping space, data of the size of the overlapping space is recorded, and the difference data and the data of the size of the overlapping space are written into the backup file.
[0011] Optionally, after writing the difference data into a backup file for restoring the backup data of the sub-disk, the method further comprises: Determine shared data from the master disk according to the initial data of the master disk and the backup data of the child disk, and determine that the shared data occupies a first data area of the master disk, wherein the shared data is data with the same content in the same data area of the master disk and the child disk; Check whether the backup file contains data on the size of the overlapping space; In a case where the data of the size of the overlapping space is recorded in the backup file, reading the difference data and the data of the size of the overlapping space from the backup file; Determining that the difference data occupies a second data area of the sub-disk; According to the data of the size of the overlapping space, a capacity reduction operation is performed on the restoration disk to adjust the capacity of the restoration disk to be consistent with the size of the overlapping space, and the restoration disk before the capacity reduction operation is a blank disk with a capacity consistent with that of the mother disk; The shared data is written into a data area of the restored disk after the shrinking operation corresponding to the first data area, and the differential data is written into a data area of the restored disk after the shrinking operation corresponding to the second data area.
[0012] In a second aspect, an embodiment of the present disclosure provides a data backup device, the device comprising: An acquisition module, used for acquiring the initial data of the mother disk and the backup data of the child disk cloned from the mother disk; a determination module, configured to determine difference data from the child disk according to the initial data of the mother disk and the backup data of the child disk, wherein the difference data is data having different contents in the same data area between the child disk and the mother disk; The backup module is used to write the difference data into a backup file used to restore the backup data of the sub-disk.
[0013] Optionally, the device further comprises: a first shared data determination module, configured to determine shared data from the mother disk according to the initial data of the mother disk and the backup data of the child disk, and determine that the shared data occupies a first data area of the mother disk, wherein the shared data is data with the same content in the same data area of the mother disk and the child disk; A first difference data determination module, configured to read the difference data from the backup file and determine that the difference data occupies the second data area of the sub-disk; The first writing module is used to write the shared data into a data area of the restoration disk corresponding to the first data area, and to write the difference data into a data area of the restoration disk corresponding to the second data area, wherein the restoration disk is a blank disk having a capacity consistent with that of the master disk.
[0014] Optionally, the backup module includes: an erase space determination submodule, used to determine whether there is erase space on the sub-disk, the erase space being an erased data area in the sub-disk; The first writing submodule is used for writing the erasure information of the erase space and the difference data into the backup file when there is erase space on the sub-disk.
[0015] Optionally, the erase space determination submodule includes: A first determining unit, configured to determine a plurality of data objects corresponding to the backup data of the sub-disk; A determination unit, configured to determine the allocation status of each of the plurality of data objects; The second determining unit is configured to determine, for the plurality of data objects, when it is detected that the allocation status of any data object is incompletely allocated, a data area where the incompletely allocated backup data of the data object is located as the erase space on the sub-disk.
[0016] Optionally, the device further comprises: a second shared data determination module, configured to determine shared data from the mother disk according to the initial data of the mother disk and the backup data of the child disk, and determine that the shared data occupies a first data area of the mother disk, wherein the shared data is data with the same content in the same data area of the mother disk and the child disk; A second difference data determination module, configured to read the difference data and erase information of the erase space from the backup file, and determine that the difference data occupies the second data area of the sub-disk; A second writing module is used to write the shared data into a data area of the restoration disk corresponding to the first data area, and write the difference data into a data area of the restoration disk corresponding to the second data area, wherein the restoration disk is a blank disk with the same capacity as the master disk; a historical erasure operation determination module, configured to determine a historical erasure operation of the sub-disk according to the erasure information, wherein the historical erasure operation is performed on an erase space of the sub-disk; The erasing module is used to perform an erasing operation corresponding to the historical erasing operation on the restoration disk.
[0017] Optionally, the backup module includes: A capacity determination submodule, used to determine the capacity of the mother disk and the historical minimum capacity of the child disk; an overlap size determination submodule, used to determine the size of the overlap space between the mother disk and the child disk according to the capacity of the mother disk and the historical minimum capacity of the child disk; A capacity determination submodule, used to determine whether the capacity of the mother disk is consistent with the size of the overlapping space; The second writing submodule is used to record the data of the size of the overlapping space when the capacity of the mother disk is inconsistent with the size of the overlapping space, and write the difference data and the data of the size of the overlapping space into the backup file.
[0018] Optionally, the device further comprises: a third shared data determination module, configured to determine shared data from the mother disk according to the initial data of the mother disk and the backup data of the child disk, and determine that the shared data occupies a first data area of the mother disk, wherein the shared data is data having the same content in the same data area of the mother disk and the child disk; Check whether the backup file contains data on the size of the overlapping space; A third difference data determination module is used for reading the difference data and the data of the size of the overlapped space from the backup file when the data of the size of the overlapped space is recorded in the backup file, and determining that the difference data occupies the second data area of the sub-disk; A shrinking module, used for performing a shrinking operation on the restoration disk according to the data of the size of the overlapping space, adjusting the capacity of the restoration disk to be consistent with the size of the overlapping space, wherein the restoration disk before the shrinking operation is a blank disk with a capacity consistent with that of the mother disk; The third writing submodule is used to write the shared data into a data area corresponding to the first data area of the restored disk after the shrinking operation is performed, and to write the differential data into a data area corresponding to the second data area of the restored disk after the shrinking operation is performed.
[0019] In a third aspect, an embodiment of the present disclosure provides an electronic device, including: a processor, a memory, and A computer program stored in the memory and capable of running on the processor implements the steps of a data backup method when the computer program is executed by the processor.
[0020] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of a data backup method are implemented.
[0021] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects: The present invention identifies the difference data between the master disk and the child disk, and only backs up the data that has actually changed, thus avoiding unnecessary repeated backup. The incremental backup strategy based on the difference data disclosed in the present invention not only reduces the size of the backup file, saves storage space and storage costs, but also speeds up the subsequent data restoration. When restoring data, users can quickly access the latest status, avoiding the trouble of long waiting, and meeting the urgent need for fast backup and recovery in modern cloud computing environments. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 It is a schematic diagram of a data backup and restoration method in the related art; Figure 2 It is a flowchart of a data backup and restoration method in the related art; Figure 3 It is a schematic diagram of the steps of a data backup method provided by an embodiment of the present disclosure; Figure 4 is a schematic diagram of a data backup and restoration method in an embodiment of the present disclosure; Figure 5 is a flowchart of a data backup and restoration method in an embodiment of the present disclosure; Figure 6It is a structural block diagram of a data backup device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0024] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0025] Figure 1 is a schematic diagram of a data backup and restoration method in the related art, Figure 2 is a flowchart of a data backup and restoration method in the related art. Figure 1 and Figure 2 In the traditional data backup process, you first need to select the clone RBD (RADOS Block Device) to be backed up, that is, the child disk, and then scan and read the entire clone RBD, and copy all the data on the master disk and the child disk to the backup file. The backup software reads the data block by block, and all the data will be copied one by one regardless of whether the data has changed. After the data is read, the data is packaged and stored in the specified backup location. The above process involves a large number of I / O operations, resulting in a long backup time. Since the backup process does not distinguish the changes in the data, all data blocks are backed up repeatedly, even if most of the data has not changed in the master disk, which not only leads to a large backup file size, but also occupies a large amount of storage space. In the traditional data restoration process, the backup file is first selected, and then the data in the backup file is read and written to the restoration disk. The disadvantages are its slow recovery speed and high consumption of system resources. Since the data needs to be read and written block by block, especially when the backup file is large, the time required for restoration will increase significantly. In addition, the traditional method also has the risk of data inconsistency, especially if the original data changes during the backup, the restored data may not match the user's expected state. These problems make traditional backup and restore processes unable to meet the needs of modern data management in terms of efficiency and reliability, especially in cloud computing and virtualization environments.
[0026] Figure 3 is a schematic diagram of the steps of a data backup method provided by an embodiment of the present disclosure, such as Figure 3 As shown, in order to solve the problems existing in the above-mentioned related technologies, the present disclosure considers performing data backup and subsequent restoration based on differential data, and the method includes: Step S101, obtaining initial data of a master disk and backup data of a child disk cloned from the master disk.
[0027] Figure 4 is a schematic diagram of the data backup and restoration method in the embodiment of the present disclosure, see Figure 4 The mother disk refers to the original data disk that serves as the base image. It is a template for creating multiple child disks. All child disks can be cloned from the mother disk. The child disk is a virtual disk cloned from the mother disk, which is used to store user or application data. Each child disk can be operated and modified independently of the mother disk. The data changes made by the user in the child disk will not affect the mother disk. The creation process of the child disk is based on the snapshot of the mother disk. The child disk will copy the initial state of the mother disk when it is created, but subsequent modifications and data writing will only affect the child disk.
[0028] Initial data refers to the complete data state of the master disk when it is created, and backup data refers to the current data state extracted from the sub-disk, which is used to restore the state of the sub-disk in the event of data loss, damage or other unexpected situations.
[0029] Step S102: determining difference data from the child disk according to the initial data of the mother disk and the backup data of the child disk, wherein the difference data is data with different contents in the same data area between the child disk and the mother disk.
[0030] Compare the initial data of the master disk and the backup data of the child disk to identify the difference between the two. The difference data refers to the part of the child disk that is inconsistent with the master disk in the same data area. By identifying the difference data, backup and subsequent restore operations can be performed effectively. Assume that the initial data of the master disk is as follows: Data area A: File 1 (content is "Hello World"); Data area B: File 2 (content is "Data Backup"); Data area C: File 3 (content is "Configuration"); the child disk is cloned from the mother disk, and the child disk copies the initial state of the mother disk when it is created. At this time, the initial data of the child disk is the same as the mother disk. Subsequently, the user performs the following operations on the child disk. In data area A, the user modifies the content of file 1 to "Hello Universe"; in data area B, the user deletes file 2; data area C remains unchanged. Therefore, the backup data of the child disk is as follows: Data area A: File 1 (content is "Hello Universe"); Data area B: None (file 2 has been deleted); Data area C: File 3 (content is "Configuration"). Comparing the data areas of the master disk and the child disk, we can find that the content of data area A is different (the master disk is "Hello World" and the child disk is "Hello Universe"); the content of data area B is different (the master disk has file 2, but the child disk does not have file 2); the content of data area C is the same (both are "Configuration"). Therefore, the difference data is file 1 in data area A (content is "Hello Universe") and file 2 in data area B (content is "Deleted").
[0031] Step S103: writing the difference data into a backup file used to restore the backup data of the sub-disk.
[0032] The backup file is used to store differential data. The backup file can be a new file or an updated version of an existing backup file. The identified differential data are written into the backup file one by one. According to the previous example, during the writing process, the state changes of each data area are recorded. For example, for data area A, the content of file 1 is written as "Hello Universe". For data area B, the deletion status of file 2 is written. The backup file is saved to a specified storage location so that it can be easily accessed and used when needed. The backup file can be stored locally or remotely.
[0033] The present invention identifies the difference data between the master disk and the child disk, and only backs up the data that has actually changed, thus avoiding unnecessary repeated backup. The incremental backup strategy based on the difference data disclosed in the present invention not only reduces the size of the backup file, saves storage space and storage costs, but also speeds up the subsequent data restoration. When restoring data, users can quickly access the latest status, avoiding the trouble of long waiting, and meeting the urgent need for fast backup and recovery in modern cloud computing environments.
[0034] In an optional implementation manner, after writing the difference data into a backup file for restoring the backup data of the sub-disk, the method further includes: Step S201, based on the initial data of the mother disk and the backup data of the child disk, determine the shared data from the mother disk, and determine that the shared data occupies the first data area of the mother disk, the shared data is the data with the same content in the same data area of the mother disk and the child disk.
[0035] Compare the initial data of the mother disk and the backup data of the child disk to identify the identical data parts between the two and determine them as shared data. Shared data refers to data in the same data area where the contents of the mother disk and the child disk are completely identical. Specifically, traverse the initial data of the mother disk and the backup data of the child disk. For each data area, check whether the contents of the mother disk and the child disk are the same. If the contents of a data area are the same, mark the data area as shared data and record its location in the mother disk (the first data area).
[0036] Step S202, reading the difference data from the backup file, and determining that the difference data occupies the second data area of the sub-disk.
[0037] The backup file previously created in step S103 is opened, differential data is extracted from the backup file, the differential data being the different parts between the mother disk and the child disk, and the position (second data area) occupied by the differential data in the child disk is determined.
[0038] Step S203, writing the shared data into a data area of the restoration disk corresponding to the first data area, and writing the differential data into a data area of the restoration disk corresponding to the second data area, wherein the restoration disk is a blank disk having the same capacity as the master disk.
[0039] The shared data and differential data are written to a new blank disk (restore disk) respectively. The capacity of the restore disk is the same as that of the master disk. Specifically, the shared data is written to the location corresponding to the first data area in the restore disk. In other words, all the data that is the same in the master disk and the child disk will be directly copied from the master disk to the restore disk. The differential data is written to the location corresponding to the second data area in the restore disk.
[0040] The data restoration method disclosed herein avoids repeated storage of the same data and only processes the difference data that has actually changed, while retaining the unmodified shared data in the master disk, thereby effectively utilizing the storage space.
[0041] See also Figure 2When the related technology wants to calculate the difference between the child disk and the parent disk, it calls the rbd_diff_iterate2 interface to detect the allocated space in the RBD, but it cannot distinguish which data areas are unallocated (i.e., unused space) and which data areas have been erased. The rbd_diff_iterate2 interface is not specifically designed for the characteristics of cloned disks. If the difference data is calculated through rbd_diff_iterate2, the unallocated data blocks may be regarded as valid data. When the user tries to restore the backup data of the child disk from the backup, the erased data blocks are restored to the data in the corresponding data area in the parent disk, but in fact the user has deleted this data block, resulting in the user seeing the wrong content of the data block after restoration, instead of the expected unallocated state.
[0042] In order to overcome the above problems, the present invention discloses a new interface (rbd_diff_from_parent) in librbd, which enables the system to accurately identify which data areas are erased when calculating the difference, and record this information in the difference file. The step of writing the difference data into a backup file for restoring the backup data of the sub-disk includes: Step S301, determining whether there is erase space on the sub-disk, the erase space being an erased data area on the sub-disk.
[0043] Figure 5 This is a flow chart of the data backup and restore method in the embodiment of the present disclosure. Please refer to the left branch. During the backup process, first determine whether there is erase space on the sub-disk. Erase space refers to the data area in the sub-disk that has been deleted or erased by the user. Specifically, the interface rbd_diff_from_parent is used to query the status of each data block of the sub-disk when calculating the difference data, and identify which data blocks are valid, which are unallocated (that is, there is no data), and which are erased. By analyzing the status of the data blocks, it is possible to determine which data blocks have been erased. For example, if a data block is unallocated in the sub-disk and there is data in the parent disk, it can be determined that the data block is erase space.
[0044] Step S302: When there is erase space on the sub-disk, write the erase information of the erase space and the difference data into the backup file.
[0045] If there is erased space on the sub-disk, the erased space's erased information is recorded, which may include the erased data block's index or address, erased timestamp, and other related metadata. The erased space's erased information and differential data are written together into a backup file, waiting for subsequent data restoration.
[0046] Through the above steps, the present disclosure accurately handles erased space during backup and restore, thereby improving data consistency and accuracy, and avoiding data confusion and inconsistency problems caused by erroneous recovery. During backup, not only the difference data is recorded, but also the information of erased space can be effectively managed, so that the user's expected state can be accurately reconstructed during restore.
[0047] In an optional implementation manner, step S301, determining whether there is erase space on the sub-disk, further includes the following steps: Step S3011, determining a plurality of data objects corresponding to the backup data of the sub-disk.
[0048] The backup data of the sub-disk is composed of multiple data objects, which are stored in the form of blocks. Therefore, the backup data can be determined according to the identifiers of the multiple data objects.
[0049] Step S3012: determine the allocation status of each of the multiple data objects.
[0050] Perform a status query on each data object to check its allocation status. The present disclosure chooses to call the rbd_diff_from_parent interface to implement, which can return the allocation status of each data object. The allocation status includes a fully allocated state and an incompletely allocated state. Full allocation means that all the reserved space of the data object has been allocated and valid data is stored. Incomplete allocation means that some parts of the data object are not allocated, which may be because these parts are areas where data has not been written, or areas that have been erased.
[0051] Step S3012: for the multiple data objects, when it is detected that the allocation status of any data object is incompletely allocated, determine the data area where the incompletely allocated backup data of the data object is located as the erase space on the sub-disk.
[0052] Traverse the multiple data objects determined in step S3011, and check the allocation status of each data object one by one. For each data object, determine whether its allocation status is incompletely allocated. If it is found that the status of any data object is incompletely allocated, mark the data area where the backup data of the incompletely allocated data object is located as erase space. In other words, these areas do not contain valid data in the sub-disk because the user has erased them. Record the location information of the erase space (such as the ID of the data object and the start and end addresses of the unallocated area) for use in subsequent backup and restore processes.
[0053] The present disclosure can effectively determine whether there is erased space on the sub-disk, which not only improves the consistency of data, but also avoids the mistaken restoration of erased data to the content of the master disk during the recovery process, thereby improving the overall reliability. During the backup, the erased space can be accurately identified and the relevant information can be recorded, providing necessary data support for subsequent operations.
[0054] In an optional embodiment, after writing the differential data into a backup file for restoring the backup data of the sub-disk, the method further includes: determining shared data from the master disk based on the initial data of the master disk and the backup data of the sub-disk, and determining that the shared data occupies a first data area of the master disk, the shared data being data with identical content in the same data area of the master disk and the sub-disk; reading the differential data and erase information of the erase space from the backup file, and determining that the differential data occupies a second data area of the sub-disk; writing the shared data into a data area of the restoration disk corresponding to the first data area, and writing the differential data into a data area of the restoration disk corresponding to the second data area, the restoration disk being a blank disk having the same capacity as the master disk; determining a historical erase operation of the sub-disk based on the erase information, the historical erase operation being performed on the erase space of the sub-disk; and performing an erase operation corresponding to the historical erase operation on the restoration disk.
[0055] See also Figure 5 The right branch, when restoring the sub-disk in this embodiment, writes the difference data into the backup file for restoring the sub-disk. Similar to the data restoration method described above, the shared data is determined from the mother disk. The previously recorded difference data and the erase information of the erase space are read from the backup file.
[0056] During the restoration process, the shared data is written to the portion of the restoration disk corresponding to the first data area of the master disk, and the differential data is written to the portion of the restoration disk corresponding to the second data area. In addition, the historical erasure operations of the child disk are determined based on the erasure information. The historical erasure operations refer to the operations performed on the erased space in the child disk to ensure that the user's expected state can be accurately restored during the restoration process. Finally, the erasure operations corresponding to these historical erasure operations are performed on the restoration disk, which is equivalent to replaying the erasure operations on the restoration disk to ensure that no erased data is retained in the restoration disk, thereby achieving accurate data recovery and consistency.
[0057] Through the above steps, the present disclosure can effectively manage data in the backup and restore process, ensuring that users obtain the correct state when restoring.
[0058] In an optional embodiment, the step of writing the differential data into a backup file for restoring the backup data of the child disk comprises: determining the capacity of the mother disk and the historical minimum capacity of the child disk; determining the size of the overlapping space between the mother disk and the child disk based on the capacity of the mother disk and the historical minimum capacity of the child disk; judging whether the capacity of the mother disk is consistent with the size of the overlapping space; and if the capacity of the mother disk is inconsistent with the size of the overlapping space, recording the data of the size of the overlapping space, and writing the differential data and the data of the size of the overlapping space into the backup file.
[0059] In the related art, after a sub-disk is shrunk, if the user performs an expansion operation on it, it may not be possible to accurately identify which data is valid and which data is erased or unallocated. Since the shrinking operation will release part of the space, resulting in changes in the original data structure, data inconsistency may occur after the expansion. For example, the space originally released during the shrinking process may be mistaken for valid data after the expansion, resulting in erroneous data being read during recovery. In order to solve the above problem, the present disclosure proposes recording the overlapping space to a backup file for subsequent data restoration.
[0060] For details, see Figure 5 The left branch determines the total capacity of the mother disk and the historical minimum capacity of the child disk. The historical minimum capacity refers to the minimum storage capacity reached by the child disk during its life cycle, which changes due to data modification and deletion. The size of the overlapping space between them is determined based on the capacity of the mother disk and the historical minimum capacity of the child disk. The overlapping space refers to the same data area in the mother disk and the child disk. Determine whether the total capacity of the mother disk is consistent with the calculated size of the overlapping space. If the capacity of the mother disk is inconsistent with the overlapping space, it means that there may be a risk of data inconsistency or omission during the backup process. At this time, the size of the overlapping space is recorded and the data of the size of the overlapping space is stored in the backup file. Finally, the difference data and the recorded data of the size of the overlapping space are written to the backup file together.
[0061] Through the above steps, the relationship between the master disk and the child disk can be effectively managed, the problem of scaling the child disk and then expanding it can be solved, data redundancy and inconsistency can be avoided, and the efficiency and accuracy of backup and restore can be improved. This not only improves resource utilization, but also enhances the reliability of data recovery.
[0062] In an optional embodiment, after writing the differential data into a backup file for restoring the backup data of the sub-disk, the method further includes: determining shared data from the master disk based on the initial data of the master disk and the backup data of the sub-disk, and determining that the shared data occupies a first data area of the master disk, wherein the shared data is data having the same content in the same data area of the master disk and the sub-disk; checking whether data on the size of the overlapping space is recorded in the backup file; if data on the size of the overlapping space is recorded in the backup file, reading data on the differential data and the size of the overlapping space from the backup file, and determining that the differential data occupies a second data area of the sub-disk; performing a shrinking operation on the restoration disk based on the data on the size of the overlapping space, adjusting the capacity of the restoration disk to be consistent with the size of the overlapping space, wherein the restoration disk before performing the shrinking operation is a blank disk having a capacity consistent with that of the master disk; writing the shared data into a data area of the restoration disk corresponding to the first data area after the shrinking operation is performed, and writing the differential data into a data area of the restoration disk corresponding to the second data area after the shrinking operation is performed.
[0063] Similar to step S201 and step S202, the same steps are not described here. Figure 5 On the right branch, if the backup file records the size of the overlapped space, the difference data and the size of the overlapped space will be read from the backup file. The shared data is written to the first data area of the restored disk after the shrinking operation, and the difference data is written to the second data area of the restored disk after the shrinking operation. The initial capacity of the restored disk is the same as that of the master disk, but when the shrinking operation is performed, it is adjusted to the size of the overlapped space to ensure that the capacity of the restored disk contains only valid data. Assume that the capacity of the master disk is 5G and the overlapped space size is 3G. Assume that the initial data of the master disk is [A, B, C, D, E], and the backup data of the child disk is [A, B, X, D, Y]. In this example, A, B, D are shared data, the overlapped space size is 3 (i.e. A, B, D), and the difference data is [X, Y]. After the shrinking operation is performed, the original 5G restored disk will be adjusted to 3G. Write the shared data [A, B, D] to the corresponding first data area. Write the difference data [X, Y] to the corresponding second data area. Finally, the restored disk data after shrinking is [A, B, X] (assuming D is omitted and only the overlapping part is retained).
[0064] Through the above steps, the shared data and differential data between the parent disk and the child disk are effectively managed, and the consistency and integrity of the data are ensured during the process of shrinking and expanding the capacity, ensuring that no data loss or error will occur during the recovery process, thereby improving the reliability of data recovery.
[0065] Figure 6 is a structural block diagram of a data backup device provided by an embodiment of the present disclosure, such as Figure 6 As shown, the device comprises: The acquisition module 401 is used to acquire the initial data of the mother disk and the backup data of the child disk cloned from the mother disk; A determination module 402, configured to determine difference data from the child disk according to the initial data of the mother disk and the backup data of the child disk, wherein the difference data is data having different contents in the same data area between the child disk and the mother disk; The backup module 403 is used to write the difference data into a backup file used to restore the backup data of the sub-disk.
[0066] In an optional embodiment, the device further comprises: a first shared data determination module, configured to determine shared data from the mother disk according to the initial data of the mother disk and the backup data of the child disk, and determine that the shared data occupies a first data area of the mother disk, wherein the shared data is data with the same content in the same data area of the mother disk and the child disk; A first difference data determination module, configured to read the difference data from the backup file and determine that the difference data occupies the second data area of the sub-disk; The first writing module is used to write the shared data into a data area of the restoration disk corresponding to the first data area, and to write the difference data into a data area of the restoration disk corresponding to the second data area, wherein the restoration disk is a blank disk having a capacity consistent with that of the master disk.
[0067] In an optional implementation, the backup module includes: an erase space determination submodule, used to determine whether there is erase space on the sub-disk, the erase space being an erased data area in the sub-disk; The first writing submodule is used for writing the erasure information of the erase space and the difference data into the backup file when there is erase space on the sub-disk.
[0068] In an optional implementation, the erase space determination submodule includes: A first determining unit, configured to determine a plurality of data objects corresponding to the backup data of the sub-disk; A determination unit, configured to determine the allocation status of each of the plurality of data objects; The second determining unit is configured to determine, for the plurality of data objects, when it is detected that the allocation status of any data object is incompletely allocated, a data area where the incompletely allocated backup data of the data object is located as the erase space on the sub-disk.
[0069] In an optional embodiment, the device further comprises: a second shared data determination module, configured to determine shared data from the mother disk according to the initial data of the mother disk and the backup data of the child disk, and determine that the shared data occupies a first data area of the mother disk, wherein the shared data is data with the same content in the same data area of the mother disk and the child disk; A second difference data determination module, configured to read the difference data and erase information of the erase space from the backup file, and determine that the difference data occupies the second data area of the sub-disk; A second writing module is used to write the shared data into a data area of the restoration disk corresponding to the first data area, and write the difference data into a data area of the restoration disk corresponding to the second data area, wherein the restoration disk is a blank disk with the same capacity as the master disk; a historical erasure operation determination module, configured to determine a historical erasure operation of the sub-disk according to the erasure information, wherein the historical erasure operation is performed on an erase space of the sub-disk; The erasing module is used to perform an erasing operation corresponding to the historical erasing operation on the restoration disk.
[0070] In an optional implementation, the backup module includes: A capacity determination submodule, used to determine the capacity of the mother disk and the historical minimum capacity of the child disk; an overlap size determination submodule, used to determine the size of the overlap space between the mother disk and the child disk according to the capacity of the mother disk and the historical minimum capacity of the child disk; A capacity determination submodule, used to determine whether the capacity of the mother disk is consistent with the size of the overlapping space; The second writing submodule is used to record the data of the size of the overlapping space when the capacity of the mother disk is inconsistent with the size of the overlapping space, and write the difference data and the data of the size of the overlapping space into the backup file.
[0071] In an optional embodiment, the device further comprises: a third shared data determination module, configured to determine shared data from the mother disk according to the initial data of the mother disk and the backup data of the child disk, and determine that the shared data occupies a first data area of the mother disk, wherein the shared data is data having the same content in the same data area of the mother disk and the child disk; Check whether the backup file contains data on the size of the overlapping space; A third difference data determination module is used for reading the difference data and the data of the size of the overlapped space from the backup file when the data of the size of the overlapped space is recorded in the backup file, and determining that the difference data occupies the second data area of the sub-disk; A shrinking module, used for performing a shrinking operation on the restoration disk according to the data of the size of the overlapping space, adjusting the capacity of the restoration disk to be consistent with the size of the overlapping space, wherein the restoration disk before the shrinking operation is a blank disk with a capacity consistent with that of the mother disk; The third writing submodule is used to write the shared data into a data area corresponding to the first data area of the restored disk after the shrinking operation is performed, and to write the differential data into a data area corresponding to the second data area of the restored disk after the shrinking operation is performed.
[0072] An embodiment of the present disclosure also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, the various processes in the above-mentioned data backup method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0073] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, each process in the above-mentioned data backup method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the embodiments can be referred to each other.
[0074] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, devices, electronic devices, and storage media. Therefore, the embodiments of the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present disclosure may take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0075] The embodiments of the present disclosure are described with reference to the flowcharts and / or block diagrams of the methods and devices according to the embodiments of the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing terminal device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device, so that a series of operation steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable terminal device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0076] Although the preferred embodiments of the present disclosure have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present disclosure.
[0077] Finally, it should be noted that, in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "include..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements. The above is a detailed introduction to a data backup method, device, electronic device and storage medium provided by the present disclosure. The principle and implementation method of the present disclosure are explained in this article using specific examples. The description of the above embodiments is only used to help understand the method and its core idea of the present disclosure; at the same time, for those of ordinary skill in the art, according to the idea of the present disclosure, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present disclosure.
Claims
1. A data backup method, characterized in that: The method comprises: Acquire the initial data of the mother disk and the backup data of the child disk cloned from the mother disk; Determine differential data from the sub-disk according to the initial data of the master disk and the backup data of the sub-disk, wherein the differential data is data with different contents in the same data area between the sub-disk and the master disk; The differential data is written into a backup file for restoring the backup data of the sub-disk.
2. The method according to claim 1, characterized in that After writing the difference data into a backup file for restoring the backup data of the sub-disk, the method further comprises: Determine shared data from the master disk according to the initial data of the master disk and the backup data of the child disk, and determine that the shared data occupies a first data area of the master disk, wherein the shared data is data with the same content in the same data area of the master disk and the child disk; Reading the difference data from the backup file, and determining that the difference data occupies the second data area of the sub-disk; The shared data is written into a data area of the restoration disk corresponding to the first data area, and the differential data is written into a data area of the restoration disk corresponding to the second data area. The restoration disk is a blank disk with a capacity consistent with that of the master disk.
3. The method according to claim 1, characterized in that The step of writing the difference data into a backup file for restoring the backup data of the sub-disk comprises: Determine whether there is erase space on the sub-disk, the erase space being an erased data area in the sub-disk; In the case that there is erased space on the sub-disk, the erased information of the erased space and the difference data are written into the backup file.
4. The method according to claim 3, characterized in that Determining whether there is erase space on the sub-disk includes: Determine a plurality of data objects corresponding to the backup data of the sub-disk; Determining an allocation status of each of the plurality of data objects; For the multiple data objects, when it is detected that the allocation status of any data object is incompletely allocated, the data area where the incompletely allocated backup data of the data object is located is determined as the erase space on the sub-disk.
5. The method according to claim 3, characterized in that: After writing the difference data into a backup file for restoring the backup data of the sub-disk, the method further comprises: Determine shared data from the master disk according to the initial data of the master disk and the backup data of the child disk, and determine that the shared data occupies a first data area of the master disk, wherein the shared data is data with the same content in the same data area of the master disk and the child disk; Reading the differential data and erasure information of the erased space from the backup file, and determining that the differential data occupies the second data area of the sub-disk; Writing the shared data into a data area of the restoration disk corresponding to the first data area, and writing the difference data into a data area of the restoration disk corresponding to the second data area, wherein the restoration disk is a blank disk with the same capacity as the master disk; Determining, according to the erasure information, a historical erasure operation of the sub-disk, wherein the historical erasure operation is performed on an erase space of the sub-disk; An erasing operation corresponding to the historical erasing operation is performed on the restoration disk.
6. The method according to claim 1, characterized in that The step of writing the difference data into a backup file for restoring the backup data of the sub-disk comprises: Determining the capacity of the mother disk and the historical minimum capacity of the child disk; Determining the size of the overlapping space between the master disk and the sub-disk according to the capacity of the master disk and the historical minimum capacity of the sub-disk; Determining whether the capacity of the master disk is consistent with the size of the overlapping space; In the case that the capacity of the master disk is inconsistent with the size of the overlapping space, data of the size of the overlapping space is recorded, and the difference data and the data of the size of the overlapping space are written into the backup file.
7. The method according to claim 6, characterized in that After writing the difference data into a backup file for restoring the backup data of the sub-disk, the method further comprises: Determine shared data from the master disk according to the initial data of the master disk and the backup data of the child disk, and determine that the shared data occupies a first data area of the master disk, wherein the shared data is data with the same content in the same data area of the master disk and the child disk; Check whether the backup file contains data on the size of the overlapping space; In the case where the data of the size of the overlapping space is recorded in the backup file, reading the difference data and the data of the size of the overlapping space from the backup file, and determining that the difference data occupies the second data area of the sub-disk; According to the data of the size of the overlapping space, a capacity reduction operation is performed on the restoration disk to adjust the capacity of the restoration disk to be consistent with the size of the overlapping space, and the restoration disk before the capacity reduction operation is a blank disk with a capacity consistent with that of the mother disk; The shared data is written into a data area of the restored disk after the shrinking operation corresponding to the first data area, and the differential data is written into a data area of the restored disk after the shrinking operation corresponding to the second data area.
8. A data backup device, characterized in that: The device comprises: An acquisition module, used for acquiring the initial data of the mother disk and the backup data of the child disk cloned from the mother disk; a determination module, configured to determine difference data from the child disk according to the initial data of the mother disk and the backup data of the child disk, wherein the difference data is data having different contents in the same data area between the child disk and the mother disk; The backup module is used to write the difference data into a backup file used to restore the backup data of the sub-disk.
9. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.