A computer hard disk data snapshot and recovery method, device and equipment

By using empty files to establish logical hard disk and write operation records in computer hard disk data recovery, the problem of traditional backup and recovery methods requiring abort the operating system's read and write is solved, and snapshots and recovery without aborting read and write are realized, reducing space occupation and improving applicability.

CN119668938BActive Publication Date: 2025-08-22XIAN QIANLONG HUITENG TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411752651.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-02
Publication Date
2025-08-22
Estimated Expiration
2044-12-02

AI Technical Summary

Technical Problem

In the prior art, when recovering computer hard disk data, traditional backup and recovery methods require aborting the reading and writing of the operating system, and the space occupies a large amount of space when recording the actual state of the computer hard disk, making it difficult to apply to uninterrupted production scenarios.

Method used

Use empty files to establish logical hard disk and write operation records based on sector-sized block devices to form snapshot files, and record the computer hard disk status through snapshot files, so as to achieve no need to abort the operating system's read and write, and only record the target position of the write operation during the write operation, reducing space occupation.

Benefits of technology

It realizes data snapshots and recovery without aborting the operating system's read and write, reducing space usage and improving applicability and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119668938B_ABST
    Figure CN119668938B_ABST
Patent Text Reader

Abstract

The present invention discloses a computer hard disk data snapshot and recovery method, device, and apparatus, and relates to the field of computer technology. For a data snapshot request, the present invention uses a hole file to establish a logical hard disk corresponding to the computer hard disk and an empty write operation record when no snapshot file exists, forming a snapshot file at the snapshot time point. Otherwise, the latest snapshot file is used as the snapshot file at the current time point. When a write operation request is received, only the write operation is recorded through the snapshot file at the write operation request time point, without recording additional content. When a read operation request is received, the storage location of the data content can be determined and read based on the write operation record of the latest snapshot file. When a data recovery request for a target time point is received, the snapshot file at the time corresponding to the data recovery request can be updated to the snapshot file at the target time point. The present invention does not need to suspend the reading and writing of the operating system during data backup or recovery, thereby improving applicability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method, device and equipment for snapshot and recovery of computer hard disk data. Background Art

[0002] Currently, when a computer is damaged (eg, due to system instability, hacker attack, virus damage, misoperation, etc.), it is usually necessary to recover computer hard disk data based on pre-backed-up data.

[0003] In the existing technology, traditional backup and recovery methods mostly copy the valid data of the target partition to the backed-up partition. During recovery, the data is read from the backup partition to overwrite the data of the partition to be restored. Other methods use the mapping relationship between logical addresses and physical addresses to save the actual state of the computer hard disk data at the time of snapshot or after the data is written.

[0004] However, traditional backup and recovery methods often require suspending the operating system's read and write operations during data backup or recovery, making them difficult to apply in scenarios where production processes cannot be interrupted. While recording the actual state of a computer hard drive using a mapping relationship between logical and physical addresses typically requires recording the mapping relationship across the entire hard drive, even though actual data writes typically only to a small portion of the space. This requires a significant amount of space to store the actual state of the hard drive. Summary of the Invention

[0005] Based on this, it is necessary to provide a computer hard disk data snapshot and recovery method, device and equipment to address the above technical problems.

[0006] The present invention adopts the following technical solutions:

[0007] The present invention provides a computer hard disk data snapshot and recovery method, comprising:

[0008] When a data snapshot request is received, if a snapshot file already exists, the latest snapshot file is used as the snapshot file at the current time point; otherwise, a hole file is used to create a logical hard disk corresponding to the computer hard disk and an empty write operation record in a block device of sector size to form a snapshot file at the current time point;

[0009] Upon receiving a write operation request, a snapshot file is created at the time of the write operation request using a hole file, a write operation is performed based on the logical hard disk of the snapshot file at the time of the write operation request according to the target location of the write operation request, and a write operation record of the snapshot file at the time of the write operation request is formed according to the write operation;

[0010] When a read operation request is received, the system queries the latest snapshot file to determine whether the data content at the target location of the read operation request is stored in the snapshot file, so as to read the data from the snapshot file or the computer hard disk.

[0011] After receiving a data recovery request for a target time point, the latest snapshot file is updated to the snapshot file at the target time point.

