A database log backup method and device

By receiving database log backup tasks, obtaining and filtering incremental log files that meet the integrity conditions for backup, the problem of the inability to effectively restore the database to its pre-failure state in existing technologies is solved, and rapid database recovery and data security are achieved.

CN116263725BActive Publication Date: 2026-06-19NETSUNION CLEARING CORP

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NETSUNION CLEARING CORP
Filing Date
2021-12-13
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Existing database backup methods cannot effectively restore the database to any state before the failure, resulting in data loss and failing to meet actual business needs.

Method used

By receiving database log backup tasks, the system obtains log files that meet the integrity requirements to be backed up, selects incremental log files from them, and backs them up to the backup storage medium to ensure the integrity of the log files.

Benefits of technology

It enables rapid database recovery to any point in time, ensuring data security and meeting actual business needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116263725B_ABST
    Figure CN116263725B_ABST
Patent Text Reader

Abstract

This application discloses a database log backup method and apparatus. The method is executed by a database server and includes: receiving a database log backup task; obtaining log files that meet integrity conditions to be backed up according to the database log backup task; selecting incremental log files from the log files to be backed up; and backing up the incremental log files to a backup storage medium. The database log backup method of this application embodiment can ensure the backup of complete incremental log files. The backed-up log files can serve as a supplement to the data backup, thereby facilitating the rapid restoration of the database to any point in time before the backup, ensuring data security, and also meeting the business needs of real-world scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of database technology, and in particular to a database log backup method and apparatus. Background Technology

[0002] Data, as a factor of production, has become a crucial enterprise asset in the context of informatization, making data protection paramount. Database backups are essential in the event of lost or corrupted database tables or data center disasters. In the event of system crashes or other failures, the goal is typically to minimize data loss and restore the database to its most recent state at the time of the crash.

[0003] Currently, the main database used in distributed database systems is MySQL. Data backup is mainly performed using backup programs such as Mysqldump, Xtrabackup, and Mysqlbackup, or by directly copying database files using tools such as Cp, Cipo, or Tar.

[0004] However, while the above methods can restore the database to its state before the failure, they can only restore it to the state at the time of backup, and there will still be some data loss, which will result in the database failing to meet actual business needs in many scenarios. Summary of the Invention

[0005] This application provides a database log backup method and apparatus to ensure that database log backup meets actual business needs.

[0006] The embodiments of this application adopt the following technical solutions:

[0007] In a first aspect, embodiments of this application provide a database log backup method, executed by a database server, wherein the method includes:

[0008] Receive database log backup tasks;

[0009] Based on the database log backup task, obtain the log files to be backed up that meet the integrity requirements;

[0010] Select incremental log files from the log files to be backed up;

[0011] The incremental log files are backed up to the backup storage medium.

[0012] Optionally, obtaining the log files to be backed up that meet the integrity conditions according to the database log backup task includes:

[0013] Based on the database log backup task, determine the time point for obtaining the log files to be backed up;

[0014] Upon reaching the stated time point, check the current status of the database containing the log file to be backed up;

[0015] If the current state of the database meets the preset state, then the step of obtaining the log file to be backed up that meets the integrity conditions is executed;

[0016] If the current state of the database does not meet the preset state, the time point for obtaining the log file to be backed up is re-determined according to the waiting time configured in the database log backup task.

[0017] Optionally, the current state of the database includes the database load status and / or the status of the data backup task, and checking the current state of the database where the log file to be backed up is located includes:

[0018] If the database is in an idle state and / or the data backup task is in a non-running state, then the current state of the database is determined to satisfy the preset state.

[0019] If the database is in a busy state and / or the data backup task is in a running state, then it is determined that the current state of the database does not meet the preset state.

[0020] Optionally, the log files to be backed up include multiple log files arranged in chronological order, and obtaining the log files to be backed up that meet the integrity conditions according to the database log backup task includes:

[0021] Based on the database log backup task, log files that match the preset time range are selected as log files to be backed up;

[0022] Determine the latest log file among the log files to be backed up;

