Embedded database replication and backup method

By building an embedded database replication and backup management system, the problem of data replication and backup of heterogeneous databases on embedded devices was solved, and efficient data replication was achieved in environments with unbalanced hardware resources and unstable networks, thereby improving data query efficiency and stability.

CN121412031APending Publication Date: 2026-01-27BEIJING INST OF COMP TECH & APPL
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202511361338.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-23
Publication Date
2026-01-27

AI Technical Summary

Technical Problem

Existing technologies struggle to efficiently copy and back up data from general databases on embedded devices with limited hardware resources, especially in unstable network environments where continuous operation is difficult, and data sharing between heterogeneous database management systems is poor.

Method used

An embedded database replication and backup management system is built using the database replication and backup program dbrepsql and the control program dbget. This system enables interaction and replay of operation log files between the master and slave databases, shields internal differences within the database system, and improves data replication efficiency and stability.

Benefits of technology

It enables efficient data replication and backup between heterogeneous databases, reduces dependence on network stability, improves data query efficiency and working ability in harsh network environments, and reduces resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121412031A_ABST
    Figure CN121412031A_ABST
Patent Text Reader

Abstract

The invention relates to an embedded database copying and backup method, and belongs to the technical field of embedded databases. According to the method, a master database end and a slave database end are connected through a database replication and backup program dbrepsql, and an embedded database replication and backup management system is constructed; the system comprises a database replication and backup program dbrepsql and a database replication and backup control program dbget. According to the method, the transaction operation process is recorded in the operation log file at the master database end, and after the operation log file is transmitted to the slave database end through the network, the slave database end performs transaction operation replay, so that the data change of the master database end is copied and backed up to the slave database end; therefore, the user can copy and backup the database between different devices or between different positions of the same device through the network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of embedded database technology, and specifically relates to an embedded database replication and backup method. Background Technology

[0002] With the growth of embedded system applications, the demand for data storage and management in embedded systems is becoming increasingly prominent, leading to the widespread application of embedded database management systems in these scenarios. Embedded database management systems typically run on devices with relatively limited hardware resources. However, in some disaster recovery and backup technology applications, users may face a situation where the source data is stored on a large server, but the actual data processing is performed on embedded devices with limited hardware resources. This makes existing backup technologies unsuitable for this scenario, failing to meet the requirement of storing data on a large server and processing it on an embedded device.

[0003] Chinese patent "CN 115237671A A Method and System for Embedded Database Mirror Backup" employs a database mirror backup method that reuses database transaction log files. The transaction log file generated on the master database is transmitted over a network to the slave database. The slave database then parses this transaction log file and performs the same transaction operations as the master database. Ultimately, mirror backup is achieved by using the same transaction log file to perform identical transaction operations on both the master and slave databases. This backup method reuses the transaction log file generated during master database operations, reducing the impact of backups on the master database's operational efficiency and realizing mirror backup between master and slave databases.

[0004] Chinese patent CN 115237671A, "A Method and System for Embedded Database Mirror Backup," proposes a method for achieving mirror backup by reusing database transaction logs. This method transmits the transaction logs of the master database to the slave database, where the slave database parses and redoes the same transactions to achieve database backup. While this solution reduces the performance overhead of the master database, its core drawback is its heavy reliance on the transaction log file format within the database system, thus limiting its applicability to homogeneous database systems. This is because transaction log files generated by heterogeneous database management systems are typically incompatible in terms of format, protocol, and internal identifiers, making direct parsing and execution impossible on the other end. This solution fails when the master and slave databases are respectively a general-purpose database and an embedded database. Furthermore, embedded devices directly accessing databases on large servers suffer from low query efficiency, high network dependence, and poor continuous operation in unstable network environments. Summary of the Invention

[0005] (a) Technical problems to be solved