[0012] Optionally, performing a write operation on the logical hard disk based on the snapshot file at the write operation request time point, and forming a write operation record of the snapshot file at the write operation request time point according to the write operation, specifically includes:

[0013] Writing the data content corresponding to the write operation request into the target location corresponding to the write operation request of the logical hard disk of the snapshot file at the time of the write operation request;

[0014] Form a record of the current write operation according to the target location of the write operation request and the time point of the write operation request;

[0015] The content at the target location of the write operation request on the write operation record before responding to the write operation request is replaced with the record of the current write operation to form a write operation record of the snapshot file at the time point of the write operation request.

[0016] Optionally, querying from the latest snapshot file whether the data content of the target location of the read operation request is stored in the snapshot file, so as to read the data from the snapshot file or the computer hard disk, specifically includes:

[0017] Query the write operation record in the latest snapshot file to determine whether the data content at the target location corresponding to the read operation request is stored in the snapshot file;

[0018] If so, determining the target time point in the record of the write operation of the data content at the target location corresponding to the read operation request, and reading the data at the target location corresponding to the read operation request from the logical hard disk of the snapshot file at the target time point;

[0019] If not, data is read from the target location corresponding to the read operation request in the computer hard disk.

[0020] Optionally, the method of using a hole file to establish a logical hard disk corresponding to the computer hard disk and a vacant write operation record in a block device of sector size to form a snapshot file at the current time point specifically includes:

[0021] When a data snapshot request is received, the used sectors in the computer hard disk are scanned, and a hole file is used to record whether each block device is used in units of sector-sized block devices, thereby obtaining a data block mark table at the current time point;

[0022] A hole file is used to create an empty write operation record for recording whether a write operation is performed on each device in the computer hard disk at the current time point;

[0023] Establishing a logical hard disk corresponding to the computer hard disk in units of sector-sized block devices, and determining an address mapping relationship table between the logical hard disk and the computer hard disk at a current time point;

[0024] A snapshot area for storing data content is established using a hole file, and the snapshot area is combined with the data block mark table, write operation record and address mapping relationship table at the current time point to form a snapshot file at the current time point.

[0025] Optionally, performing the write operation based on the logical hard disk of the snapshot file at the current time point according to the target location of the write operation request, and forming a write operation record of the snapshot file at the current time point according to the current write operation, specifically includes:

[0026] determining whether the target location corresponding to the write operation request on the computer hard disk is in use according to a usage status of the target location corresponding to the write operation request in the data block mark table of the snapshot file before responding to the write operation request;

[0027] If so, the data content corresponding to the write operation request is written into the free location of the snapshot area, and the address mapping relationship between the target location corresponding to the write operation request and the free location in the logical hard disk is updated based on the address mapping relationship table before responding to the write operation request, and an address mapping relationship table after responding to the write operation request is created; and a write operation record after responding to the write operation request is generated based on the free location;

[0028] If not, writing the data content corresponding to the write operation request to the target location corresponding to the write operation request in the computer hard disk; and generating a write operation record after responding to the write operation request according to the target location corresponding to the write operation request;

[0029] A data block marking table after responding to the write operation request is generated according to the write operation record after responding to the write operation request and the data block marking table before responding to the write operation request.

[0030] Optionally, a block device filter driver is provided between the computer file system and the computer hard disk drive, and the block device filter driver is used to intercept all calls to the computer hard disk drive and call the driver of the block device mapped by the computer hard disk after address mapping based on the snapshot file.

[0031] The present invention provides a computer hard disk data snapshot and recovery device, comprising:

[0032] The snapshot module is configured to, upon receiving a data snapshot request, use the latest snapshot file as the snapshot file at the current time point if a snapshot file already exists; otherwise, use an empty file to create a logical hard disk corresponding to the computer hard disk and an empty write operation record in units of sector-sized block devices to form a snapshot file at the current time point;

[0033] a write mapping module configured to, upon receiving a write operation request, create a snapshot file at the time of the write operation request using a hole file, perform a write operation based on the logical hard disk of the snapshot file at the time of the write operation request according to a target location of the write operation request, and generate a write operation record of the snapshot file at the time of the write operation request according to the write operation;