[0023] Check if there are any write operations in the latest log file;

[0024] If it exists, then the log files other than the latest log file in the log files to be backed up will be used as log files to be backed up that meet the integrity conditions.

[0025] If none exist, all log files to be backed up will be used as log files that meet the integrity requirements.

[0026] Optionally, the log files to be backed up include multiple log files, and the step of selecting incremental log files from the log files to be backed up includes:

[0027] Based on the characteristic identifier of the target log file, check whether the target log file exists in the backup storage medium, wherein the target log file is any one of a plurality of log files to be backed up;

[0028] If it exists, then the target log file will not be used as the incremental log file;

[0029] If it does not exist, the target log file will be used as the incremental log file.

[0030] Optionally, the log files to be backed up include multiple files, and the step of selecting incremental log files from the log files to be backed up includes:

[0031] Select incremental log files one by one from the log files to be backed up;

[0032] The step of backing up the incremental log file to the backup storage medium includes:

[0033] The incremental log files are backed up one by one to the backup storage medium.

[0034] Optionally, after backing up the incremental log files to the backup storage medium, the method further includes:

[0035] Check if a new incremental log file can be obtained within the preset time interval;

[0036] If possible, then repeat the step of backing up the incremental log file to the backup storage medium;

[0037] If not, perform a log file switching operation.

[0038] Optionally, the execution log file switching operation includes:

[0039] Identify the log file to be switched;

[0040] Create a new blank log file based on the log file to be switched, and perform log write operations in the blank log file;

[0041] Based on the creation result, the log file to be switched is used as the new incremental log file, and the new incremental log file is backed up to the backup storage medium.

[0042] Optionally, the method further includes:

[0043] Start the daemon process, and through the daemon process, perform the steps of receiving database log backup tasks and backing up the incremental log files to the backup storage medium.

[0044] Secondly, embodiments of this application also provide a database log backup device, applied to a backup server, wherein the device is used to implement any of the methods described above.

[0045] Thirdly, embodiments of this application also provide an electronic device, including:

[0046] Processor; and

[0047] A memory configured to store computer-executable instructions, which, when executed, cause the processor to perform any of the methods described above.

[0048] Fourthly, embodiments of this application also provide a computer-readable storage medium that stores one or more programs, which, when executed by an electronic device including multiple applications, cause the electronic device to perform any of the methods described above.

[0049] The above-mentioned at least one technical solution adopted in the embodiments of this application can achieve the following beneficial effects: The database log backup method of the embodiments of this application can be executed by a database server. When performing database log backup, a database log backup task can be received first; then, according to the database log backup task, log files that meet the integrity conditions to be backed up can be obtained; then, incremental log files can be selected from the log files to be backed up; finally, the incremental log files are backed up to the backup storage medium. The database log backup method of the embodiments of this application can ensure that complete incremental log files are backed up. The backed-up log files can serve as a supplement to the data backup, thereby facilitating the rapid restoration of the database to any point in time before the backup, ensuring data security, and also meeting actual business needs. Attached Figure Description

[0050] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments of this application and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0051] Figure 1 This is a flowchart illustrating a database log backup method according to an embodiment of this application;

[0052] Figure 2 This is a schematic diagram of the structure of a database log backup device according to an embodiment of this application;

[0053] Figure 3 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Detailed Implementation

[0054] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

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

[0056] To restore the database to its most recent state before the failure, log backups need to be added on top of data backups. In other words, combining data backups with log backups allows the database to be restored to any point in time. Current log backup solutions primarily involve copying the binary log files from the database to a backup machine or other backup storage media on a daily schedule. Alternatively, the binary log files can be synchronized to the backup storage media using a real-time synchronization tool like Rsync (Remote synchronize, a remote data synchronization tool).

[0057] However, while the above log backup solutions can meet the needs of most business scenarios, they also have their own problems. For example, if log files are copied periodically, each full copy of the log files in the directory will consume a lot of disk I / O and take a long time, which can easily affect core business. If incremental copying is performed using Rsync, the log file currently being written will be copied to the backup storage medium. If the log file is not yet full, the resulting log file will be incomplete. Backing up this incomplete log file will make it unusable during subsequent database recovery.