[0006] The technical problem this invention aims to solve is how to provide an embedded database replication and backup method to address the issues of low efficiency in remotely accessing data from a general database on embedded devices and difficulty in continuous operation under unstable network environments; the problem of backing up specific data in large servers; and the problem of poor data sharing between devices with different hardware resources and between heterogeneous database management systems.

[0007] (II) Technical Solution

[0008] To address the aforementioned technical problems, this invention proposes an embedded database replication and backup method. This method connects the master and slave databases through the database replication and backup program dbrepsql to construct an embedded database replication and backup management system. The system includes: the database replication and backup program dbrepsql and the database replication and backup control program dbget.

[0009] The database replication and backup program dbrepsql runs on both the master and slave database ends. dbrepsql is used for command and operation log file interaction between the master and slave database ends, including database replication / backup startup, shutdown, and status query services. The dbrepsql program comprises four modules: a log file management module, a command interaction processing module, a network data service (HTTP) module, and a data transmission transport module.

[0010] The log file management module is used to manage the operation log files generated by the database replication and backup program dbrepsql during replication and backup, including the generation and parsing of operation log files;

[0011] The command interaction processing module is responsible for handling command interactions between the master and slave databases. When both the master and slave databases start the database replication and backup program dbrepsql, the command interactions between these two nodes are received and processed by this module, and then fed back to the command initiating node.

[0012] The data service HTTP module provides network service capabilities for the embedded database management system;

[0013] The data transmission transport module provides TCP-based data transmission capabilities for the embedded database management system, enabling network data sending and receiving.

[0014] The database replication and backup control program dbget runs on the slave database side. As a replication and backup control command sending program, it sends database replication and backup instructions to the database replication and backup program dbrepsql on the slave database side. These instructions include: replication and backup start / stop commands, the port number for starting the replication and backup program on both the master and slave database sides, the IP address of the master and slave devices, and the corresponding database name.

[0015] (III) Beneficial Effects

[0016] This invention proposes an embedded database replication and backup method. In this invention, the transaction operation process is recorded in an operation log file on the master database side. After the operation log file is transmitted to the slave database side via the network, the transaction operation is replayed on the slave database side, thereby realizing the replication and backup of data changes on the master database side to the slave database side. This allows users to perform database replication and backup between different devices or different locations on the same device via the network.

[0017] This invention provides an embedded database replication and backup method. Compared with the prior art, the advantages of this invention are:

[0018] 1. Achieving Heterogeneous Database Replication: This invention solves the data replication and backup problem between heterogeneous database management systems by parsing and replaying database operation logs (instead of directly applying native logs), thus shielding the internal differences between different database systems.

[0019] 2. Improved efficiency and stability: By maintaining a local copy of the data on the embedded device, frequent query operations are shifted from high-latency network access to local access, which greatly improves data query efficiency, reduces dependence on network stability, and enhances the ability to work in harsh network environments.

[0020] 3. The operation log files generated by the master database are reused and transmitted to the slave database, reducing the time spent on operation log files by the embedded database management system. At the same time, the data operation process in the operation log files is replayed on the slave database, realizing replication and backup between master and slave databases with unbalanced resources, reducing financial consumption, and solving the data backup problem between heterogeneous databases through replication and backup methods. Attached Figure Description

[0021] Figure 1 This is a schematic diagram of the components of the embedded database replication and backup management system of the present invention;

[0022] Figure 2 Diagram showing the components of the backup program module;

[0023] Figure 3 A functional composition diagram of the database network data service module;

[0024] Figure 4 This is a diagram showing the functional components of the data transmission transport module. Detailed Implementation

[0025] To make the objectives, contents, and advantages of the present invention clearer, the specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples.

[0026] This invention relates to the field of embedded database technology, and more specifically to a method for data replication and backup between database management systems with different architectures and resource-unbalanced devices.

[0027] This invention proposes an embedded database replication and backup method. This method overcomes the shortcomings of previous technologies by deploying an embedded database management system on an embedded device and replicating and backing up device-related data located in a general database in real time. It enriches the application scenarios of embedded databases and reduces the dependence of embedded applications on network stability. Specific objectives are as follows:

[0028] (1) Solve the problem of low efficiency in remotely accessing data in a general database on embedded devices and difficulty in continuous operation under unstable network conditions.

[0029] (2) Build a solution for backing up specific data in large servers on embedded devices, forming the ability to access the database locally on embedded devices, improving data security, reliability and access efficiency.

[0030] (3) Solve the problem of poor data sharing between devices with different hardware resources and between heterogeneous database management systems. The system source data is uniformly stored in a general database management system (such as MySQL, Oracle, Microsoft SQL Server) on a large server as the master database. The actual data can be deployed in an embedded database management system in an embedded device with relatively scarce resources. The master and slave database management systems will be replicated and backed up, thereby ensuring the high efficiency of data access between multiple devices.

[0031] This invention relates to the field of database backup technology. It establishes an embedded database replication and backup management system by connecting the master and slave databases using the database replication and backup program dbrepsql. The system components are shown in the attached figure. Figure 1As shown, its main components are: the database replication and backup program dbrepsql and the database replication and backup control program dbget. The dbrepsql and dbget programs reside on different device nodes that are connected via a network. The master and slave databases are connected via a network. The master database is typically a general-purpose database management system (MySQL, Oracle, Microsoft SQL Server, etc.) deployed on a large server device, while the slave database consists of an embedded device and an embedded database management system.

[0032] 1. Database replication and backup program dbrepsql

[0033] The database replication and backup program dbrepsql is the main program of this invention, running on both the master and slave database ends. dbrepsql is used for command and operation log file interaction between the master and slave database ends for replication and backup, including database replication and backup start, database replication and backup stop, and database replication and backup status query services.

[0034] The database replication and backup program dbrepsql comprises four modules: a log file management module, a command interaction processing module, a network data service (HTTP) module, and a data transfer transport module. Its architecture is shown in the attached diagram. Figure 2 As shown. The main functions of these four modules are summarized below.

[0035] (1) Log file management module, which is used to manage the operation log files generated by the database replication and backup program dbrepsql during replication and backup. It mainly includes the generation of operation log files and the parsing of operation log files.

[0036] The log file management module is responsible for saving newly generated data operations to operation log files, which are then provided to the data transmission module for transmission. The log file management module operates on both the master and slave ends of the database. On the master end, it monitors database changes and records them in the operation log file. On the slave end, it parses the operation log file to obtain the database operation methods and replays these changes in the slave database.

[0037] (2) The command interaction processing module is responsible for handling the command interaction between the master and slave databases. When both the master and slave databases start the replication backup program dbrepsql, the command interaction between these two nodes is received and processed by this module, and then fed back to the command initiating node. For example, when the slave database requests the master database to establish a replication backup connection, the command is sent from the slave database to the master database via the network. The master database connects the master and slave databases according to the connection command. After the master and slave databases are successfully connected, the command interaction between the master and slave is maintained, and feedback is given according to the command execution status.

[0038] (3) The data service HTTP module provides network service capabilities for the embedded database management system, mainly including four components: HTTP basic services, HTTP service parsing, HTTP thread management, and remote connection processing, as shown in the appendix. Figure 3 As shown.

[0039] a) The HTTP basic service component provides the system with basic HTTP services such as HTTP initialization, termination, startup, stop, and shutdown;

[0040] b) The HTTP service parsing component performs preliminary parsing of the received HTTP requests, mainly including parameter initialization, command validity determination, parameter parsing, saving the obtained parameter information string into the parameter structure, and releasing parameters.