[0034] The read mapping module is used to query the latest snapshot file when receiving a read operation request whether the data content of the target location of the read operation request is stored in the snapshot file, so as to read the data from the snapshot file or the computer hard disk;

[0035] The recovery module is used to update the latest snapshot file to the snapshot file at the target time point after receiving a data recovery request at the target time point.

[0036] The present invention provides a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the computer hard disk data snapshot and recovery method is implemented.

[0037] The present invention provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the computer hard disk data snapshot and recovery method is implemented.

[0038] At least one of the above technical solutions adopted by the present invention can achieve the following beneficial effects:

[0039] In response to data snapshot requests, if no snapshot file exists, the present invention uses a hole file to create a logical hard disk corresponding to the computer hard disk and a vacant write operation record, forming a snapshot file at the snapshot time. This allows the snapshot file at the snapshot time to record the computer hard disk status at that time without suspending the operating system's reading and writing. Otherwise, the latest snapshot file is used as the snapshot file at the current time.

[0040] When a write operation request is received, the target space corresponding to the write operation is usually small compared to the space of the entire computer hard disk. Therefore, a hole file can be used to create a logical hard disk at the time of the write operation request, and the data content of the write operation request is written at the target location of the write operation. For the logical hard disk formed by the hole file, only the target location of the write operation is allocated space, and the remaining locations exist in the form of holes and do not occupy actual storage space. A write operation record of the snapshot file at the current time point is further formed based on the current write operation. Combined with the logical hard disk and the write operation record after responding to the write operation, only the write operation is recorded, without the need to record additional content, thereby reducing space occupancy.

[0041] When a read operation request is received, the data content corresponding to the read operation can be determined to be stored in the snapshot file or in the computer hard disk based on the latest write operation record of the snapshot file. When it is stored in the snapshot file, since it is stored at the target location of the read operation in the logical hard disk, the reading speed is equivalent to reading from the computer hard disk.

[0042] When a data recovery request for a target time point is received, since the status is recorded through the snapshot file at the corresponding time point each time data is written to the computer hard disk after the data snapshot, the snapshot file at the data request time point can be directly replaced with the snapshot file at the target time point without suspending the reading and writing of the operating system, thereby improving applicability. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0044] Figure 1 A schematic flow chart of a computer hard disk data snapshot and recovery method provided by the present invention;

[0045] Figure 2 A schematic diagram of a block device filter driver provided by the present invention;

[0046] Figure 3 A real-time snapshot of data provided by the present invention Figure 1 ;

[0047] Figure 4 A schematic diagram of a data recovery process provided by the present invention;

[0048] Figure 5 The present invention provides a method for backing up the current time point of a computer hard disk based on the hard disk sector and snapshot file transfer relationship diagram Figure 1 ;

[0049] Figure 6 A real-time snapshot of data provided by the present invention Figure 2 ;

[0050] Figure 7 The present invention provides a method for backing up the current time point of a computer hard disk based on the hard disk sector and snapshot file transfer relationship diagram Figure 2 ;

[0051] Figure 8 A schematic diagram of a computer hard disk data snapshot and recovery device provided by the present invention;

[0052] Figure 9 A schematic diagram of a computer device for implementing a snapshot and recovery method of computer hard disk data provided by the present invention. DETAILED DESCRIPTION

[0053] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with specific embodiments of the present invention and corresponding drawings. Obviously, the embodiments described are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0054] At present, there is still a blank in the real-time backup and recovery technology of domestic computers (chips & operating systems). Domestic platforms are quite different and usually incompatible. Domestic operating systems are also constantly being upgraded and improved, and software must also be adapted and developed for different domestic platforms and domestic systems. Currently, it is limited by the incompatibility of hardware platforms, so only software can be compatible with various hardware platforms.

[0055] The technical solutions provided by various embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0056] Figure 1 The present invention is a flowchart of a method for snapshotting and restoring computer hard disk data, which specifically includes the following steps:

[0057] S101: When a data snapshot request is received, if a snapshot file already exists, the latest snapshot file is used as the snapshot file at the current time point; otherwise, an empty file is used to create a logical hard disk corresponding to the computer hard disk and an empty write operation record in units of sector-sized block devices to form a snapshot file at the current time point.