[0058] Based on this, embodiments of this application provide a database log backup method, executed by a database server, such as... Figure 1 The diagram illustrates a flowchart of a database log backup method according to an embodiment of this application. The method includes at least the following steps S110 to S140:

[0059] Step S110: Receive the database log backup task.

[0060] The database log backup method of this application embodiment can be executed by the server where each database resides. When performing database log backup, a database log backup task can be received first. This database log backup task can be understood as a specific instruction to perform a backup operation on the database. It can be issued separately by the task server, or it can be executed by a scheduled task pre-set in the database server. How to trigger the database log backup task can be flexibly set by those skilled in the art according to actual needs, and no specific limitation is made here.

[0061] Step S120: According to the database log backup task, obtain the log files to be backed up that meet the integrity conditions.

[0062] After receiving the database log backup task, it is necessary to determine which log files to be backed up exist on the current database server. The relevant information of the log files to be backed up can be automatically obtained from the specified directory of the database.

[0063] Since the database is still in use during the backup process of the database logs in this embodiment of the application, some log files to be backed up will still be in an operational state, that is, the logs in the log files to be backed up have not been written. If the log files to be backed up are backed up directly, the log files will not be able to be used when the database is restored later.

[0064] In other words, the log files to be backed up pulled from the specified directory of the database in this application embodiment may not all meet the actual backup requirements. Therefore, this application embodiment needs to obtain the log files to be backed up that meet the integrity conditions from all the log files to be backed up as the basis for subsequent backup, so as to avoid backing up incomplete log files and affecting subsequent data recovery.

[0065] Step S130: Select incremental log files from the log files to be backed up.

[0066] After obtaining the log files to be backed up that meet the integrity requirements, it is necessary to further filter out incremental log files from these log files. Incremental log files can be understood as log files that meet the integrity requirements but have not yet been backed up, that is, log files that meet the actual backup requirements.

[0067] Step S140: Back up the incremental log file to the backup storage medium.

[0068] Once the incremental log files that can be backed up are identified, they can be backed up to a backup storage medium. This backup storage medium can be a separately deployed machine for storing backup files, or any other type of storage medium, such as an external hard drive. Those skilled in the art can flexibly set the type of storage medium used for storing backup files according to actual needs, and no specific limitation is made here.

[0069] The database log backup method of this application embodiment can ensure that the complete incremental log file is backed up. The backed-up log file can be used as a supplement to the data backup, which facilitates the rapid restoration of the database to any point in time before the backup, ensuring data security and meeting the business needs of actual scenarios.

[0070] In one embodiment of this application, obtaining a log file to be backed up that meets the integrity conditions according to the database log backup task includes: determining a time point for obtaining the log file to be backed up according to the database log backup task; checking the current state of the database where the log file to be backed up is located when the time point is reached; if the current state of the database meets a preset state, then executing the step of obtaining the log file to be backed up that meets the integrity conditions; if the current state of the database does not meet the preset state, then re-determining the time point for obtaining the log file to be backed up according to the waiting time configured in the database log backup task.

[0071] After receiving a database log backup task, the start time and execution frequency of the backup operation can be determined based on the task. The start time and execution frequency can be set in advance according to actual business needs. For example, the start time of the log backup of database A can be set to xxxx year xx month xx day xx hour xx minute, and the execution frequency can be set to once per minute. When the current time reaches this set time point, the subsequent log backup operation will be automatically triggered.

[0072] Considering that log backup operations consume certain database server resources in actual business scenarios, in order to avoid affecting actual business operations, this embodiment of the application can check the current status of the database where the log file to be backed up is located before performing a specific log backup operation. If the current status of the database meets the preset status, it means that the database can currently provide certain resources for the log backup operation, so the subsequent steps of obtaining the log file to be backed up that meets the integrity conditions can be executed. If the current status of the database does not meet the preset status, it means that the database cannot currently provide enough resources for the log backup operation, so the subsequent log backup operation cannot be executed temporarily. In this case, the waiting time configured in the database log backup task can be used to wait for a period of time before re-executing the above steps of determining the time point for obtaining the log file to be backed up.

