A method for improving data backup success rate
By storing unbacked changing data into cache files during the data backup process and optimizing data reading, the backup failure problem caused by excessive space occupied by snapshot devices is solved, and the success rate of data backup is improved.
Patent Information
- Application Number
- CN202210604310.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-31
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2042-05-31
AI Technical Summary
When the machine load is high, the snapshot device takes up more space, resulting in the problem of failure of data backup operations.
During the backup process, the unbacked change data is recorded into the cache file through the write-on-write copy operation and deleted after the backup is completed, reducing the space occupied by the snapshot device, and combining the binary search method to read the data, optimizing the backup process.
Reduces the footprint of snapshot devices and improves the success rate of data backup, especially in high load situations.
Smart Images

Figure CN115033425B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of computer applications, and in particular relates to a method for improving the success rate of data backup. Background Art
[0002] Data backup is the foundation of disaster recovery. To prevent data loss due to system failures and other reasons, performing full or incremental backups of host data is essential. Currently, data backup mainly includes file-level backup, block-level backup, and object-level backup.
[0003] When performing a block-level backup, a snapshot of the disk data is first taken to record the disk data information at a certain point in time. When the original disk data changes, the corresponding snapshot device uses write-time redirection technology to record the disk changes. The snapshot device creates a new block and copies the data at the snapshot point in time to the new block. The new data is then written to the disk, and the data pointer table is updated in the snapshot to point to the new data block. This technology will cause the space occupied by the snapshot device to increase when there are a large number of changes to the data in the source data volume during the backup process. If the machine is heavily loaded at this time, the data backup operation may fail due to the increase in space occupied by the snapshot device. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to address the deficiencies of the above-mentioned prior art and provide a method for improving the success rate of data backup, which can reduce the space used for snapshots and improve the success rate of data backup under heavy machine load.
[0005] In order to achieve the above technical objectives, the technical solution adopted by the present invention is:
[0006] A method for improving a data backup success rate, comprising:
[0007] S1. Before the backup begins, a snapshot is taken of the source data volume to record the data at the snapshot point in time.
[0008] S2. After the backup begins, if a write request occurs on the source volume, a copy-on-write operation is performed on the snapshot. Based on the backup status of the changed data block and its relationship with the snapshot, it is determined whether to perform another copy-on-write operation and store the original data to be backed up in the cache file. The data in the source data volume is then updated, ensuring that the source data volume remains in normal use during the backup process and that data changes are written.
[0009] S3. During the backup process, the data to be backed up is read through the snapshot, and the data at the snapshot time point is backed up based on whether the data is in the cache file.
[0010] To optimize the above technical solutions, specific measures taken also include:
[0011] The above-mentioned S1 includes:
[0012] S11. Before the backup starts, a snapshot operation is performed on the source data volume to record the data information at the backup start time point;
[0013] S12: Start backup and read the data at the backup time point by accessing the snapshot device;
[0014] S13. When the source data volume data changes, the snapshot device performs a copy-on-write operation to process the changed data.
[0015] S14, backing up the changed data and storing it in the corresponding storage medium;
[0016] The above-mentioned S2 includes:
[0017] S21. When a write request occurs on the source volume during the backup process, a copy-on-write operation is performed on the snapshot.
[0018] S22. Check whether the block data to which the write operation occurs has been backed up. If so, do not perform the copy-on-write operation, directly send the write request, and execute S25. Otherwise, execute S23.
[0019] S23. Check whether the data block where the write operation occurs exists in the snapshot. If so, no copy-on-write operation is performed, and the write request is directly sent down and S25 is executed. Otherwise, S24 is executed.
[0020] S24: A copy-on-write operation occurs on the snapshot. The snapshot device stores the original data to be backed up in a cache file, and then executes S25.
[0021] S25. The new data is written to the source data volume, and the data in the source data volume is updated.
[0022] The above S3 includes:
[0023] S31: Backup starts, and the data to be backed up is read through the snapshot;
[0024] S32. Determine whether the data to be backed up is already stored in the cache file based on the offset of the data to be backed up. If so, execute S33. Otherwise, read the data directly from the volume.
[0025] S33, reading the data from the cache file according to the offset of the data to be backed up;
[0026] S34. Delete the node where the data to be backed up is located;
[0027] S35, rebalancing after node changes;
[0028] S36: Store the data to be backed up in a storage medium.
[0029] The above-mentioned S33 reads the data from the cache file through a binary search method according to the offset of the data to be backed up.
[0030] The above S35 is rebalanced through the binary tree after the node changes.
[0031] The present invention has the following beneficial effects:
[0032] The present invention addresses the problem that when the machine load is heavy and the source data volume frequently undergoes write operations during the backup process, the space occupied by the snapshot device increases, causing the backup program to fail. The present invention abandons the traditional snapshot copy-on-write technology and uses the idea of copy-on-write to record the original data that has not been backed up and is to be changed in a file, thereby reducing the space occupied by the snapshot device; after backing up the data stored in the file, the data is deleted, which reduces the file size, can reduce the space occupied by the snapshot, and improve the success rate of data backup operations under high machine load. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 Schematic diagram of the method of the present invention;
[0034] Figure 2 A schematic diagram of the data backup process;
[0035] Figure 3 Schematic diagram of snapshot copy-on-write operation;
[0036] Figure 4 A schematic diagram of the data reading process. DETAILED DESCRIPTION
[0037] The embodiments of the present invention are described in further detail below with reference to the accompanying drawings.
[0038] like Figure 1 As shown, the present invention provides a method for improving the success rate of data backup, comprising:
[0039] S1. Before the backup starts, take a snapshot of the source data volume and record the data at the snapshot point (backup start point). Specifically, Figure 2 As shown, S1 includes:
[0040] S11. Before the backup starts, a snapshot operation is performed on the source data volume to record the data information at the backup start time point;
[0041] S12: Start backup and read the data at the backup time point by accessing the snapshot device;
[0042] S13. When the source data volume data changes, the snapshot device performs a copy-on-write operation to process the changed data.
[0043] S14, backing up the changed data and storing it in the corresponding storage medium;
[0044] S2. After the backup begins, if a write request occurs on the source volume, a copy-on-write operation is performed on the snapshot. Based on the backup status of the changed data block and its relationship with the snapshot, it is determined whether to perform another copy-on-write operation and store the original data to be backed up in the cache file. The data in the source data volume is then updated, ensuring that the source data volume remains in normal use during the backup process and that data changes are written.
[0045] In this embodiment, after backup begins, the snapshot device performs a copy-on-write operation. First, the read data is backed up. If a write request occurs on the source volume, the snapshot performs a copy-on-write operation. Next, a check is made to see if the block data where the write operation occurred has been backed up. If it is determined that it has not been backed up, the data block where the write operation occurred is checked to determine if it exists in the snapshot. If the changed data block has not been backed up and exists in the snapshot, the original data to be backed up is stored in a cache file. After the original data is stored in the cache file, the new data is written to the source data volume.
[0046] Specifically, such as Figure 3 As shown, the S2 includes:
[0047] S21. When a write request occurs to the source volume during the backup process, a copy-on-write operation will be performed on the snapshot.
[0048] S22. Check whether the block data to which the write operation occurs has been backed up. If so, do not perform the copy-on-write operation, directly send the write request, and execute S25 to update the data in the source data volume. Otherwise, execute S23.
[0049] S23: Check whether the data block where the write operation occurs exists in the snapshot. That is, check whether the data in the corresponding data block in the snapshot needs to be changed. If not, no copy-on-write operation is performed, and the write request is directly sent down. Then, S25 is executed, that is, the data in the source data volume is updated. Otherwise, S24 is executed.
[0050] S24. If the changed data block has not been backed up and exists in the snapshot, a copy-on-write operation will be performed on the snapshot due to the change in the data block. Here, the snapshot device does not create a new data block to store the original data to be backed up. Instead, the original data to be backed up is stored in a cache file, thereby reducing the size of the snapshot device. Then, S25 is executed.
[0051] S25. The new data is written to the source data volume, and the data in the source data volume is updated to ensure that the normal use of the source data volume is not affected during the backup process.
[0052] S3. During the backup process, the data to be backed up is read through the snapshot, and the data at the snapshot time point is backed up based on whether the data is in the cache file.
[0053] In an embodiment, during the backup process, first, based on the offset of the read data, it is determined whether the data to be read has been stored in the cache file. If a copy-on-write operation has occurred for the data to be backed up, the data is read from the cache file based on the offset of the data. The data is stored in the cache file using a balanced binary tree data structure. The data is read through a binary search method. After the data is read out, the node will no longer be accessed, so the node is deleted.
[0054] In addition, when a node changes, binary tree balancing is required; if the backup data is not stored in the cache file, the data is read directly from the volume.
[0055] Specifically, such as Figure 4 As shown, the S3 includes:
[0056] S31: Backup starts, and the data to be backed up is read through the snapshot;
[0057] S32. Based on the offset of the data to be backed up, determine whether the data to be backed up has been stored in the cache file. In other words, determine whether a copy-on-write operation has occurred on this data since the snapshot was taken. If so, execute S33. Otherwise, read the data directly from the volume.
[0058] S33. According to the offset of the data to be backed up, the data is read out from the cache file through a binary search method.
[0059] The data in the cache file is stored using a balanced binary tree data structure, and the data is read through a binary search method;
[0060] S34. After the data is read out, the node will no longer be accessed, so the node where the data needs to be backed up is deleted;
[0061] S35, after the node changes, rebalance through the binary tree;
[0062] S36: Store the data to be backed up in a storage medium.
[0063] From then on, starting from the backup, a snapshot is taken of the source data volume; during the backup process, the source data volume is used normally and data is written and changed; the backup of the data at the snapshot time point is completed.
[0064] Example 1
[0065] 1. Run the backup software backup on the host where data needs to be backed up;
[0066] 2. Install the backup driver backupdriver.ko;
[0067] 3. The backup software uses the mount command to mount the storage device \\desktop-ciku69b\SDPSHAREFOLDER, with the mount point being mountpoint1;
[0068] 4. The backup software obtains information about the volume / dev / sda1 on the host;
[0069] 5. The backup software creates a snapshot device / dev / snapshotdev1 based on the volume information; (S1)
[0070] 6. The backup software reads the snapshot device / dev / snapshotdev1 to obtain the backup data; (S2)
[0071] 7. The backup software stores the read backup data in the storage device through the mount point mountpoint1; (S4)
[0072] 8. During the backup process, modify the file testfile on the volume / dev / sda1; (S5)
[0073] 9. After the driver backupdriver.ko detects the block data changes, it saves the data to be cached into the / tmp / cachefile file; (S8)
[0074] 10. When the backup software accesses the snapshot device / dev / snapshotdev1 to read block data, it finds that this part of the data is cached, and then reads the data from the file / tmp / cachefile; (S101)
[0075] 11. After all data is read out and stored in the storage device, delete the snapshot device / dev / snapshotdev1, delete the cache file / tmp / cachefile, and exit the backup software backup.
[0076] From now on, all the work of the data backup process is completed.
[0077] The above are merely preferred embodiments of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions based on the principles of the present invention are within the scope of protection of the present invention. It should be noted that for those skilled in the art, various improvements and modifications that do not depart from the principles of the present invention should be considered within the scope of protection of the present invention.
Claims
1. A method for improving the success rate of data backup, characterized in that: include: S1. Before the backup begins, a snapshot is taken of the source data volume to record the data at the snapshot point in time. S2. After the backup begins, if a write request occurs on the source volume, a copy-on-write operation is performed on the snapshot. Based on the backup status of the changed data block and its relationship with the snapshot, it is determined whether to perform another copy-on-write operation and store the original data to be backed up in the cache file. The data in the source data volume is then updated, ensuring that the source data volume can be used normally during the backup process. The data is written and changed, including: S21. When a write request occurs on the source volume during the backup process, a copy-on-write operation is performed on the snapshot. S22. Check whether the block data to which the write operation occurs has been backed up. If so, do not perform the copy-on-write operation, directly send the write request, and execute S25. Otherwise, execute S23. S23. Check whether the data block where the write operation occurs exists in the snapshot. If so, no copy-on-write operation is performed, and the write request is directly sent down and S25 is executed. Otherwise, S24 is executed. S24: A copy-on-write operation occurs on the snapshot. The snapshot device stores the original data to be backed up in a cache file, and then executes S25. S25. The new data is written to the source data volume, and the data in the source data volume is updated; S3. During the backup process, the data to be backed up is read through the snapshot. Based on whether the data is in the cache file, the data at the snapshot time point is backed up, including: S31: Backup starts, and the data to be backed up is read through the snapshot; S32. Determine whether the data to be backed up is already stored in the cache file based on the offset of the data to be backed up. If so, execute S33. Otherwise, read the data directly from the volume. S33, reading the data from the cache file according to the offset of the data to be backed up; S34. Delete the node where the data to be backed up is located; S35, rebalancing after node changes; S36: Store the data to be backed up in a storage medium.
2. The method for improving the success rate of data backup according to claim 1, characterized in that: Said S1 comprises: S11. Before the backup starts, a snapshot operation is performed on the source data volume to record the data information at the backup start time point; S12: Start backup and read the data at the backup time point by accessing the snapshot device; S13. When the source data volume data changes, the snapshot device performs a copy-on-write operation to process the changed data. S14. Back up the changed data and store it in a corresponding storage medium.
3. The method for improving the success rate of data backup according to claim 1, characterized in that: The step S33 reads the data from the cache file using a binary search method based on the offset of the data to be backed up.
4. The method for improving the success rate of data backup according to claim 1, characterized in that: The S35 is rebalanced through the binary tree after the node changes.
Citation Information
Patent Citations
Method for implementing incremental snapshots-on-write
CN102012852A
Effective data acquisition system and method in virtual machine protection
CN111651238A
Data backup method and device based on virtual machine, and computer equipment
CN112395133A