[0058] S102: When a write operation request is received, a snapshot file at the time of the write operation request is created using a hole file, a write operation is performed based on the logical hard disk of the snapshot file at the time of the write operation request according to the target location of the write operation request, and a write operation record of the snapshot file at the time of the write operation request is formed according to the write operation.

[0059] S103: When a read operation request is received, query the latest snapshot file to see whether the data content of the target location of the read operation request is stored in the snapshot file, so as to read the data from the snapshot file or the computer hard disk.

[0060] S104: After receiving the data recovery request for the target time point, the latest snapshot file is updated as the snapshot file at the target time point.

[0061] For the sake of convenience, the following description will only be based on the computer as the execution subject. The computer mentioned in the present invention can be a server set up on the business platform, or a device such as a desktop computer or a laptop computer that can execute the solution of the present invention.

[0062] Typically, a computer file system performs specific operations on the computer hard disk through the computer hard disk driver. Taking Kylin or Unisys Operating System (UOS) as an example, its block device filter driver is located between the file system driver and the computer hard disk driver. The block device filter driver will intercept all calls to the computer hard disk driver, such as Figure 2 As shown, Figure 2 This is a schematic diagram of a block device filter driver in the present invention.

[0063] On the Unified Extensible Firmware Interface (UEFI) platform, the original BlockIo protocol can be replaced by registering a new EFI_BLOCK_IO_PROTOCOL or EFI_BLOCK_IO2_PROTOCOL (BlockIo for short). A BlockIo filter driver is added to the new BlockIo protocol function interface and the original BlockIo function interface. The filter driver captures calls to block devices, remaps them, and then calls the block devices mapped to the computer hard disk.

[0064] Based on this, in one or more embodiments of the present invention, a computer can capture calls to block devices through a filter driver and remap them based on a snapshot file. The snapshot file can include using a hole file to create a logical hard disk corresponding to the computer's hard disk using sector-sized block devices as units, and using the hole file to create a write operation record corresponding to the computer's hard disk using sector-sized block devices as units. The computer can use the snapshot file formed by the logical hard disk and the write operation record to record a data snapshot or the state of the computer's hard disk when data is written.

[0065] Specifically, the snapshot file may include a file header and a block data area (logical hard disk). The size of each block in the block data area may be the size of a sector in a computer hard disk (usually 512 bytes or 4 KB).

[0066] The location of the block device in the computer hard disk in the logical hard disk of the snapshot file = the address corresponding to the snapshot file header + the address corresponding to the block device on the computer hard disk;

[0067] Snapshot file header = file snapshot information (including snapshot time, snapshot name, snapshot ID, etc.) + write operation record.

[0068] The write operation record may be used to record the real physical address of the data in the logical hard disk written into the snapshot file at a certain moment, so as to indicate that the data at the real physical address at a certain moment is saved by the snapshot file.

[0069] When a data snapshot request is received, the computer determines whether a snapshot file currently exists. If so, the latest snapshot file is used as the snapshot file for the current point in time. Otherwise, a hole file is used to create a logical hard disk corresponding to the computer's hard disk and a vacant write operation record using sector-sized block devices as units, forming the snapshot file for the current point in time.

[0070] Since the purpose of a data snapshot is to record the computer hard drive's data storage status at the time of the snapshot, and the snapshot file is used to record the computer hard drive's data storage status at the time the snapshot file was created, when a data snapshot is first taken, an empty snapshot file may be created, indicating that there is no data protected and recorded by the snapshot file at that moment. When the computer reads data, it can read the data directly from the computer hard drive.

[0071] After the first data snapshot, in one or more embodiments of the present invention, if the computer receives a write operation request to a target location in the computer hard disk, based on the above-mentioned snapshot file format, a snapshot file at the time of the write operation request can be created using an empty file, and the data content corresponding to the write operation request is written to the target location corresponding to the write operation request in the logical hard disk of the snapshot file at the time of the write operation request, and a record of the current write operation is formed according to the target location of the write operation request and the time of the write operation request, so as to replace the content at the target location of the write operation request on the write operation record before responding to the write operation request with the record of the current write operation, thereby forming a write operation record of the snapshot file at the time of the write operation request.