[0073] It should be noted that the start time, execution frequency, and waiting time configured in the above database log backup task can be set according to actual business needs. For example, for databases with a large workload, the execution frequency and waiting time can be set relatively low to meet the real-time backup requirements as much as possible. For databases with a small workload, the execution frequency and waiting time can be set relatively high to avoid frequently executing the above process and wasting server resources.

[0074] In one embodiment of this application, the current state of the database includes the database load state, and checking the current state of the database where the log file to be backed up is located includes: if the database load state is idle, then it is determined that the current state of the database meets the preset state; if the database load state is busy, then it is determined that the current state of the database does not meet the preset state.

[0075] The database status in this application embodiment may include the database load status. If the database server load is high, it indicates that the current business volume is large and the database may be in a peak business period. If a log backup operation is forcibly performed, it may affect other applications' access to the database, thereby affecting the actual business. Conversely, if the database server load is low, it indicates that the current business volume is small and the database may be in a business idle period. Performing a log backup operation will not affect the actual business.

[0076] Based on this, the embodiments of this application can check the current load status of the database. For example, the current load of the database service can be compared with a preset load threshold. If it is lower than the preset load threshold, it can be determined that the current load status of the database is idle, so subsequent log backup operations can be performed. If it is not lower than the preset load threshold, it can be determined that the current load status of the database is busy, so subsequent log backup operations cannot be performed temporarily.

[0077] In one embodiment of this application, the current state of the database includes the state of the data backup task, and checking the current state of the database where the log file to be backed up is located includes: if the state of the data backup task is non-running, then it is determined that the current state of the database meets the preset state; if the state of the data backup task is running, then it is determined that the current state of the database does not meet the preset state.

[0078] In real-world business scenarios, database backup mainly involves two dimensions: data backup and log backup. Data backup refers to backing up the actual data recorded in the database, while log backup refers to backing up the various log files generated by the database during the data recording process. Log backup mainly serves as a supplement to data backup. By combining data backup and log backup, the database can be restored to a specified point in time, thereby maximizing data security.

[0079] However, since the bandwidth of a database server is limited, and data backup tasks typically require a significant amount of bandwidth during execution, this embodiment of the application can also check whether a data backup task is currently running on the database server when checking the database status. If no data backup task is currently running on the database server, it indicates that the database currently meets the requirements for log backup operations. If a data backup task is currently running on the database server, it indicates that the database does not currently meet the requirements for log backup operations. In this case, the database can wait for a period of time until no data backup task is currently running on the database server before performing the log backup operation. This avoids the simultaneous execution of data backup tasks and log backup tasks, which could affect database I / O and bandwidth.

[0080] It should be noted that, in the above embodiments, when checking the current state of the database containing the log file to be backed up, a comprehensive judgment can also be made based on the database's load status and the status of the data backup task. For example, when the database's load status is idle and the data backup task's status is not running, it can be determined that the database's current state meets the preset state; while when the database's load status is busy, or the data backup task's status is running, it can be determined that the database's current state does not meet the preset state.

[0081] In one embodiment of this application, the log files to be backed up include multiple log files arranged in chronological order. The step of obtaining log files that meet the integrity conditions according to the database log backup task includes: filtering log files that match a preset time range according to the database log backup task as log files to be backed up; determining the latest log file among the log files to be backed up; checking whether there is a write operation in the latest log file; if so, then using all log files other than the latest log file among the log files to be backed up as log files that meet the integrity conditions; if not, then using all log files to be backed up as log files that meet the integrity conditions.