[0041] c) The HTTP thread management component is used in embedded database management systems to support multi-user access, primarily through three types of threads. The "http_srv" thread initializes the HTTP service, listens on the given service port, starts the "con_srv" thread, and handles resource reclamation after connection closure. The "con_srv" thread accepts external connection requests and allocates a new socket and thread (con thread) for each connection to handle the corresponding transaction. There will only be one "con_srv" thread, while the number of "con" threads will be consistent with the number of external connection requests. The "con" thread handles specific database request operations, such as opening and closing the database, and CRUD operations. After a transaction is completed, the thread enters the idle thread pool; if the number of threads is insufficient, new threads are created to provide service.

[0042] d) The remote connection processing component is used to process remote service requests. It mainly includes obtaining the HTTP request, parsing the URL address information in the HTTP request, executing the commands for database operations on both the master and slave ends obtained from the parsing and executing the corresponding TFS operations (the database operations corresponding to the embedded database after obtaining the instructions in this invention), encapsulating the TFS processing results and outputting the processing results.

[0043] (4) The data transmission transport module provides the embedded database management system with TCP-based data transmission capabilities, enabling network data sending and receiving. It establishes TCP connections between the client and server, executes data sending and termination, ensuring the network transmission of underlying data. Through the socket mechanism, it implements functions such as transmission initiation, listening, connection reception, connection initiation, data reception, data sending, connection termination, and transmission termination, as shown in the appendix. Figure 4 As shown.

[0044] 2. Database replication and backup control program dbget

[0045] The database replication and backup control program, dbget, runs on the slave database side. As a command sender, it transmits database replication and backup instructions to the slave database replication and backup program, dbrepsql. These instructions include: start / stop commands, the port numbers used by the master and slave database replication and backup programs, the IP addresses of the master and slave devices, and the corresponding database names. The execution flow of the database replication and backup control program mainly involves the following steps:

[0046] (1) The user inputs a command and allows the program;

[0047] (2) The database replication and backup control program dbget parses the parameters entered by the user and checks their correctness. If the input command is incorrect, it prints the corresponding error message. If the command is correct, it continues to execute.

[0048] (3) Establish a connection with the slave's dbrepsql based on the parsed instruction information. If the connection fails, print the corresponding error message. If the connection is successful, continue execution.

[0049] (4) Send relevant command information to the slave dbrepsql and wait for the return result. If an error message is returned, print the corresponding error message. If the command is returned successfully, continue execution.

[0050] (5) Close the program and clean up related resources.

[0051] Example 1:

[0052] User source data is typically stored in a general-purpose database management system on a large server device. However, some data query and usage operations are performed on embedded devices. For example, some data stored on a large server needs to be filtered and used on an embedded device. The embedded device uses the replication and backup program dbrepsql to copy and back up the data from the main database (large server device) to the slave database (embedded device), thus completing the data replication and backup between different devices and different types of database management systems. Furthermore, after new data operations occur on the main database, the database replication and backup program dbrepsql can copy the data operations from the main database to the slave database.

[0053] The database replication backup program dbrepsql runs simultaneously on both the master and slave databases. On the master database, dbrepsql responds to requests from the slave database's dbrepsql. For the initial request from the slave's dbrepsql, the master database creates a thread dedicated to providing operation log files to the slave database until the slave database stops connecting. This thread receives log file requests from the slave database and searches its local directory for the corresponding operation log file. If the operation log file exists, dbrepsql sends it to the slave database via a network service. If the operation log file does not exist, the master dbrepsql sends a message to the slave dbrepsql indicating no new operation logs. The slave then requests the next operation log file from the master database at fixed intervals.

[0054] To make the objectives, content, and advantages of this invention clearer, the specific embodiments of this invention will be described in further detail below with reference to examples. When the main database is a large server system using the general-purpose database MySQL for data storage, and there is a small embedded device using an embedded database management system, the user needs to use data stored in the general-purpose database MySQL on the large server for task processing on the embedded platform, given the differences in hardware resources and database type. Therefore, this invention can be used to copy and back up newly generated data from the MySQL database to the embedded hardware platform using the dbrepsql backup program, thereby reducing the waste caused by resource replacement.

[0055] (1) Start the database replication and backup program dbrepsql on both the master and slave databases:

[0056] “. / dbrepsql–p 8080–d / home / dir / db_master-start”

[0057] “. / dbrepsql–p 21553–d / home / dir / db_slave-start”

[0058] It can be started using the command line. Different startup commands can be added according to specific startup requirements, such as starting from different paths or ports. The running status of the dbrepsql replication backup program can also be queried. The dbrepsql replication backup program starts a task to run an initialization function, requesting resources needed during the replication backup process; if unsuccessful, it closes the previously requested resources, deletes the started task, and terminates the current task; if successful, it continues execution.

[0059] Run the dbrepsql replication backup program. The program will lock the current directory to prevent multiple dbrepsql replication backup programs from starting. Then, it will open a network socket and enable the listening port. If it fails, it will terminate the dbrepsql replication backup program, clean up related resources, and end the current task program. If it succeeds, it will continue to loop and wait for a connection to be established.

[0060] (2) Start the database replication and backup control program dbget from the database side:

[0061] “. / dbget–b–p 21553–d / home / dir / db_slave-start”

[0062] After the master-slave database replication backup program dbrepsql starts, the database replication backup control program dbget needs to be used on the slave database to establish a connection between the master and slave databases. When running the replication backup control program dbget, you need to specify start / stop, port number, master and slave device IP and corresponding database name. The replication and backup control program `dbget` is a command sending program that sends the start / stop command, port number, master / slave device IP, and corresponding database name to the replication and backup program `dbrepsql` on the slave database side. The slave `dbrepsql` function initializes the replication and backup parameters, initializes resources needed by both the slave and master databases, and locks the current path to ensure only one service runs on that path. It also initializes network services and starts port listening. If execution fails, the `dbrepsql` function first unlocks the current path, allowing it to be restarted after this exit, and then sends a stop signal to the master database. Finally, the slave `dbrepsql` function releases resources requested by both the slave and master databases.

[0063] Once the master and slave databases establish a connection, they perform replication and backup. When the master database generates a new database operation log file, it is sent to the slave database via the network, thus completing one replication and backup cycle. This process is repeated until the replication and backup connection between the master and slave databases is terminated using the database replication and backup control program dbget or the network is interrupted.

[0064] Key points of the invention

[0065] This invention designs an embedded database replication and backup method. Based on an embedded database management system, this method performs data replication and backup on multiple devices with unbalanced resources. The master database is typically a large server with abundant hardware resources and a general-purpose database (such as MySQL, Oracle, Microsoft SQL Server, etc.), while the slave database is an embedded platform and embedded database management system with limited resources. The replication and backup program designed in this invention can establish a replication and backup link between the master and slave databases, thereby achieving the purpose of heterogeneous database replication and backup. This solves the data replication requirement between different databases. Furthermore, this method does not replicate the result of the data operation, but rather replicates the data operation action itself. That is, if a data write operation is performed on the master database, the write operation is copied to the slave database, thus ensuring that the master and slave databases achieve identical data operations. This invention avoids the need to replace embedded devices under conditions of unequal resources and enables data replication and backup between heterogeneous databases.

[0066] Effects of the present invention

[0067] This invention records the transaction operation process in an operation log file on the master database side. After the operation log file is transmitted to the slave database side via the network, the transaction operation is replayed on the slave database side, thereby realizing the replication and backup of data changes on the master database side to the slave database side. This allows users to perform database replication and backup between different devices or different locations on the same device via the network.

[0068] This invention provides an embedded database replication and backup method. Compared with the prior art, the advantages of this invention are:

[0069] 1. Achieving Heterogeneous Database Replication: This invention solves the data replication and backup problem between heterogeneous database management systems by parsing and replaying database operation logs (instead of directly applying native logs), thus shielding the internal differences between different database systems.

[0070] 2. Improved efficiency and stability: By maintaining a local copy of the data on the embedded device, frequent query operations are shifted from high-latency network access to local access, which greatly improves data query efficiency, reduces dependence on network stability, and enhances the ability to work in harsh network environments.