[0072] Assume that after the initial data snapshot, the first write request is received, with the target location being A. After executing the write request based on the snapshot file, the logical hard disk allocates only the storage space corresponding to location A in the snapshot file at the time of the write request and writes the data corresponding to the write request. All other locations on the corresponding block devices on the computer hard disk remain empty and do not occupy actual storage space. Similarly, the write operation record only allocates storage space corresponding to location A and writes the write operation record.

[0073] Assume again that a second write operation request is received, with the target location being B. After executing this write operation request based on the snapshot file, the logical hard disk allocates only the storage space corresponding to the data at location B in the snapshot file at the time of the write operation request, and writes the data corresponding to the write operation request. All other locations on the computer's hard disk block remain empty and do not occupy any actual storage space. The write operation record only allocates storage space corresponding to locations A and B, and writes the write operation record to location B. Location A remains identical to the write operation record in the snapshot file at the time of the first write operation request.

[0074] When a read operation request is received, in one or more embodiments of the present invention, the computer may query the latest snapshot file to determine whether the data content of the target location of the read operation request is stored in the snapshot file, so as to read the data from the snapshot file or the computer hard disk. Specifically, the computer may query the write operation record in the latest snapshot file to determine whether the data content of the target location corresponding to the read operation request is stored in the snapshot file. If so, the target time point in the record of the write operation of the data content of the target location corresponding to the read operation request is determined, and the data is read from the logical hard disk of the snapshot file at the target time point at the target location corresponding to the read operation request. If not, the data is read from the target location corresponding to the read operation request in the computer hard disk.

[0075] Taking the above-mentioned example of receiving a read operation request for target location A after receiving the second write operation request, the server can query the write operation record of the snapshot file at the time point of the second write operation request, and based on the record time of the write operation at A in the write operation record, read the data content corresponding to the read operation request from A of the logical hard disk of the snapshot file at the corresponding time point (i.e., the time point of the first write operation request).

[0076] The response process of the above data snapshot, write operation and read operation can be referred to Figure 3 , Figure 3 This is a real-time snapshot of data in the present invention. Figure 1 .

[0077] When restoring data, the computer can traverse all snapshot files according to the target time point selected by the user, find the snapshot file at the target time point, and update the latest snapshot file to the snapshot file at the target time point, such as Figure 4 As shown, Figure 4 The figure is a schematic diagram of a data recovery process in the present invention.

[0078] Figure 5 This is a diagram of the transfer relationship between the hard disk sector and the snapshot file based on the real-time backup of the computer hard disk at the current time point in the present invention. Figure 1 The block device that the user perceives through the operating system at the current time point, and the hard disk read and write operations perceived at the current time point will first determine whether to read data from the snapshot file based on the snapshot file. The operating system will not find any difference when operating the hard disk read and write requests. Figure 5 The lower half of the file is the filter driver. The filter driver intercepts all block device accesses from the operating system during the current time period, meaning any access to physical block devices. The filter driver then performs the operation based on the current point in time, mapping the address to the latest snapshot file.

[0079] based on Figure 1 The computer hard disk data snapshot and recovery method shown in the figure uses a hole file to establish a logical hard disk corresponding to the computer hard disk and an empty write operation record for a data snapshot request, forming a snapshot file at the snapshot time point, thereby recording the computer hard disk status at the snapshot time point through the snapshot file at the snapshot time point, without suspending the reading and writing of the operating system.

[0080] When a write operation request is received after a data snapshot, the target space corresponding to the write operation is usually small relative to the space of the entire computer hard disk. Therefore, a hole file can be used to create a logical hard disk at the time of the write operation request, and the data content of the write operation request is written at the target location of the write operation. For the logical hard disk formed by the hole file, only the target location of the write operation is allocated space, and the remaining locations exist in the form of holes and do not occupy actual storage space. The write operation record of the snapshot file at the current time point is further formed according to the current write operation. Combined with the logical hard disk and the write operation record after the write operation is responded to, only the write operation is recorded, without the need to record additional content, thereby reducing space occupancy.

[0081] When a read operation request is received after the data snapshot, the write operation record of the snapshot file at the time of the read operation can be used to determine whether the data content corresponding to the read operation is stored in the snapshot file or the computer hard disk. When it is stored in the snapshot file, since it is stored at the target location of the read operation in the logical hard disk, the reading speed is equivalent to reading from the computer hard disk.