[0082] In this embodiment, when obtaining log files to be backed up, log files within a certain time period can be obtained according to the time range set in the database log backup task. For example, all log files from the most recent day can be obtained as the log files to be backed up, thus achieving the purpose of real-time backup. Of course, if the workload of the database server is relatively small in the actual business scenario and the real-time requirements for backup are relatively low, a scheduled backup method can also be used. For example, all log files within the time period T1-T2 (not the current time) can be obtained as the log files to be backed up. How to configure this is flexible and can be set by those skilled in the art according to actual needs; no specific limitations are made here.

[0083] In real-world business scenarios, database services continuously generate log files during normal business processing. The amount of logs stored in each log file, or the size of a log file, can be configured in advance. For example, the size of a log file can be set to 1GB. When the amount of logs written to this log file reaches 1GB, a new blank log file will be automatically generated to continue writing logs.

[0084] In other words, under normal circumstances, only the latest log file among the log files to be backed up obtained in the above embodiments may contain write operations. Based on this, the embodiments of this application can directly check whether there are write operations in the latest log file. If there are, it means that the latest log file does not meet the integrity condition. Therefore, only all other log files besides the latest log file can be considered as log files that meet the integrity condition. Conversely, if there are no write operations in the latest log file, it means that the latest log file meets the integrity condition. Therefore, all log files to be backed up can be considered as log files that meet the integrity condition.

[0085] By following the above inspection process, we can avoid backing up the log file that is currently being written, thus ensuring the integrity of the backed-up log file and preventing the database recovery operation from failing due to an incomplete backup log file.

[0086] In one embodiment of this application, the log file to be backed up includes multiple log files, and the step of selecting the incremental log file from the log file to be backed up includes: checking whether the target log file exists in the backup storage medium according to the feature identifier of the target log file, wherein the target log file is any one of the multiple log files to be backed up; if it exists, the target log file is not used as the incremental log file; if it does not exist, the target log file is used as the incremental log file.

[0087] To improve the efficiency of log file backup, this application embodiment can use incremental backup to back up log files, that is, only newly generated log files that have not yet been backed up are backed up in the log files to be backed up.

[0088] Specifically, the log files to be backed up obtained above can include multiple log files. For any one of the target log files, a search and matching process can be performed on the backup storage medium based on the target log file's characteristic identifiers, such as file name and hash value, to determine whether the target log file already exists on the backup storage medium. If it exists, it means that the target log file has already been backed up, and no further backup is needed. If it does not exist, it means that the target log file has not yet been backed up, and it can be used as an incremental log file for backup. The remaining log files in the log files to be backed up are traversed sequentially according to the above process to determine the final incremental log file.

[0089] In one embodiment of this application, backing up the incremental log file to the backup storage medium includes: compressing the incremental log file; and backing up the compressed incremental log file to the backup storage medium.

[0090] In this embodiment of the application, when backing up incremental log files to the backup storage medium, the incremental log files can first be compressed, for example, into a GZ format log file. Of course, those skilled in the art can flexibly set the specific log file format according to actual needs, and no specific limitation is made here. Then, the compressed incremental log files are copied to the backup storage medium, thereby reducing the amount of data transferred, improving transfer efficiency, and saving storage space on the backup storage medium.

[0091] In one embodiment of this application, the log files to be backed up include multiple files, and the step of selecting incremental log files from the log files to be backed up includes: selecting incremental log files one by one from the log files to be backed up; the step of backing up the incremental log files to the backup storage medium includes: backing up the incremental log files one by one to the backup storage medium.

[0092] As mentioned above, there are usually multiple log files to be backed up in the embodiments of this application. When filtering incremental log files, multiple log files in the log files to be backed up can be judged one by one. If there are also multiple incremental log files, multiple incremental log files can be compressed one by one when backing up the incremental log files, and then copied to the backup storage medium one by one.

[0093] In other words, the automated backup process described above compresses each incremental log file as it is selected, and then directly copies it to the backup storage medium. This eliminates the need to wait for all incremental log files to be selected before compressing and copying them all at once. This improves the real-time performance of log backups and increases the probability of successful backups. This is because transmitting a large amount of data at once requires more network bandwidth and takes longer, resulting in poor real-time performance. Furthermore, network interruptions or other anomalies can cause all incremental log files in that batch to fail to copy, further reducing the probability of successful log backups.

