Test method and system for checking backup and recovery data of database at any time point
The DB_Data tool automatically inserts timestamp data and uses SQL statements to simulate the recovery of the database at any time point, solving the problems of inefficiency and manual operation prone to errors in traditional methods, and achieving efficient and accurate data recovery verification.
Patent Information
- Application Number
- CN202510503658.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-22
- Publication Date
- 2025-08-05
AI Technical Summary
The traditional database recovery test method is inefficient, relies on manual operations and is prone to errors, resulting in poor accuracy of data recovery verification.
The DB_Data tool is used to automatically insert timestamp data and simulate recovery at any time through SQL statements. The data files are compared with the diff command to achieve automated data verification.
It significantly improves the efficiency and accuracy of database recovery testing, reduces human resource consumption, and ensures the integrity and consistency of data recovery.
Smart Images

Figure CN120429231A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of databases, and in particular relates to a testing method and system for verifying backup and recovery data of a database at any time point. Background Art
[0002] With the rapid development of information technology, databases, as core systems for storing and managing data, play a vital role in business operations. Data integrity and availability are directly related to business continuity and competitiveness. Therefore, database backup and recovery technology is a key element in ensuring data security. Database recovery at any point in time ensures data integrity and business flexibility.
[0003] In the traditional database specified time point testing method, the core is to repeatedly insert the same data information into the database and delete the old data records before each data recovery. The tester verifies the data after recovery based on the restored data to determine the accuracy of the data after the database is restored at any time point.
[0004] Traditional testing methods have significant limitations. The repetitive manual insertion and deletion operations during the testing process not only consume significant human resources but are also extremely inefficient and prone to human error. Each operation requires precise control to ensure data consistency. Furthermore, database data generation typically involves logging into the backend and executing insert commands, inserting data one by one. This process is inefficient and labor-intensive.
[0005] During the database recovery process, if you need to roll back to the state at a specific point in time, it may cause inconsistencies in the data at different time points, which may affect the accuracy of the tester's data recovery verification.
[0006] Recovery testing requires various methods to record backup time points and verify that the restored data is the data from the recovery period. This involves complex operations and verification processes, increasing the complexity and difficulty of testing.
[0007] The current method for creating data in a database is generally to log in to the database backend, execute the database insert command, and then insert data one by one. This method of inserting data is inefficient and labor-intensive. Therefore, it is necessary to develop a new test method and system for database backup and recovery data verification at any time point to solve the existing problem. Summary of the Invention
[0008] The object of the present invention is to provide a test method and system for verifying backup and recovery data of a database at any time point, so as to solve the problem of poor accuracy of data recovery verification.
[0009] To achieve the above objectives, the present invention provides the following technical solution: a test method for verifying backup and recovery data at any time point in a database, comprising: Create the data_time data table and generate the first data record file; Add, delete, and modify the data_time database table; Perform any point-in-time recovery of the database; Enter the recovery time point; If the recovery is successful, the database status is verified, otherwise the error log is output; If the database status is normal, the current data table data is recorded to generate a second data record file; Verify data, input the verification time point, obtain the actual data of the database at the verification time point, and output to generate a third data record file; Compare the second data record file with the third data record file to see if they are consistent. If they are consistent, the data verification is consistent. Otherwise, output the comparison result and error log.
[0010] Preferably, generating the first data record file includes: creating a data table, obtaining the current system time every second through the date command, inserting the time into the data table in real time in the form of a timestamp, and generating the first data record file in a preconfigured path, recording the inserted time stamp in real time; the data table is used as a data model for test verification; Preferably, performing arbitrary time point recovery on the database includes: utilizing an existing data backup and recovery system, configuring a data backup task to back up the database, and performing arbitrary time point recovery on the generated backup set, and recording the time point selected for recovery.
[0011] Preferably, generating the second data record file includes: acquiring data in the current database table, and outputting the generated second data record file in a preconfigured path.
[0012] Preferably, generating the third data record file includes: inputting the first time point selected during recovery, obtaining the database operation log record at the first time point according to the preconfigured database installation path, retrieving the original data at the time point, and generating the third data record file under the preconfigured path.
[0013] Preferably, comparing the second data record file and the third data record file to determine whether they are consistent includes: comparing the second data record file and the third data record file using a diff command.
[0014] The present invention further provides a test system for verifying database backup and recovery data at any time point, comprising: Connection module, used to connect to the database and operating system and operate the database environment; The data creation module is used to create a data table through SQL statements, obtain the system time, and insert the system time into the data table in the form of a timestamp as verification data; Data verification module, used to verify the accuracy of data restored from the database at any point in time; The output module is used to output verification success, failure and error log information.
[0015] Preferably, the data verification module includes: The database status verification module is used to determine whether the database is normal through the database status command and ps -ef|grep; The data table data verification module is used to obtain the original data content of the database at a specified time point through the database's own operation log, and export it in stages through SQL statements, the first data record file of the original data, and the second data record file after recovery at any time point; The file content comparison and verification module is used to obtain the third data record file of the original data in the database at a specified time point according to the database's own operation log, and compare the contents of the second data record file and the third data record file through the diff command.
[0016] The test method and system for verifying database backup and recovery data at any time point significantly reduces the burden of repetitive work through automated scripts, integrates efficient data analysis and comparison functions, and ensures that the accuracy of the data recovery process is strictly verified and guaranteed. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 Schematic diagram of the operating principle of the method of the present invention; Figure 2 This is a flow chart of the testing method of the present invention; Figure 3 It is a framework diagram of the system of the present invention. DETAILED DESCRIPTION
[0018] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying 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 efforts are within the scope of protection of the present invention.
[0019] The present invention provides Figure 1 A test method for verifying data during backup and recovery of a database at any time point, as shown in , includes: Create the data_time data table and generate the first data record file; Add, delete, and modify the data_time database table; Data backup and recovery system, which can restore the database at any time point; Enter the recovery time point; If the recovery is successful, the database status is verified, otherwise the error log is output; If the database status is normal, the current data table data is recorded to generate a second data record file; Use the DB_Date tool to verify the data. Enter the verification time point. The DB_Date tool obtains the actual data of the database at the verification time point and outputs a third data record file. Compare the second data record file with the third data record file to see if they are consistent. If they are consistent, the data verification is consistent. Otherwise, output the comparison result and error log.
[0020] The specific implementation steps are as follows: First, select a server with a configured database as the test environment. Then, use the DB_Data tool to insert the current system's precise timestamp into the database in real time as test data. In addition, the tool allows you to customize the amount of inserted data according to actual needs, thereby effectively avoiding the tedious process of manually entering data that requires a large amount of human resources in traditional methods. More importantly, by entering a specific time point, the tool can retrieve the original data at that time point from the database operation log, and compare it with the recovered data in detail to ensure the integrity and consistency of data recovery. This process not only greatly improves the efficiency of the test, but also significantly enhances the verification of the accuracy of the database recovery function at a specified time point. For specific operating steps and methods, please refer to Figure 2 The test method flow chart is shown.
[0021] To improve the accuracy and efficiency of testing the database recovery function at a specific point in time, the present invention is committed to the innovative development of a set of advanced testing methods and tools. The method and tool are designed to simulate real application scenarios to achieve more accurate data recovery testing, thereby effectively reducing the dependence and consumption of human resources during the testing process. For example, in the current testing process, testers need to manually log in to the database system and execute commands such as insert one by one. This process requires high skills from the operator and is prone to instability of test results due to human factors. In order to solve this kind of problem that relies on manual operation, automation technology is used to improve the accuracy and efficiency of testing and ensure the reliability and stability of the database recovery function.
[0022] Step 1: Configure the database connection information, operating system connection information, data log file storage path, log acquisition path, database installation path, and pre-configured data size in the DB_Data tool. If not configured, the data will be inserted continuously. Step 2: After clicking Start, the DB_Data tool starts connecting to the database and creates the data_time data table. It uses the date command to obtain the current system time every second and inserts it into the data_time table in real time as a timestamp. It also generates the first data record file Data_text1 in the preconfigured path and records the inserted timestamp in real time. Step 3: Use the data backup and recovery system to configure a data backup task to back up the database. Then, restore the generated backup set to any point in time, recording the first point in time selected for recovery, data1. Step 4: After successful recovery, click the Database Verification button in the DB_Data tool to start verifying the database status. If the status is normal, the message "Database Verification Success" will be displayed, and the process will continue to Step 5. If the status is abnormal after recovery, the message "Database Verification Failure" will be entered. The pre-configured log path will be used to capture and filter the ERROR information and provide feedback to the tester. Step 5: After the database verification is successful, the DB_Data tool obtains the data in the current database table and generates the second data record file Data_text2 in the pre-configured path; Step 6: Click the Data Verification button in the DB_Data tool and enter the first time point data1 selected during recovery. The DB_Data tool will obtain the database operation log records of the first time point data1 based on the preconfigured database installation path, retrieve the original data at that time point, and generate the third data record file Data_text3 in the preconfigured path. Step 7: After the third data record file Data_text3 is generated in step 6, the DB_Data tool uses the diff command to compare the contents of the second data record file Data_text2 and the third data record file Data_text3; if the contents are consistent, the data verification is successful, otherwise, the data verification is failed, and the ERROR information is captured and filtered according to the pre-configured log path and fed back to the tester.
[0023] Through the DB_Data tool, the current system time is inserted into the database every second, and the accuracy of data recovery verification at any time point in the database is achieved. It greatly simplifies the tedious manual operation of inserting database data. Based on the pre-setting and configuration of relevant tools, users only need to use simple "open" and "close" instructions to capture the current timestamp of the system in real time and automatically perform data insertion tasks. In addition, users are allowed to flexibly set the amount of data to be inserted according to actual needs. What's more convenient is that by entering a specific timestamp, the system can automatically generate the corresponding SQL query statement and automatically direct it to the specified file to verify the accuracy of the data after recovery at any point in time. If data inconsistency is found, the system will automatically retrieve and output the corresponding ERROR log information through the preset log path, thereby ensuring the integrity and accuracy of the restored data verification.
[0024] The accuracy of data recovery verification at any point in time in the database can be achieved through automation.
[0025] By using the system's built-in date command and the database's own SQL statements, database timestamps can be inserted more efficiently, helping testers quickly and accurately locate and recover data problems.
[0026] By obtaining the database's operation log at a specified point in time, retrieving the original database data content and outputting it as a corresponding data file for comparison with the actual data content after recovery, this method can more accurately verify the accuracy of data restored from any point in time. Generating recorded original data files also facilitates rapid identification of recovery data issues in scenarios where data restored from any point in time is inaccurate.
[0027] It seamlessly integrates with backup and disaster recovery systems to automate data insertion. It accurately verifies restored database data at any point in time, ensuring data integrity and consistency. For example, in a simulated disaster recovery scenario, the DB_Data tool can quickly locate a data snapshot at a specific point in time and, using a series of pre-set verification rules, meticulously check the accuracy and integrity of the data, providing a solid foundation for the stable operation of the database. The present invention further provides Figure 3 The database backup and recovery data verification system shown is a DB_Data tool, which includes: The connection module is used to connect to the database set operating system and use SSH and SQL statements and other related commands to operate the database environment; The data manufacturing module creates a data table through SQL statements and commands such as date to obtain system time, and inserts it into the data table in the form of a timestamp as verification data.
[0028] The data verification module uses the database status command and ps -ef|grep to determine whether the database is normal, and obtains the original data content of the database at a specified time point through the database's own operation log, and exports it in stages through SQL statements, the original first data record file Data_text1, the second data record file Data_text2 after recovery at any time point, and the original third data record file Data_text3 in the database at a specified time point based on the database's own operation log, and compares the contents of the second data record file Data_text2 and the third data record file Data_text3 through the diff command to verify the accuracy of the data recovered at any time point in the database.
[0029] The output module outputs verification success, failure, and error log information; it can quickly and accurately verify the consistency of restored data at any time point in the database before and after backup and recovery.
[0030] Finally, it should be noted that the above is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A test method for verifying backup and recovery data at any point in time of a database, characterized by: include: Create a data table and generate a first data record file; Add, delete, and modify the database table; Perform any point-in-time recovery of the database; Enter the recovery time point; If the recovery is successful, the database status is verified, otherwise the error log is output; If the database status is normal, the current data table data is recorded to generate a second data record file; Verify data, input the verification time point, obtain the actual data of the database at the verification time point, and output to generate a third data record file; Compare the second data record file with the third data record file to see if they are consistent. If they are consistent, the data verification is consistent. Otherwise, output the comparison result and error log.
2. A test method for verifying database backup and recovery data at any time point according to claim 1, characterized in that: The generating of the first data record file includes: creating a data table, obtaining the current system time every second through the date command, inserting the time into the data table in real time in the form of a timestamp, and generating the first data record file in a preconfigured path, recording the inserted timestamp in real time.
3. The test method for verifying database backup and recovery data at any time point according to claim 1, characterized in that: The performing of any time point recovery on the database includes: utilizing a data backup and recovery system, configuring a data backup task to back up the database, performing any time point recovery on the generated backup set, and recording the time point selected for recovery.
4. The test method for verifying database backup and recovery data at any time point according to claim 1, characterized in that: The generating of the second data record file includes: acquiring data in the current database table, and outputting the generated second data record file in a preconfigured path.
5. The test method for verifying database backup and recovery data at any time point according to claim 1, characterized in that: Generating the third data record file includes: inputting a first time point selected during recovery, obtaining a database operation log record at the first time point according to a preconfigured database installation path, retrieving the original data at the time point, and generating the third data record file under the preconfigured path.
6. The test method for verifying database backup and recovery data at any time point according to claim 1, characterized in that: The comparing whether the second data record file is consistent with the third data record file includes: comparing the second data record file with the third data record file by using a diff command.
7. A test system for verifying database backup and recovery data at any time point, characterized by: include: Connection module, used to connect to the database and operating system and operate the database environment; The data creation module is used to create a data table through SQL statements, obtain the system time, and insert the system time into the data table in the form of a timestamp as verification data; Data verification module, used to verify the accuracy of data restored from the database at any point in time; The output module is used to output verification success, failure and error log information.
8. The test system for verifying database backup and recovery data at any time point according to claim 7, characterized in that: The data verification module includes: The database status verification module is used to determine whether the database is normal through the database status command and ps -ef|grep; The data table data verification module is used to obtain the original data content of the database at a specified time point through the database's own operation log, and export it in stages through SQL statements, the first data record file of the original data, and the second data record file after recovery at any time point; The file content comparison and verification module is used to obtain the third data record file of the original data in the database at a specified time point according to the database's own operation log, and compare the contents of the second data record file and the third data record file through the diff command.