[0082] When a data recovery request for the target time point is received after a data snapshot, since the status is recorded through the snapshot file at the corresponding time point each time data is written to the computer hard disk after the data snapshot, the snapshot file at the data request time point can be directly replaced with the snapshot file at the target time point without suspending the reading and writing of the operating system, thereby improving applicability.

[0083] When applying the snapshot and recovery method of computer hard disk data provided by the present invention, it is not necessary to Figure 1 The steps are executed in the order shown. The specific execution order of the steps can be determined according to needs, and the present invention does not limit this.

[0084] Furthermore, in one or more embodiments of the present invention, the snapshot file may be in other forms.

[0085] Specifically, upon receiving a data snapshot request, if no snapshot file exists, the computer can scan the used sectors on the computer's hard disk and, using a hole file, record whether each block device is in use, using sector-sized block devices as units, thereby obtaining a data block mark table at the current point in time. The hole file is then used to establish an empty write operation record to record whether a write operation has been performed on each block device on the computer's hard disk at the current point in time. Simultaneously, a logical hard disk corresponding to the computer's hard disk is established, using sector-sized block devices as units, and an address mapping relationship table is determined between the logical hard disk and the computer's hard disk at the current point in time. Consequently, the hole file is used to establish a snapshot area for storing data content, and the snapshot area is combined with the data block mark table, write operation record, and address mapping relationship table at the current point in time to form a snapshot file at the current point in time.

[0086] For example, you can scan the valid data (data in used space) in partition file systems (NTFS, EXT4, XFS, Refs, etc.) and manage the computer hard disk as a block device based on the physical hard disk sector size (one sector). Then, based on the used block devices obtained from the scan, you can create a data block flag table to record the status of whether each block device has data, for example, a flag of 1 indicates data and a flag of 0 indicates no data.

[0087] Detailed design of snapshot file: data block mark table + write operation record + address mapping relationship table + snapshot area.

[0088] Address mapping relationship table: records the data transfer status in the block device at the current time point.

[0089] Write operation record: records the write status of the block device at the current time point. There is only one write mark table at each time point. For example, a block device marked with 1 indicates that a write operation has occurred on the block device at the current time point, and 0 indicates that no write operation has occurred at the current time point.

[0090] Correspondingly, when receiving a write operation request, the computer can determine whether the target location corresponding to the write operation request on the computer hard disk is in use based on the usage status of the target location corresponding to the write operation request in the data block mark table of the snapshot file before responding to the write operation request.

[0091] If so, the data content corresponding to the write operation request is written into the free position of the snapshot area, and based on the address mapping relationship table before responding to the write operation request, the address mapping relationship between the target position corresponding to the write operation request and the free position in the logical hard disk is updated to create an address mapping relationship table after responding to the write operation request; and a write operation record after responding to the write operation request is generated based on the free position. It can be seen that the address mapping relationship table after responding to the write operation request is based on the address mapping relationship table of the latest snapshot file at the time of the write operation request. However, it should be noted that whether it is the address mapping relationship table before responding to the write operation request or the address mapping relationship table after responding to the write operation request, only the mapping relationship of the data content written into the snapshot area is protected and recorded. The remaining positions all exist in the form of holes and do not occupy actual storage space. That is, there is no need to record the mapping relationship of the entire computer hard disk space. It is only necessary to maintain the mapping relationship of the data content written into the snapshot area to save space.

[0092] If not, the data content corresponding to the write operation request is written into the target location corresponding to the write operation request in the computer hard disk, and a write operation record after responding to the write operation request is generated according to the target location corresponding to the write operation request.

[0093] A data block marking table after responding to the write operation request is generated according to the write operation record after responding to the write operation request and the data block marking table before responding to the write operation request.

[0094] When receiving a read request for a target location on a computer's hard drive, the computer can determine whether the target location is in use based on the usage status of the location in the data block mark table of the latest snapshot file. If so, the computer then searches the address mapping table of the latest snapshot file to find the actual address of the target location on the computer's hard drive and reads the data. Alternatively, the computer can read the data from the target location on the computer's hard drive. Figure 6 This is a real-time snapshot of data in the present invention. Figure 2 , Figure 6 For specific content, please refer to the corresponding instructions above.