[0094] It should be noted that if the network is relatively stable in the actual business scenario and the network bandwidth pressure on the database server is relatively low, then a unified compression and unified copying approach can also be used for log backup. Therefore, those skilled in the art can flexibly adjust the specific settings according to the actual situation.

[0095] In one embodiment of this application, after backing up the incremental log file to the backup storage medium, the method further includes: checking whether a new incremental log file can be obtained within a preset time interval; if so, then performing the step of backing up the incremental log file to the backup storage medium again; if not, then performing a log file switching operation.

[0096] The database log backup method of this application embodiment can be regarded as a cyclic execution process. The execution frequency can be set in advance in the database backup task, for example, set to execute once per minute. After the current cycle is completed, the next cycle will be executed automatically according to the set execution frequency. If a new incremental log file is generated during the cycle, the above log backup operation can be repeated for the newly generated incremental log file. If no new incremental log file is generated during the cycle, the cycle ends, and a new cycle will be executed according to the set execution frequency, and so on.

[0097] If no new incremental log file is generated after multiple iterations, it indicates that the database server may be in a period of low business activity, with a small amount of data being written and consequently a small amount of logs being generated. As a result, the latest log file may not be full yet. Therefore, in order to ensure timely log backup, a log file switching operation can be performed on the latest log file to back it up promptly.

[0098] In one embodiment of this application, the log file switching operation includes: determining the log file to be switched; creating a new blank log file based on the log file to be switched, and performing log write operations in the blank log file; and, based on the creation result, using the log file to be switched as a new incremental log file to back up the new incremental log file to the backup storage medium.

[0099] In this embodiment of the application, when performing a log file switching operation, the log file to be switched to can be determined first, which is the latest log file in the above embodiment. This is because generally only the latest log file is not yet full, thus not meeting the log file integrity condition. Then, a blank log file can be created based on the latest log file. All newly generated logs will be written to this newly created blank log file, and the original latest log file will become a static file, meaning there will be no more log writing operations. This satisfies the log file integrity condition, allowing for subsequent log backup operations.

[0100] This application embodiment enables timely backup of log files through log file switching operations, meeting the business needs of real-world scenarios and improving database log backup efficiency.

[0101] In one embodiment of this application, the method further includes: starting a daemon process, and executing a database log backup task through the daemon process to back up the incremental log file to a backup storage medium.

[0102] The entire database log backup process in this embodiment can be run as a daemon process to prevent the backup from being interrupted due to unknown reasons. A daemon process is a special type of process that runs in the background to perform specific system tasks. Some daemon processes start when the system boots and run until the system shuts down, while others only start when needed and automatically terminate after completing their tasks.

[0103] The daemon process in this embodiment can be started in real time, so that backups can be performed as soon as new incremental log backup files are generated, and log files can be actively switched and backed up when no new incremental log backup files are generated for a long time, ensuring the timeliness of log backups.

[0104] This application also provides a database log backup device 200, applied to a backup server, such as... Figure 2 The diagram shows a schematic representation of a database log backup device according to an embodiment of this application. The device 200 includes: a receiving unit 210, an acquiring unit 220, a filtering unit 230, and a backup unit 240, wherein:

[0105] Receiving unit 210 is used to receive database log backup tasks;

[0106] The acquisition unit 220 is used to acquire a log file to be backed up that meets the integrity conditions according to the database log backup task.

[0107] Filtering unit 230 is used to filter incremental log files from the log files to be backed up;

[0108] Backup unit 240 is used to back up the incremental log file to a backup storage medium.

[0109] In one embodiment of this application, the acquisition unit 220 is specifically configured to: determine the time point for acquiring the log file to be backed up according to the database log backup task; when the time point is reached, check the current state of the database where the log file to be backed up is located; if the current state of the database meets a preset state, then execute the step of acquiring the log file to be backed up that meets the integrity conditions; if the current state of the database does not meet the preset state, then re-determine the time point for acquiring the log file to be backed up according to the waiting time configured in the database log backup task.

