Snapshot and recovery method, device and equipment for computer hard disk data
By establishing logical hard disk and write operation records on the computer hard disk, the problem of traditional backup and recovery methods requiring aborting the operating system's read and write is solved, and space occupation is reduced, achieving efficient data snapshots and recovery.
Patent Information
- Application Number
- CN202411752651.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2044-12-02
AI Technical Summary
Traditional computer hard disk data backup and recovery methods require aborting the reading and writing of the operating system during data backup or recovery, and the space to record the actual state of the computer hard disk takes up a large amount of space, making it difficult to be applied to uninterrupted production scenarios.
The empty files are used to establish logical hard disk and write operation records corresponding to the computer hard disk in units of sector-sized block devices to form snapshot files to realize data snapshot and recovery, and only the target location of the write operation is recorded during the write operation, reducing space occupation.
It realizes data snapshots and recovery without aborting the operating system's read and write, reducing space usage and improving applicability.
Smart Images

Figure CN119668938A_ABST
Abstract
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 the computer hard disk data based on pre-backed-up data.
[0003] In the prior art, most traditional backup and recovery methods use the method of copying valid data of the target partition to the backed-up partition, and reading data from the backup partition to overwrite the data of the partition to be restored during recovery. There are also methods that use the recording of 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 the actual state after writing data.
[0004] However, traditional backup and recovery methods usually require the operating system to stop reading and writing when backing up or restoring data, which is difficult to apply in scenarios where the production process cannot be interrupted. When using the mapping relationship between logical addresses and physical addresses to record the actual status of the computer hard disk, although the actual data is usually written to only a small part of the space, it still needs to record the mapping relationship of the entire computer hard disk space, and the space required to save the actual status of the computer hard disk is relatively large. 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 units of sector-sized block devices to form a snapshot file at the current time point;
[0009] When receiving a write operation request, a snapshot file at the time point of the write operation request is created using a hole file, a write operation is performed based on a logical hard disk of the snapshot file at the time point of the write operation request according to a target location of the write operation request, and a write operation record of the snapshot file at the time point of the write operation request is formed according to the write operation;
[0010] When receiving a read operation request, 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;
[0011] After receiving a data recovery request for a target time point, the latest snapshot file is updated to be the snapshot file at the target time point.
[0012] Optionally, the performing of the 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 point of the write operation request;
[0014] Forming 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 position 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 of 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 data from the logical hard disk of the snapshot file at the target time point at the target location corresponding to the read operation request;
[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 the hole file to establish a logical hard disk corresponding to the computer hard disk and a vacant write operation record in units of 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 has been used in units of block devices of sector size, so as to obtain a data block mark table at the current time point;
[0022] A hole file is used to establish 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 by using a hole file, and the snapshot area is combined with a data block mark table, a write operation record and an 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 position of the computer hard disk corresponding to the write operation request is used according to the use status of the target position 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, write the data content corresponding to the write operation request into the free position of the snapshot area, and update the address mapping relationship between the target position corresponding to the write operation request and the free position in the logical hard disk according to the address mapping relationship table before responding to the write operation request, and create an address mapping relationship table after responding to the write operation request; and generate a write operation record after responding to the write operation request according to the free position;
[0028] If not, then write 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 generate 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 driver, and 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 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 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, use an empty file to establish a logical hard disk corresponding to the computer hard disk and an empty write operation record in units of a block device of sector size 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 a time point of the write operation request using a hole file, perform a write operation based on a logical hard disk of the snapshot file at a time point of the write operation request according to a target location of the write operation request, and form a write operation record of the snapshot file at a time point 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 of the target time point after receiving a data recovery request for 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, wherein the processor implements the above-mentioned computer hard disk data snapshot and recovery method when executing the program.
[0038] At least one of the above technical solutions adopted by the present invention can achieve the following beneficial effects:
[0039] For data snapshot requests, 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 when no snapshot file exists, 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. Otherwise, the latest snapshot file is used as the snapshot file at the current time point.
[0040] When a write operation request is received, 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. 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 recording 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 snapshot and recovery method for computer hard disk data 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 A schematic diagram of the transfer relationship between the hard disk sectors and snapshot files based on the real-time backup of the current time point of the computer hard disk provided by the present invention Figure 1 ;
[0049] Figure 6 A real-time snapshot of data provided by the present invention Figure 2 ;
[0050] Figure 7 A schematic diagram of the transfer relationship between the hard disk sectors and snapshot files based on the real-time backup of the current time point of the computer hard disk provided by the present invention Figure 2 ;
[0051] Figure 8 A schematic diagram of a computer hard disk data snapshot and recovery device provided by the present invention;
[0052] Fig. 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] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the specific embodiments of the present invention and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work 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 the software can only be compatible with various hardware platforms.
[0055] The technical solutions provided by various embodiments of the present invention are described in detail below in conjunction with 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 establish 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 a 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 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 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.
[0060] S104: After receiving a data recovery request for a target time point, updating the latest snapshot file to the snapshot file at the target time point.
[0061] For the convenience of explanation, the following description is only 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, a notebook computer, etc. that can execute the solution of the present invention.
[0062] Usually, the computer file system performs specific operations on the computer hard disk through the computer hard disk driver. Taking Kylin system (Kylin) or Tongxin 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 The figure 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) protocol, and a BlockIo filter driver is added to the new BlockIo protocol function interface and the original BlockIo function interface. The filter driver captures the call to the block device, remaps it, and then calls the call of the block device after the computer hard disk is mapped.
[0064] Based on this, in one or more embodiments of the present invention, the computer can capture the call to the block device through the filter driver and remap it based on the snapshot file. The snapshot file may include using the hole file to establish a logical hard disk corresponding to the computer hard disk in units of block devices of sector size, and using the hole file to establish a write operation record corresponding to the computer hard disk in units of block devices of sector size. Among them, the computer can record the data snapshot or the state of the computer hard disk when the data is written through the snapshot file formed by the logical hard disk and the write operation record.
[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 BYTE 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 file header of the snapshot file + 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 through the snapshot file.
[0069] When receiving a data snapshot request, the computer can determine whether there is a snapshot file currently. If there is a snapshot file, the latest snapshot file is used as the snapshot file at the current time point. Otherwise, a logical hard disk corresponding to the computer hard disk and an empty write operation record are established using a hole file in a block device of sector size as a unit to form a snapshot file at the current time point.
[0070] Since the purpose of data snapshot is to record the data storage status of the computer hard disk at the snapshot time point, and the snapshot file is to record the data storage status of the computer hard disk at the snapshot file creation time point, when the data snapshot is taken for the first time, an empty snapshot file may be formed, indicating that there is no data protected and recorded by the snapshot file at that moment. When the computer reads data, it can read data directly based on the computer hard disk.
[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 point of the write operation request can be created using an empty file, and the data content corresponding to the write operation request is written into the logical hard disk of the snapshot file at the time point of the write operation request at the target location corresponding to 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 point 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 point of the write operation request.
[0072] Assume that the first write operation request is received after the first data snapshot, and the target location is A. After the write operation request is executed based on the snapshot file, in the snapshot file at the time of the write operation request, the logical hard disk only allocates the storage space for the data storage at the corresponding location A, and writes the data content corresponding to the write operation request. The other locations of other block devices of the corresponding computer hard disk are all empty and do not occupy actual storage space. Similarly, the write operation record only allocates the storage space at the corresponding location A and writes the record of the write operation.
[0073] Assume again that a second write operation request is received, and the target location is B. After executing the write operation request based on the snapshot file, in the snapshot file at the time of the write operation request, the logical hard disk only allocates storage space for data storage at the corresponding location B, and writes the data content corresponding to the write operation request. The other locations of other devices of the corresponding computer hard disk block are all empty and do not occupy actual storage space. The write operation record only allocates storage space at the corresponding locations A and B, and writes the record of the write operation at B. The write operation record at A is the same as the write operation record at A in the snapshot file at the time of the first write operation request.
[0074] When receiving a read operation request, 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 computer hard disk at the target location corresponding to the read operation request.
[0075] Taking the 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 performing data recovery, 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 The present invention is a method for backing up the current time point of a computer hard disk in real time based on the hard disk sector and the snapshot file transfer relationship diagram. Figure 1 The block device perceived by the user 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 part of the file is the filter driver. The filter driver intercepts all block device accesses of the operating system in the current time period, that is, any access to the physical block device. Then the filter driver performs the operation based on the operation at the current time point and the address mapping based on the latest snapshot file.
[0079] based on Figure 1 The snapshot and recovery method for computer hard disk data shown in the figure, for data snapshot requests, 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, 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. A 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 responding to the write operation, only the write operation is recorded without recording additional content, thereby reducing space occupancy.
[0081] When a read operation request is received after the data snapshot, the data content corresponding to the read operation can be determined to be stored in the snapshot file or the computer hard disk based on the write operation record of the snapshot file at the time of the read operation. 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 a 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 computer hard disk data snapshot and recovery method 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] In addition, in one or more embodiments of the present invention, the snapshot file may be in other forms.
[0085] Specifically, when receiving a data snapshot request, if there is no snapshot file, the computer can scan the used sectors in the computer hard disk, use a hole file to record whether each block device has been used in units of sector-sized block devices, and obtain a data block mark table at the current time point. And use the hole file to establish an empty write operation record for recording whether a write operation is performed on each block device in the computer hard disk at the current time point. At the same time, a logical hard disk corresponding to the computer hard disk is established in units of sector-sized block devices, and an address mapping relationship table between the logical hard disk and the computer hard disk at the current time point is determined. Thus, 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.
[0086] For example, the valid data (data in the used space) in the partition file system (NTFS, EXT4, XFS, Refs, etc.) can be scanned, and the computer hard disk can be managed as a block device according to the physical hard disk sector size (one sector). Then, based on the used block devices obtained by scanning, a data block mark table is established to record the status of whether each block device has data, for example, mark 1 represents data, and 0 represents 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 position corresponding to the write operation request on the computer hard disk is in use based on the usage status of the target position 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 according to 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 the write operation record after responding to the write operation request is generated according to 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 point 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, and the remaining positions 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, only the mapping relationship of the data content written into the snapshot area needs to be maintained to save space.
[0092] If not, the data content corresponding to the write operation request is written into the target position 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 position 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 operation request for a target location in a computer hard disk, the computer can determine whether the target location corresponding to the read operation request is used according to the usage status of the target location corresponding to the read operation request in the data block mark table of the latest snapshot file. If so, the real address of the target location corresponding to the read operation request in the computer hard disk is queried according to the address mapping relationship table of the latest snapshot file, and data is read. Alternatively, data is read from the target location corresponding to the read operation request in the computer hard disk. 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 above corresponding instructions.
[0095] Furthermore, after receiving a data recovery request for a target time point after a data snapshot, the computer may update the snapshot file at the time corresponding to the data recovery request to the snapshot file at the target time point, and clean up the data in the snapshot area according to the snapshot file at the target time point.
[0096] Figure 7 The present invention is a method for backing up the current time point of a computer hard disk in real time based on the hard disk sector and the snapshot file transfer relationship diagram. Figure 2 .Depend on Figure 7 It can be seen that 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. Then the filter driver performs the operation based on the operation at the current time point and the address mapping based on the latest snapshot file before executing the operation.
[0097] The above is a computer hard disk data snapshot and recovery method provided by one or more embodiments of the present invention. Based on the same idea, the present invention also provides a corresponding computer hard disk data snapshot and recovery device, 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 used for, when receiving a data snapshot request, if a snapshot file already exists, using the latest snapshot file as the snapshot file at the current time point; otherwise, using an empty file to establish a logical hard disk corresponding to the computer hard disk and an empty write operation record in units of a block device of a sector size, to form a snapshot file at the current time point;
[0100] The write mapping module 202 is used to create a snapshot file at the time point of the write operation request using a hole file when receiving a write operation request, perform a write operation based on the logical hard disk of the snapshot file at the time point of the write operation request according to the target location of the write operation request, and form a write operation record of the snapshot file at the time point of the write operation request according to the write operation;
[0101] The read mapping module 203 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;
[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 after receiving a data recovery request for the target time point after the data snapshot.
[0103] The specific definition of the snapshot and recovery device for computer hard disk data can be found in the definition of the snapshot and recovery method for computer hard disk data in the above text, which will not be repeated here. Each module in the above-mentioned snapshot and recovery device for computer hard disk data can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above 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 Fig. 9 The structural diagram of the computer device shown in FIG. Fig. 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, and 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 can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and 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 may be arbitrarily combined. 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 establish a logical hard disk corresponding to the computer hard disk and a vacant write operation record in units of a block device of sector size, forming a snapshot file at the current time point; When a write operation request is received, a snapshot file at the time point of the write operation request is created using a hole file, a write operation is performed based on a logical hard disk of the snapshot file at the time point of the write operation request according to a target location of the write operation request, and a write operation record of the snapshot file at the time point of the write operation request is formed according to the write operation; When receiving a read operation request, 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; After receiving a data recovery request for a target time point, the latest snapshot file is updated to be the snapshot file at the target time point.
2. The computer hard disk data snapshot and recovery method according to claim 1, characterized in that: The logical hard disk based on the snapshot file at the write operation request time point performs a write operation, and forms a write operation record of the snapshot file at the write operation request time point according to the write operation, specifically including: 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 point of the write operation request; Forming 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; The content at the target position 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.
3. The computer hard disk data snapshot and recovery method as claimed in claim 2, characterized in that: The 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: 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, 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 data 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, data is read from the target location corresponding to the read operation request in the computer hard disk.
4. The computer hard disk data snapshot and recovery method according to claim 1, characterized in that: 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 units of 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 has been used in units of block devices of sector size, so as to obtain a data block mark table at the current time point; A hole file is used to establish 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 by using a hole file, and the snapshot area is combined with a data block mark table, a write operation record and an address mapping relationship table at the current time point to form a snapshot file at the current time point.
5. The computer hard disk data snapshot and recovery method as claimed in claim 4, characterized in that: The step of performing a write operation based on the target location of the write operation request and the logical hard disk of the snapshot file at the current time point, 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 position of the computer hard disk corresponding to the write operation request is used according to the use status of the target position 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, write the data content corresponding to the write operation request into the free position of the snapshot area, and update the address mapping relationship between the target position corresponding to the write operation request and the free position in the logical hard disk according to the address mapping relationship table before responding to the write operation request, and create an address mapping relationship table after responding to the write operation request; and generate a write operation record after responding to the write operation request according to the free position; If not, then write 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 generate 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.
6. The computer hard disk data snapshot and recovery method according to claim 1, characterized in that: A block device filter driver is provided between the computer file system and the computer hard disk driver, and 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 address mapping based on the snapshot file.
7. 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 establish a logical hard disk corresponding to the computer hard disk and a vacant write operation record in units of a block device of sector size, forming a snapshot file at the current time point; A write mapping module, configured to, upon receiving a write operation request, create a snapshot file at a time point of the write operation request using a hole file, perform a write operation based on a logical hard disk of the snapshot file at a time point of the write operation request according to a target location of the write operation request, and form a write operation record of the snapshot file at a time point of the write operation request according to the write operation; 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.
8. 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 6 is implemented.
9. 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 when the processor executes the program, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Data processing method and storage equipment
CN103221925A
Writable snapshot realization method and apparatus
CN107423233A
A computer hardware data multi-timepoint fast storing and recovery method
CN1740981A
Method and device for managing multiple snapshots of data strorage device
US20150193315A1
Cited By
Data backup and recovery method and device, electronic equipment and storage medium
CN121070696A