[0095] Furthermore, after receiving a data recovery request for a target time point after a data snapshot, the computer may update the snapshot file corresponding to the time of the data recovery request to the snapshot file of the target time point, and clean up the data in the snapshot area according to the snapshot file of the target time point.

[0096] Figure 7 This is a diagram of the transfer relationship between the hard disk sector and the snapshot file based on the real-time backup of the computer hard disk at the current time point in the present invention. Figure 2 .Depend on Figure 7 As can be seen, the filter driver can intercept all block device accesses of the operating system in the current time period, that is, any access to the physical block device. The filter driver then performs the operation based on the current time point after performing address mapping based on the latest snapshot file.

[0097] The above is a snapshot and recovery method of computer hard disk data provided by one or more embodiments of the present invention. Based on the same idea, the present invention also provides a corresponding snapshot and recovery device for computer hard disk data, such as Figure 8 shown.

[0098] Figure 8 A schematic diagram of a computer hard disk data snapshot and recovery device provided by the present invention, comprising:

[0099] The snapshot module 201 is configured to, upon receiving a data snapshot request, use the latest snapshot file as the snapshot file at the current time point if a snapshot file already exists; otherwise, use a hole file to create a logical hard disk corresponding to the computer hard disk and a vacant write operation record in a sector-sized block device unit to form a snapshot file at the current time point;

[0100] The write mapping module 202 is configured to, upon receiving a write operation request, create a snapshot file at the time of the write operation request using a hole file, perform a write operation based on the logical hard disk of the snapshot file at the time of the write operation request according to the target location of the write operation request, and generate a write operation record of the snapshot file at the time of the write operation request based on the write operation;

[0101] The read mapping module 203 is configured to, upon receiving a read operation request, query the latest snapshot file to determine whether the data content at the target location of the read operation request is stored in the snapshot file, so as to read the data from the snapshot file or the computer hard disk;

[0102] The recovery module 204 is configured to update the snapshot file at the time corresponding to the data recovery request to the snapshot file at the target time point upon receiving a data recovery request at the target time point after the data snapshot is taken.

[0103] The specific definitions of the computer hard disk data snapshot and recovery device can be found in the definitions of the computer hard disk data snapshot and recovery method described above and will not be repeated here. Each module in the aforementioned computer hard disk data snapshot and recovery device can be implemented in whole or in part via software, hardware, or a combination thereof. Each of the aforementioned modules can be embedded in or independent of a processor in a computer device in hardware form, or can be stored in a computer device memory in software form, so that the processor can call and execute the corresponding operations of each of the aforementioned modules.

[0104] The present invention also provides a computer-readable storage medium, which stores a computer program, which can be used to execute the above Figure 1 Provides a snapshot and recovery method for computer hard disk data.

[0105] The present invention also provides Figure 9 The structural diagram of the computer equipment shown in FIG. Figure 9 As shown in the figure, at the hardware level, the computer device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory. Of course, it may also include other hardware required for the business. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to achieve the above Figure 1 Provides a snapshot and recovery method for computer hard disk data.

[0106] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0107] The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of the present invention.

Claims

1. A computer hard disk data snapshot and recovery method, characterized in that: include: When a data snapshot request is received, if a snapshot file already exists, the latest snapshot file is used as the snapshot file at the current time point; Otherwise, a hollow file is used to create a logical hard disk corresponding to the computer hard disk and an empty write operation record in a block device of sector size, forming a snapshot file at the current time point; Upon receiving a write operation request, a snapshot file at the time of the write operation request is created using a hole file, and data content corresponding to the write operation request is written to the target location corresponding to the write operation request of the logical hard disk of the snapshot file at the time of the write operation request according to the target location of the write operation request; a record of the current write operation is formed according to the target location of the write operation request and the time of the write operation request; the content at the target location of the write operation request on the write operation record before the response to the write operation request is replaced with the record of the current write operation, thereby forming a write operation record of the snapshot file at the time of the write operation request; When a read operation request is received, the system queries the latest snapshot file to determine whether the data content at the target location of the read operation request is stored in the snapshot file, so as to read the data from the snapshot file or the computer hard disk. After receiving a data recovery request for a target time point, the latest snapshot file is updated to the snapshot file at the target time point.