[0071] 3. The operation log files generated by the master database are reused and transmitted to the slave database, reducing the time spent on operation log files by the embedded database management system. At the same time, the data operation process in the operation log files is replayed on the slave database, realizing replication and backup between master and slave databases with unbalanced resources, reducing financial consumption, and solving the data backup problem between heterogeneous databases through replication and backup methods.

[0072] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. An embedded database replication and backup method, characterized in that, This method connects the master and slave databases through the database replication and backup program dbrepsql to build an embedded database replication and backup management system; the system includes: the database replication and backup program dbrepsql and the database replication and backup control program dbget; The database replication and backup program dbrepsql runs on both the master and slave database ends. dbrepsql is used for command and operation log file interaction between the master and slave database ends, including database replication / backup startup, shutdown, and status query services. The dbrepsql program comprises four modules: a log file management module, a command interaction processing module, a network data service (HTTP) module, and a data transmission transport module. The log file management module is used to manage the operation log files generated by the database replication and backup program dbrepsql during replication and backup, including the generation and parsing of operation log files; The command interaction processing module is responsible for handling command interactions between the master and slave databases. When both the master and slave databases start the database replication and backup program dbrepsql, the command interactions between these two nodes are received and processed by this module, and then fed back to the command initiating node. The data service HTTP module provides network service capabilities for the embedded database management system; The data transmission transport module provides TCP-based data transmission capabilities for the embedded database management system, enabling network data sending and receiving. The database replication and backup control program dbget runs on the slave database side. As a replication and backup control command sending program, it sends database replication and backup instructions to the database replication and backup program dbrepsql on the slave database side. These instructions include: replication and backup start / stop commands, the port number for starting the replication and backup program on both the master and slave database sides, the IP address of the master and slave devices, and the corresponding database name.

2. The embedded database replication and backup method as described in claim 1, characterized in that, The log file management module is responsible for saving newly generated data operations to the operation log file, which is then provided to the data transmission module for transmission. The log file management module operates on both the master and slave ends of the database. On the master end, it monitors changes in the database and records them to the operation log file. On the slave end, it parses the operation log file to obtain the database operation methods and replays these changes in the slave database.

3. The embedded database replication and backup method as described in claim 1, characterized in that, When a slave database requests a replication backup from the master database to establish a connection, the command is sent from the slave database to the master database via the network. The master database then establishes a connection with the slave database based on the connection command. After the connection is successfully established, the master and slave databases continue to exchange commands and provide feedback based on the command execution status.

4. The embedded database replication and backup method as described in claim 1, characterized in that, The data service HTTP module provides network service capabilities for the embedded database management system, including four components: basic HTTP services, HTTP service parsing, HTTP thread management, and remote connection processing. The HTTP basic service component provides the system with HTTP initialization, termination, start, stop, and shutdown services; The HTTP service parsing component performs preliminary parsing of received HTTP requests, including parameter initialization, command validity determination, parameter parsing, saving the obtained parameter information string into the parameter structure, and parameter release. The HTTP thread management component is used in embedded database management systems to support multi-user access. The remote connection processing component is used to process remote service requests, including obtaining HTTP requests, parsing the URL address information in the HTTP request, executing the commands for database operations on both the master and slave ends and the corresponding TFS operations, encapsulating the TFS processing results, and outputting the processing results.

5. The embedded database replication and backup method as described in claim 4, characterized in that, The HTTP thread management component is supported by three types of threads: the "http_srv" thread is used to initialize the HTTP service, listen on the given service port, start the "con_srv" thread, and handle resource reclamation after connection closure; the "con_srv" thread accepts external connection requests and allocates a new socket and con thread for each external connection to handle the corresponding transaction. There will only be one "con_srv" thread, while the number of "con" threads will be consistent with the number of external connection requests; the "con" thread is used to handle specific database request operations; after the transaction is completed, the thread enters the idle thread pool; when the number of threads is insufficient, new threads are created to provide services.