[0110] In one embodiment of this application, the current state of the database includes the database load state and / or the state of the data backup task. The acquisition unit 220 is specifically configured to: if the database load state is idle, and / or the data backup task state is non-running, then determine that the current state of the database satisfies the preset state; if the database load state is busy, and / or the data backup task state is running, then determine that the current state of the database does not satisfy the preset state.

[0111] In one embodiment of this application, the log files to be backed up include multiple log files arranged in chronological order. The acquisition unit 220 is specifically used for: filtering log files that match a preset time range according to the database log backup task, as log files to be backed up; determining the latest log file among the log files to be backed up; checking whether there is a write operation in the latest log file; if there is, then taking the log files other than the latest log file among the log files to be backed up as log files to be backed up that meet the integrity condition; if there is no write operation, then taking all log files to be backed up as log files to be backed up that meet the integrity condition.

[0112] In one embodiment of this application, the log file to be backed up includes multiple log files, and the filtering unit 230 is specifically used to: check whether a target log file exists in the backup storage medium according to the feature identifier of the target log file, wherein the target log file is any one of the multiple log files to be backed up; if it exists, the target log file is not used as the incremental log file; if it does not exist, the target log file is used as the incremental log file.

[0113] In one embodiment of this application, the backup unit 240 is specifically used to: compress the incremental log file; and back up the compressed incremental log file to the backup storage medium.

[0114] In one embodiment of this application, the log files to be backed up include multiple files, and the filtering unit 230 is specifically used to: filter out incremental log files one by one from the log files to be backed up; the backup unit 240 is specifically used to: back up the incremental log files one by one to the backup storage medium.

[0115] In one embodiment of this application, the apparatus further includes: a checking unit, configured to check whether a new incremental log file can be obtained within a preset time interval; a first execution unit, configured to, if possible, execute the step of backing up the incremental log file to the backup storage medium again; and a second execution unit, configured to, if not possible, execute a log file switching operation.

[0116] In one embodiment of this application, the second execution unit is specifically used to: determine the log file to be switched; create a new blank log file based on the log file to be switched, and perform log write operations in the blank log file; and, based on the creation result, use the log file to be switched as a new incremental log file to back up the new incremental log file to the backup storage medium.

[0117] In one embodiment of this application, the apparatus further includes: a startup unit, configured to start a daemon process, and execute the steps of receiving database log backup tasks to backing up the incremental log files to a backup storage medium through the daemon process.

[0118] It is understood that the above-described database log backup device can implement all the steps of the database log backup method executed by the backup server provided in the foregoing embodiments. The relevant explanations of the database log backup method are applicable to the database log backup device and will not be repeated here.

[0119] Figure 3 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Please refer to it. Figure 3 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and memory. The memory may include main memory, such as high-speed random-access memory (RAM), or non-volatile memory, such as at least one disk drive. Of course, the electronic device may also include other hardware required for other business operations.

[0120] The processor, network interface, and memory can be interconnected via an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. This bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 3 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.

[0121] Memory is used to store programs. Specifically, programs may include program code, which includes computer operation instructions. Memory may include main memory and non-volatile memory, and provides instructions and data to the processor.

[0122] The processor reads the corresponding computer program from non-volatile memory into main memory and then runs it, forming a database log backup device at the logical level. The processor executes the program stored in memory and specifically performs the following operations:

[0123] Receive database log backup tasks;

[0124] Based on the database log backup task, obtain the log files to be backed up that meet the integrity requirements;

[0125] Select incremental log files from the log files to be backed up;

[0126] The incremental log files are backed up to the backup storage medium.

[0127] The above is as stated in this application. Figure 1 The method executed by the database log backup device disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by integrated logic circuits in the processor's hardware or by instructions in software form. The processor can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method.

[0128] The electronic device can also perform Figure 1 The method for executing the database log backup device, and the implementation of the database log backup device in... Figure 1The functions of the embodiments shown are not described in detail here.