2. The computer hard disk data snapshot and recovery method according to claim 1, wherein: The step of querying the latest snapshot file to determine whether the data content at the target location of the read operation request is stored in the snapshot file, so as to read the data from the snapshot file or the computer hard disk, specifically includes: Query the write operation record in the latest snapshot file to determine whether the data content at the target location corresponding to the read operation request is stored in the snapshot file; If so, determining the target time point in the record of the write operation of the data content at the target location corresponding to the read operation request, and reading the data at the target location corresponding to the read operation request from the logical hard disk of the snapshot file at the target time point; If not, data is read from the target location corresponding to the read operation request in the computer hard disk.

3. The computer hard disk data snapshot and recovery method according to claim 1, wherein: The method of using a hole file to establish a logical hard disk corresponding to the computer hard disk and a vacant write operation record in a block device of sector size to form a snapshot file at the current time point specifically includes: When a data snapshot request is received, the used sectors in the computer hard disk are scanned, and a hole file is used to record whether each block device is used in units of sector-sized block devices, thereby obtaining a data block mark table at the current time point; A hole file is used to create an empty write operation record for recording whether a write operation is performed on each device in the computer hard disk at the current time point; Establishing a logical hard disk corresponding to the computer hard disk in units of sector-sized block devices, and determining an address mapping relationship table between the logical hard disk and the computer hard disk at a current time point; A snapshot area for storing data content is established using a hole file, and the snapshot area is combined with the data block mark table, write operation record and address mapping relationship table at the current time point to form a snapshot file at the current time point.

4. The computer hard disk data snapshot and recovery method according to claim 3, wherein: The step of performing a write operation based on a logical hard disk of the snapshot file at the current time point according to a target location of the write operation request and forming a write operation record of the snapshot file at the current time point according to the current write operation specifically includes: determining whether the target location corresponding to the write operation request on the computer hard disk is in use according to a usage status of the target location corresponding to the write operation request in the data block mark table of the snapshot file before responding to the write operation request; If so, the data content corresponding to the write operation request is written into the free location of the snapshot area, and the address mapping relationship between the target location corresponding to the write operation request and the free location in the logical hard disk is updated based on the address mapping relationship table before responding to the write operation request, and an address mapping relationship table after responding to the write operation request is created; and a write operation record after responding to the write operation request is generated based on the free location; If not, writing the data content corresponding to the write operation request to the target location corresponding to the write operation request in the computer hard disk; and generating a write operation record after responding to the write operation request according to the target location corresponding to the write operation request; A data block marking table after responding to the write operation request is generated according to the write operation record after responding to the write operation request and the data block marking table before responding to the write operation request.

5. The computer hard disk data snapshot and recovery method according to claim 1, wherein: A block device filter driver is provided between the computer file system and the computer hard disk driver. The block device filter driver is used to intercept all calls to the computer hard disk driver and call the driver of the block device mapped by the computer hard disk after performing address mapping based on the snapshot file.

6. A computer hard disk data snapshot and recovery device, characterized in that: include: The snapshot module is used to, when receiving a data snapshot request, use the latest snapshot file as the snapshot file at the current time point if a snapshot file already exists; Otherwise, a hollow file is used to create a logical hard disk corresponding to the computer hard disk and an empty write operation record in a block device of sector size, forming a snapshot file at the current time point; The write mapping module is configured to, upon receiving a write operation request, create a snapshot file at the time of the write operation request using a hole file, write the data content corresponding to the write operation request to the target location corresponding to the write operation request of the logical hard disk of the snapshot file at the time of the write operation request according to the target location of the write operation request; form a record of the current write operation according to the target location of the write operation request and the time of the write operation request; replace the content at the target location of the write operation request on the write operation record before responding to the write operation request with the record of the current write operation, thereby forming a write operation record of the snapshot file at the time of the write operation request; The read mapping module is used to query the latest snapshot file when receiving a read operation request whether the data content of the target location of the read operation request is stored in the snapshot file, so as to read the data from the snapshot file or the computer hard disk; The recovery module is used to update the latest snapshot file to the snapshot file at the target time point after receiving a data recovery request at the target time point.

7. A computer-readable storage medium, characterized in that The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

8. A computer device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 5 when executing the program.

Citation Information

Patent Citations

  • Data processing method and storage equipment

    CN103221925A

  • Writable snapshot realization method and apparatus

    CN107423233A