6. The embedded database replication and backup method as described in claim 1, characterized in that, The data transmission transport module establishes a TCP connection between the client and the server, executes data sending and termination, and ensures the network transmission of underlying data. It uses the socket mechanism to start transmission, start listening, receive connections, initiate connections, receive data, send data, disconnect, and terminate transmission.

7. The embedded database replication and backup method according to any one of claims 1-6, characterized in that, The execution flow of the database replication and backup control program dbget includes: (1) The user inputs a command and allows the program; (2) The database replication and backup control program dbget parses the parameters entered by the user and checks their correctness. If the input command is incorrect, it prints the corresponding error message. If the command is correct, it continues to execute. (3) Establish a connection with the slave's dbrepsql based on the parsed instruction information. If the connection fails, print the corresponding error message. If the connection is successful, continue execution. (4) Send relevant command information to the slave dbrepsql and wait for the return result. If an error message is returned, print the corresponding error message. If the command is returned successfully, continue execution. (5) Close the program and clean up related resources.

8. The embedded database replication and backup method as described in claim 7, characterized in that, The database replication backup program dbrepsql runs simultaneously on both the master and slave databases. On the master database, dbrepsql responds to requests from the slave database's dbrepsql. For the initial request from the slave's dbrepsql, the master database creates a thread dedicated to providing operation log files to the slave database until the slave database stops connecting. This thread receives log file requests from the slave database and searches its local directory for the corresponding operation log file. If the operation log file exists, dbrepsql sends it to the slave database via a network service. If the operation log file does not exist, the master database's dbrepsql sends a "no new operation log" message to the slave's dbrepsql. The slave's dbrepsql then requests the next operation log file from the master database at fixed intervals.

9. The embedded database replication and backup method as described in claim 7, characterized in that, Start the database replication and backup program dbrepsql on both the master and slave databases. The replication and backup program dbrepsql will start a task to run an initialization function and request the resources required during the replication and backup process. If it fails, it will close the corresponding previously requested resources, delete the started task, and end the current task. If successful, continue execution; run the replication backup program dbrepsql. The program will lock the current directory to prevent multiple replication backup programs dbrepsql from starting, then open the network socket and enable the listening port function; if unsuccessful, terminate the replication backup program dbrepsql, clean up related resources, and end the current task program; if successful, continue to loop and wait for a connection to be established.

10. The embedded database replication and backup method as described in claim 9, characterized in that, To start the database replication and backup control program dbget on the slave database side: After the master-slave database replication and backup program dbrepsql starts, you need to use dbget on the slave database side to establish a connection between the master and slave databases. When dbget runs, you need to specify start / stop, port number, master / slave device IP, and corresponding database name. dbget is a command sending program that sends the start / stop, port number, master / slave device IP, and corresponding database name specified in the run command to the slave database replication and backup program dbrepsql. The slave-side dbrepsql initialization function sets the replication and backup parameters, initializes the resources required by the slave database during operation, and initializes the resources required by the master database during operation. The slave-side dbrepsql... The function locks the current path to ensure that only one service runs under the current path on the local machine; initializes network services and starts port listening services; if execution fails, the database replication backup program `dbrepsql` is stopped. The function first unlocks the current path, allowing the database replication backup program `dbrepsql` to be restarted after this exit, and sends a stop signal to the master database. The slave database's replication backup program terminates, and the `dbrepsql` function releases resources requested during its operation on both the slave and master databases. After the master and slave databases establish a connection, they perform replication backup. New database operation log files generated by the master database are sent to the slave database via the network, completing one replication backup. This process is repeated until the database replication backup control program `dbget` disconnects the replication backup connection between the master and slave databases or the network is interrupted.

Citation Information

Patent Citations

  • Embedded database mirror image backup method and system

    CN115237671A