[0129] This application also proposes a computer-readable storage medium that stores one or more programs, the programs including instructions that, when executed by an electronic device including multiple applications, enable the electronic device to perform... Figure 1 The method executed by the database log backup device in the illustrated embodiment is specifically used to perform:

[0130] Receive database log backup tasks;

[0131] Based on the database log backup task, obtain the log files to be backed up that meet the integrity requirements;

[0132] Select incremental log files from the log files to be backed up;

[0133] The incremental log files are backed up to the backup storage medium.

[0134] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0135] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0136] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1The function specified in one or more boxes.

[0137] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0138] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0139] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0140] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0141] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0142] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0143] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A database log backup method, performed by a database server, wherein, The method includes: Receive database log backup tasks; Based on the database log backup task, obtain the log files to be backed up that meet the integrity requirements; Select incremental log files from the log files to be backed up; Back up the incremental log files to the backup storage medium; After backing up the incremental log file to the backup storage medium, the method further includes: Check if a new incremental log file can be obtained within the preset time interval; If possible, then repeat the step of backing up the incremental log file to the backup storage medium; If not, perform a log file switching operation; The execution log file switching operation includes: If the latest log file is not full, perform the log file switching operation on the latest log file to back it up; The log files to be backed up include multiple log files arranged in chronological order. The step of obtaining the log files that meet the integrity requirements for backup according to the database log backup task includes: Based on the database log backup task, log files that match the preset time range are selected as log files to be backed up; Determine the latest log file among the log files to be backed up; Check if there are any write operations in the latest log file; If it exists, then the log files other than the latest log file in the log files to be backed up will be used as log files to be backed up that meet the integrity conditions. If none exist, all log files to be backed up will be used as log files that meet the integrity requirements.

2. The method of claim 1, wherein, The step of obtaining the log files to be backed up that meet the integrity conditions according to the database log backup task includes: Based on the database log backup task, determine the time point for obtaining the log files to be backed up; Upon reaching the stated time point, check the current status of the database containing the log file to be backed up; If the current state of the database meets the preset state, then the step of obtaining the log file to be backed up that meets the integrity conditions is executed; If the current state of the database does not meet the preset state, the time point for obtaining the log file to be backed up is re-determined according to the waiting time configured in the database log backup task.

3. The method of claim 2, wherein, The current state of the database includes the database load status and / or the status of the data backup task. Checking the current state of the database where the log file to be backed up is located includes: If the database is in an idle state and / or the data backup task is in a non-running state, then the current state of the database is determined to satisfy the preset state. If the database is in a busy state and / or the data backup task is in a running state, then it is determined that the current state of the database does not meet the preset state.

4. The method of claim 1, wherein, The log files to be backed up include multiple log files, and the step of selecting incremental log files from the log files to be backed up includes: Based on the characteristic identifier of the target log file, check whether the target log file exists in the backup storage medium, wherein the target log file is any one of a plurality of log files to be backed up; If it exists, then the target log file will not be used as the incremental log file; If it does not exist, the target log file will be used as the incremental log file.

5. The method of claim 1, wherein, The log files to be backed up include multiple files, and the step of selecting incremental log files from the log files to be backed up includes: Select incremental log files one by one from the log files to be backed up; The step of backing up the incremental log file to the backup storage medium includes: The incremental log files are backed up one by one to the backup storage medium.

6. The method of claim 1, wherein, The execution log file switching operation includes: Identify the log file to be switched; Create a new blank log file based on the log file to be switched, and perform log write operations in the blank log file; Based on the creation result, the log file to be switched is used as the new incremental log file, and the new incremental log file is backed up to the backup storage medium.

7. The method of claim 1, wherein, The method further includes: Start the daemon process, and through the daemon process execute the steps of receiving database log backup tasks and backing up the incremental log files to the backup storage medium.

8. A database log backup apparatus applied to a backup server, wherein, The apparatus is used to implement the method according to any one of claims 1 to 7.