CN110874287B - Backup and recovery method and device for data in database and electronic equipment - Google Patents

Backup and recovery method and device for data in database and electronic equipment Download PDF

Info

Publication number
CN110874287B
CN110874287B CN201811014535.9A CN201811014535A CN110874287B CN 110874287 B CN110874287 B CN 110874287B CN 201811014535 A CN201811014535 A CN 201811014535A CN 110874287 B CN110874287 B CN 110874287B
Authority
CN
China
Prior art keywords
backup
database
data
file
checkpoints
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811014535.9A
Other languages
Chinese (zh)
Other versions
CN110874287A (en
Inventor
郑涔
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201811014535.9A priority Critical patent/CN110874287B/en
Publication of CN110874287A publication Critical patent/CN110874287A/en
Application granted granted Critical
Publication of CN110874287B publication Critical patent/CN110874287B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention provides a method and a device for backing up and recovering data in a database and electronic equipment, wherein the backup method comprises the following steps: creating backup checkpoints in a database, wherein all old checkpoints are automatically deleted after new checkpoints are created except the backup checkpoints; generating a backup metadata file and a table data file of the data table based on metadata of the data table generated after the backup check point operation; copying the backup metadata file and the table data file to a backup storage path; and marking that the database is in a backup stage in the process of generating and copying the backup metadata file and the table data file to a backup storage path so as to enable other components of the database to enter a preset backup working state. The scheme of the embodiment of the invention can effectively solve the problem of rapid increase of the storage space occupied by the data file and Journal log during the backup of the database.

Description

Backup and recovery method and device for data in database and electronic equipment
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for backing up and recovering data in a database, and an electronic device.
Background
Contemporary databases often use checkpoint (checkpoint) techniques to achieve persistence of data. In addition to the checkpoint technology, contemporary databases also typically use Journal logs to achieve finer granularity data persistence.
The checkpoint technique may be used to implement backup restoration in addition to data persistence. During the backup process, the database will turn off the auto-delete function of the checkpoint (new checkpoint will still be automatically created periodically) while turning off the auto-delete function of the Journal log file. The data files and Journal log take up memory space that would grow very quickly if the database were still continuing to provide normal service, as the old checkpoint and Journal log files were not deleted. Therefore, there are also existing schemes that add global write locks to the database during the backup process, halting continued service, but doing so sacrifices service availability and affects more.
Disclosure of Invention
The invention provides a method and a device for backing up and recovering data in a database and electronic equipment, which can effectively solve the problem of rapid increase of storage space occupied by data files and Journal logs during the backup of the database.
In order to achieve the above purpose, the embodiment of the present invention adopts the following technical scheme:
in a first aspect, a method for backing up data in a database is provided, including:
creating backup checkpoints in a database, wherein all old checkpoints are automatically deleted after new checkpoints are created except the backup checkpoints;
generating a backup metadata file and a table data file of the data table based on metadata of the data table generated after the backup check point operation;
copying the backup metadata file and the table data file to a backup storage path;
and marking that the database is in a backup stage in the process of generating and copying the backup metadata file and the table data file to a backup storage path so as to enable other components of the database to enter a preset backup working state.
In a second aspect, a method for recovering data in a database is provided, including:
copying the backup metadata file and the table data file obtained by backup into a designated directory of a database;
starting and controlling a database to load the backup metadata files in the appointed catalogue and the data in the table data files so as to restore the data in the database;
The backup metadata file and the table data file are obtained by backup by adopting the backup method of the data in the database according to the first aspect.
In a third aspect, there is provided a backup apparatus for data in a database, including:
the system comprises a checkpoint creation module, a backup checkpoint and a backup checkpoint generation module, wherein the checkpoint creation module is used for creating backup checkpoints in a database, and all old checkpoints are automatically deleted after new checkpoints are created except the backup checkpoints;
the backup data generation module is used for generating a backup metadata file and a table data file of the data table based on metadata of the data table generated after the backup check point operation;
the backup data storage module is used for copying the backup metadata file and the table data file to a backup storage path;
and the backup state control module is used for marking the database to be in a backup stage in the process of generating and copying the backup metadata file and the table data file to a backup storage path so as to enable other components of the database to enter a preset backup working state.
In a fourth aspect, there is provided a device for recovering data in a database, including:
the backup data copying module is used for copying the backup metadata files and the table data files obtained by backup into the appointed catalogue of the database;
The database recovery module is used for starting and controlling the database to load the backup metadata files in the appointed catalogue and the data in the table data files so as to recover the data in the database;
the backup metadata file and the table data file are obtained by backup by adopting the backup method of the data in the database according to the first aspect.
In a fifth aspect, there is provided an electronic device comprising:
a memory for storing a program;
a processor coupled to the memory for executing the program for:
creating backup checkpoints in a database, wherein all old checkpoints are automatically deleted after new checkpoints are created except the backup checkpoints;
generating a backup metadata file and a table data file of the data table based on metadata of the data table generated after the backup check point operation;
copying the backup metadata file and the table data file to a backup storage path;
and marking that the database is in a backup stage in the process of generating and copying the backup metadata file and the table data file to a backup storage path so as to enable other components of the database to enter a preset backup working state.
In a sixth aspect, there is provided another electronic device comprising:
a memory for storing a program;
a processor coupled to the memory for executing the program for:
copying the backup metadata file and the table data file obtained by backup into a designated directory of a database;
starting and controlling a database to load the backup metadata files in the appointed catalogue and the data in the table data files so as to restore the data in the database;
the backup metadata file and the table data file are obtained by backup by adopting the backup method of the data in the database according to the first aspect.
The invention provides a method and a device for backing up and recovering data in a database and electronic equipment. When the database is backed up, a backup check point is created, and all old check points except the backup check point are set to be automatically deleted after a new check point is created; then generating and copying a backup metadata file and a table data file of the data table based on metadata of the data table generated after the backup check point operation; meanwhile, in the process of generating and copying the backup metadata file and the table data file, the database is marked in the backup stage, so that other components of the database enter a preset backup working state, and the sequential progress of the backup process is ensured. Based on the metadata file and the table data file which are copied in the backup process, the quick recovery of the data in the database can be realized. According to the scheme, only one old check point, namely the backup check point, is reserved during database backup, and only the data of the backup check point is restored when the database is restored, so that the problem of rapid increase of disk space during backup is effectively solved although the instantaneity of some restored data is sacrificed.
The foregoing description is only an overview of the technical solutions of the present application, and may be implemented according to the content of the specification in order to make the technical means of the present application more clearly understood, and in order to make the above-mentioned and other objects, features and advantages of the present application more clearly understood, the following detailed description of the present application will be given.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the application. Also, like reference numerals are used to designate like parts throughout the figures. In the drawings:
FIG. 1 is a schematic diagram of a data backup process in a database according to the prior art;
FIG. 2a is a schematic logic diagram of the pre-backup stage shown in FIG. 1;
FIG. 2b is a logic diagram of the backup phase shown in FIG. 1;
FIG. 2c is a logic diagram of the post-backup phase shown in FIG. 1;
FIG. 3 is a schematic diagram of a prior art data recovery logic in a database;
FIG. 4a is a schematic diagram of a pre-portion stage according to an embodiment of the present invention;
FIG. 4b is a schematic diagram illustrating a backup phase according to an embodiment of the present invention;
FIG. 4c is a schematic diagram illustrating a post-backup phase according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of data recovery logic in a database according to an embodiment of the present invention;
FIG. 6 is a block diagram of a data backup and restore system in a database according to an embodiment of the present invention;
FIG. 7 is a flowchart of a method for backing up data in a database according to an embodiment of the present invention;
FIG. 8 is a flowchart of a second method for backing up data in a database according to an embodiment of the present invention;
FIG. 9 is a flowchart of a method for recovering data in a database according to an embodiment of the present invention;
FIG. 10 is a diagram illustrating a first configuration of a backup device for data in a database according to an embodiment of the present invention;
FIG. 11 is a diagram illustrating a second embodiment of a backup device for data in a database;
FIG. 12 is a diagram of a recovery device for data in a database according to an embodiment of the present invention;
FIG. 13 is a schematic diagram of an electronic device according to an embodiment of the present invention;
fig. 14 is a schematic diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
Generally, the data backup process in the database mainly includes three stages, as shown in fig. 1, namely a backup stage, a backup stage and a post backup. Wherein:
in the preparation stage, the main operation is to acquire backup metadata files of the checkpoint and table data files of a data table pointed to by the metadata files based on a checkpoint technology.
The backup stage, the main operation is to copy the backup data (metadata file and table data file) generated in the backup stage to the backup storage path. The backup storage path is a storage path except for a database system path, so that the backup data cannot be lost or damaged after the database is down.
The post-backup stage is mainly to remove the pre-backup stage, and performs additional setting operations for the backup process, such as turning off the auto-delete function of the checkpoint in the pre-backup stage (the old checkpoint will be automatically deleted after the new checkpoint is created) so as to avoid the automatic deletion of the backup metadata, and turning on the auto-delete function of the checkpoint after the backup stage is completed, so that the database can perform the normal checkpoint operation function.
Correspondingly, the data recovery flow in the database is simpler than the storage flow, and the data in the database can be recovered after the pre-backup data file is loaded in the starting process of the database.
As shown in fig. 2a, 2b and 2c, the process logic diagrams of the backup stage, the backup stage and the post-backup stage included in the data backup process in the database in the prior art are sequentially shown.
As shown in fig. 2a, the pre-portioning stage includes:
step 1, a backup mark is set in the database to mark that the current database is in a backup state, so that other components in the database assist in completing the backup process smoothly, such as ensuring that only one backup can be performed at the same time point, preventing the table data file to be backed up from being deleted, preventing the table data file from being truncated, and the like.
Step 2, turning off the auto-delete function of the checkpoint (new checkpoint is still automatically created periodically).
And 3, closing the automatic deleting function of the Journal log file.
The aim of executing the step 2 and the step 3 is to ensure that data cannot be lost in the database backup process.
Step 4: and generating a backup metadata file according to the latest checkpoint.
A backup metadata file is generated and metadata corresponding to the latest checkpoint at this time is output to the file.
Step 5: and outputting the table data file, the journ log file and the backup metadata file which need to be copied.
Wherein the table data file is a file (not limited to a table form) in which table data contained in a database is recorded; the Journal log in the Journal log file is the Journal log generated after the latest checkpoint.
For example, the file data may be output to a storage path of a directory where the database system is located, or to a designated data output port.
As shown in fig. 2b, the backup phase includes:
copying the table data file, the journ log file and the backup metadata file to a backup storage path, thereby completing the substantial backup process of database backup. The backup storage path is a storage path other than the database system path, so that the backup data is not lost or damaged after the database is down.
As shown in fig. 2c, the post-backup phase includes:
and step 1, canceling the backup mark in the database, so that other components in the database can acquire that the backup state of the current database is relieved, and the components can be restored to the normal working state.
And 2, recovering the automatic deleting function of the checkpoint.
And step 3, recovering the automatic deleting function of the journ log file.
FIG. 3 is a logic diagram of a data recovery process in a database according to the prior art, which includes:
And step 1, copying all files (including table data files, journ log files and backup metadata files) copied in the backup stage into a designated directory of a database. The specified directory is dedicated to storing the loading data required at database start-up.
And 2, starting the database.
After the database is started, the loading of the data under the appointed catalogue is automatically carried out, so that the data corresponding to the database at the backup time node is restored.
In summary, the automatic deletion function of the checkpoint and Journal log files is turned off in the conventional database backup method, so as to prevent the recovery of the data space pointed by the checkpoint corresponding to the backup during the copying of the data file, and the failure of restoring the data to the updated state due to the deletion of the Journal log file. However, the biggest problem caused by this automatic closing of the automatic deletion function of the checkpoint and Journal log files is that if the database is still continuously providing normal service during the entire backup process, the storage space occupied by the data files and Journal log will grow very fast because the old checkpoint and Journal log files are not deleted, thereby putting a great storage pressure on the disk.
The embodiment of the invention improves the backup flow aiming at the data in the database in the prior art, only one old checkpoint is reserved in the backup period of the database, namely the backup checkpoint, and only the data of the backup checkpoint is restored when the database is restored, and the problem of rapid increase of disk space in the backup period is effectively solved although the instantaneity of some restored data is sacrificed.
The embodiment of the invention still follows the whole backup flow of the database backup in the prior art, namely still comprises the following steps: a pre-backup stage, a backup stage and a post-backup stage. But with some modifications to the stages.
First, as shown in fig. 4a, a process logic diagram of a pre-backup stage in a data backup process in a database according to an embodiment of the present invention includes:
step 1, enabling the database to create a backup checkpoint.
First, the database is caused to create a special backup checkpoint that needs to be explicitly created and deleted. I.e. it needs to be created and deleted by the outside world through an interface. This backup checkpoint is created every time a backup is made and only one is created. Correspondingly, the data is restored to the checkpoint when the database is restored.
At this point, the database will delete old checkpoints other than the backup checkpoints as it continues to create new checkpoints. This arrangement ensures that the automatic deletion function of ordinary checkpoints other than the backup checkpoints is not turned off during backup, and the automatic deletion function is not turned off for Journal log files.
Step 2: a backup mark is set in the database.
The main function of the backup mark is the same as that of the backup mark in the prior art, and the backup mark is used for marking that the current database is in a backup state, so that other components in the database assist in smoothly completing the backup process, such as ensuring that only one backup can be performed at the same time point, preventing the table data file to be backed up from being deleted, preventing the table data file from being truncated, and the like.
Step 3: and generating a backup metadata file according to the backup checkpoint.
And generating a backup metadata file, and outputting metadata corresponding to the backup checkpoint to the file.
Step 4: and outputting the table data file to be copied and the backup metadata file.
The table data file is a file (not limited to a table format) in which table data included in a database is recorded.
For example, the file data may be output to a storage path of a directory where the database system is located, or to a designated data output port.
Next, as shown in fig. 4b, a schematic process logic diagram of a backup stage in a data backup process in a database according to an embodiment of the present invention includes:
copying the table data file and the backup metadata file to a backup storage path. The difference from the backup phase in the prior art is that the copied file does not contain a journ log file.
Next, as shown in fig. 4c, a schematic process logic diagram of a post-backup stage in a data backup process in a database according to an embodiment of the present invention includes:
and step 1, canceling the backup mark in the database.
And step 2, explicitly deleting the backup checkpoint.
Explicit deletion of a backup checkpoint means that deletion of the backup checkpoint is performed by a deletion operation (e.g., manual deletion) triggered from outside the database system.
Correspondingly, as shown in fig. 5, a logic schematic diagram of a recovery process in a data backup process in a database according to an embodiment of the present invention includes:
step 1, copying all files (including table data files and backup metadata files) copied in the backup stage into an empty data directory. The specified directory is dedicated to storing the loading data required at database start-up.
And 2, starting the database and loading data.
After the database is started, the loading of the data under the appointed catalogue is automatically carried out, so that the data corresponding to the database at the backup time node is restored.
In summary, the database backup method provided by the embodiment of the invention does not need to close the automatic deletion function of the checkpoint and Journal log files, and can realize the backup process by only keeping an old backup checkpoint. In this way, the database can still continue to provide normal service in the whole backup process, and the backup points of other old non-backup points are still deleted normally, so that the problem that the storage space occupied by the data file and Journal log can grow quickly is avoided, huge storage pressure can not be brought to a disk, and only the backup points are needed to be stored additionally.
Based on the foregoing solution idea of backup and recovery of data in a database provided by the embodiment of the present invention, fig. 6 is a structural diagram of a backup and recovery system of data in a database provided by the embodiment of the present invention. As shown in fig. 6, the system includes a database system 610, a backup device 620 of data in the database, and a recovery device 630 of data in the database, wherein:
Database system 610 may employ data modification that is not in place and employs a checkpoint technique to effect data persistence.
And the backup device 620 is configured to set a backup checkpoint in the database to backup the backup metadata file and the corresponding table data file of the backup checkpoint.
And the recovery device 630 is configured to recover the data in the database based on the backup metadata file backed up by the backup device 620 and the corresponding table data file.
The backup device 620 for data in the database includes:
the system comprises a check point creation module, a backup check point creation module and a storage module, wherein the check point creation module is used for creating backup check points in a database, and all old check points are automatically deleted after new check points are created except the backup check points;
the backup data generation module is used for generating a backup metadata file and a table data file of the data table based on metadata of the data table generated after the backup check point operation;
the backup data storage module is used for copying the backup metadata files and the table data files to the backup storage path;
and the backup state control module is used for marking the database in a backup stage in the process of generating and copying the backup metadata file and the table data file to the backup storage path so as to enable other components of the database to enter a preset backup working state.
The recovery device 630 of the data in the database includes:
the backup data copying module is used for copying the backup metadata files and the table data files obtained by backup into the appointed catalogue of the database;
the database recovery module is used for starting and controlling the database to load the backup metadata files in the appointed catalogue and the data in the table data files so as to recover the data in the database;
the backup metadata file and the table data file are obtained by backup of the backup device 620 for the data in the database.
The technical solution of the present application is further described below by a plurality of embodiments.
Example 1
Based on the foregoing concept of the backup solution of the data in the database, as shown in fig. 7, it is a flowchart of a method for backup of the data in the database according to an embodiment of the present invention, and the execution subject of the method may be the backup device 620 of the data in the database shown in fig. 6. As shown in fig. 7, the backup method of the data in the database includes the following steps:
s710, creating backup checkpoints in the database, wherein all old checkpoints are automatically deleted after the new checkpoints are created except the backup checkpoints.
First, the database is caused to create a special backup checkpoint that needs to be explicitly created and deleted. I.e. it needs to be created and deleted by the outside world through an interface. This backup checkpoint is created every time a backup is made and only one is created. The database may be a database that is updated ex-situ.
At this point, the database will delete old checkpoints other than the backup checkpoints as it continues to create new checkpoints. This arrangement ensures that the automatic deletion function of ordinary checkpoints other than the backup checkpoints is not turned off during backup, and the automatic deletion function is not turned off for Journal log files.
S720, generating a backup metadata file and a table data file of the data table based on metadata of the data table generated after the backup check point operation.
The creation and operation processes of the backup and common checkpoints are the same, and the backup and common checkpoints are to generate and persist corresponding metadata for each data table in the current database, and at the same time persist the table data file of the data table. Thus, based on the backup checkpoint operation, metadata generated by the backup checkpoint operation can be summarized to generate a backup metadata file. According to the data table pointed in the backup metadata file, the table data file of the corresponding content can be extracted. The table data file is a file (not limited to a table format) in which table data included in a database is recorded.
S730, copying the backup metadata file and the table data file to the backup storage path.
The backup storage path is independent of a storage position outside a storage path occupied by the database system, and the purpose of the backup storage path is that data under the storage path cannot be lost or damaged after the database is in a downtime state.
In addition, the difference between the step and the backup stage in the prior art is that the copied file does not contain a journ log file, so that the complexity of backup operation can be reduced, and quick backup is realized.
S740, in the process of generating and copying the backup metadata file and the table data file to the backup storage path, the database is marked in the backup stage so that other components of the database enter a preset backup working state.
When the backup process starts, the current database can be marked to be in a backup state, so that other components of the database assist in smoothly completing the backup process. The auxiliary content mainly includes, for example, ensuring that only one backup can be performed at the same point in time, preventing the table data file to be backed up from being deleted, preventing the table data file from being truncated, and the like. After the backup process is finished, the backup state of the database can be released again, so that each component can restore to the normal working state of each component.
It should be noted that, the preset backup working states corresponding to other components may be customized, so long as the backup process can be guaranteed to be performed normally, and the definition of the content of the preset backup working states is not limited to the above examples. Of course, the implementation and effect of this step may also be achieved by adopting or combining the mode of setting the backup mark in the prior art.
According to the backup method for the data in the database, when the database is backed up, a backup check point is established, all old check points except the backup check point are set to be automatically deleted after the new check point is established; then generating and copying a backup metadata file and a table data file of the data table based on metadata of the data table generated after the backup check point operation; meanwhile, in the process of generating and copying the backup metadata file and the table data file, the database is marked in the backup stage, so that other components of the database enter a preset backup working state, and the sequential progress of the backup process is ensured. According to the scheme, only one old check point, namely the backup check point, is reserved during the backup of the database, and the problem of rapid increase of disk space during the backup is effectively solved.
Example two
The present embodiment adds the following expansion content on the basis of the above embodiment.
First, as shown in fig. 8, a flowchart of a method for backing up data in a database according to an embodiment of the present invention is shown. On the basis of the method shown in the previous embodiment, a step of setting a backup mark is added to ensure that the backup process is performed normally. As shown in fig. 8, after step S710, the following steps are performed:
S810, creating a backup mark in the database, wherein the backup mark is used for identifying that the database is in a backup stage so as to enable other components to enter a preset backup working state.
This step may be used as a refinement of step S740 described above, where the specific backup mark functions as in the prior art. The benefit of this treatment is that the cost of modification to existing methods is reduced.
However, in the prior art, after the backup mark is set, the auto-delete function of the checkpoint is automatically turned off, and the auto-delete function of the journ log is automatically turned off, so that other old checkpoints except the backup checkpoint cannot be deleted, thereby occupying disk storage space. As such, it can be understood that the preset backup operation states of the other components include: automatically shutting down the function that all old checkpoints in normal operating state will be automatically deleted after the new checkpoints are created.
The method is to decouple the steps of the two links, and separate the process of setting the backup mark from the automatic deleting function of automatically closing the checkpoint and the automatic deleting function of automatically closing the journ log. Then, only the step of setting the backup mark is executed, and the step of automatically closing the automatic deletion function of the checkpoint and the step of automatically closing the automatic deletion function of the journ log are not executed, thereby achieving the effect that all old checkpoints are automatically deleted after the new checkpoints are created except the backup checkpoints.
However, the transformation cost of the prior art is relatively high, and the original backup flow is destroyed. The scheme provides a scheme with lower reconstruction cost for the situation, namely, if the process of setting the backup mark and the process of automatically closing the automatic deletion function of the checkpoint are not decoupled, the preset backup working state comprises the following steps: automatically closing the function that all old checkpoints in the normal working state are automatically deleted after the new checkpoints are created; then an additional flag may be created after step 710, for causing other components to automatically shut down, upon entering the preset backup operational state, only the function that the old checkpoint in the normal operational state will be automatically deleted after the new checkpoint is created for the backup checkpoint, such that all old checkpoints will be automatically deleted after the new checkpoint is created, except for the backup checkpoint.
Thus, after step S810 is performed again, when the other components are to perform the deletion of the backup checkpoint according to the backup mark, only the backup checkpoint is maintained since the additional mark is seen (the execution priority of the additional mark is set to be higher than that of the backup mark), and the other old checkpoints are still automatically deleted after the new checkpoint is created. When the backup mark is canceled to fail, the additional mark is automatically canceled to fail.
After step S730, the following steps may be performed:
s820, cancel the backup mark.
S830, other components are restored to enter a normal working state.
After the backup stage is finished, the backup mark can be canceled to be invalid, so that other components can be restored to the normal working state.
At this time, the database also stores backup checkpoints, and in order to reduce the storage pressure of the disk, the following steps may be selectively executed:
and S840, deleting metadata of the data table generated by the backup check point operation in response to the operation of deleting the backup check point triggered by the external port.
It should be emphasized here that the manner in which the backup checkpoint is deleted is explicit deletion, i.e. deletion of the backup checkpoint is performed by means of a deletion operation triggered from outside the database system (e.g. manual deletion).
The backup method of the data in the database provided by the invention expands the method on the basis of the first embodiment:
firstly, referring to the backup mark in the prior art, the mark database is in a backup stage, so that other components enter a preset backup working state. By multiplexing the prior art, the complexity of the improvement is reduced.
And secondly, after the backup stage is finished, the normal functional states of other components are restored, and the sequence of the database is ensured to provide services to the outside.
And finally, deleting the backup checkpoint through external triggering of the database after the backup stage is finished, so that the backup checkpoint is not deleted randomly in the backup stage, and the corresponding disk storage space can be released after the backup stage is finished, and the disk storage pressure is reduced.
Example III
Based on the above-mentioned idea of the recovery scheme of the data in the database, as shown in fig. 9, which is a flowchart of a method for recovering the data in the database according to an embodiment of the present invention, an execution subject of the method may be the recovery device 630 of the data in the database shown in fig. 6. As shown in fig. 9, the method for recovering data in the database includes the following steps:
s910, copying the backup metadata file and the table data file obtained by backup into a designated directory of the database.
For example, the data file may be copied to an empty data directory under the database system. The specified directory is dedicated to storing the loading data required at database start-up.
S920, the database is started and controlled to load the backup metadata file in the appointed directory and the data in the table data file so as to restore the data in the database.
The backup metadata file and the table data file are obtained by backup of the data in the database according to any one of the first embodiment and the second embodiment.
According to the database recovery method provided by the embodiment of the invention, based on the metadata file and the table data file which are backed up in advance, the data of the database can be quickly recovered to the data at the moment of backing up the checkpoint.
Example IV
As shown in fig. 10, a first structure diagram of a backup device of data in a database according to an embodiment of the present invention is shown, where the backup device of data in the database may be disposed in the backup and restore system of data in the database shown in fig. 6, and is configured to perform the method steps shown in fig. 7, and includes:
a checkpoint creation module 101, configured to create backup checkpoints in a database, where all old checkpoints are automatically deleted after a new checkpoint is created, except for the backup checkpoint;
the backup data generating module 102 is configured to generate a backup metadata file and a table data file of the data table based on metadata of the data table generated after the backup checkpoint operation;
a backup data storage module 103, configured to copy the backup metadata file and the table data file to a backup storage path;
the backup state control module 104 is configured to mark that the database is in a backup stage during generating and copying the backup metadata file and the table data file to the backup storage path, so that other components of the database enter a preset backup working state.
Further, the backup status control module 104 is specifically configured to create a backup mark in the database, where the backup mark is used to identify that the database is in a backup stage, so that other components enter a preset backup working state;
correspondingly, the backup status control module 104 may be further configured to restore the other components to enter the normal working status after the backup mark is cancelled.
Further, the preset backup working state may include: closing and deleting functions for automatically closing all old checkpoints in a normal working state and automatically deleting the old checkpoints after new checkpoints are created;
accordingly, as shown in fig. 11, the backup device for data in the database may further include:
an additional state control module 111 for creating an additional mark after the backup checkpoint is created in the database by the checkpoint creation module, the additional mark being used to enable other components to automatically close, after entering the preset backup working state, only the function that an old checkpoint in the normal working state will be automatically deleted after a new checkpoint is created for the backup checkpoint, so that all old checkpoints will be automatically deleted after the new checkpoint is created except for the backup checkpoint.
Further, the backup device of the data in the database shown in fig. 11 may further include:
the backup mark cancellation module 112 is configured to cancel the backup mark after the backup metadata file and the table data file are copied to the backup storage path by the backup data generation module.
Further, the backup device of the data in the database shown in fig. 11 may further include:
the backup checkpoint deleting module 113 is configured to delete metadata of a data table generated by the backup checkpoint operation in response to an external port triggered operation of deleting the backup checkpoint.
The apparatus structure shown in fig. 11 may be used to perform the method steps shown in fig. 8.
When the backup device for the data in the database is used for backing up the database, a backup check point is established, all old check points except the backup check point are set to be automatically deleted after a new check point is established; then generating and copying a backup metadata file and a table data file of the data table based on metadata of the data table generated after the backup check point operation; meanwhile, in the process of generating and copying the backup metadata file and the table data file, the database is marked in the backup stage, so that other components of the database enter a preset backup working state, and the sequential progress of the backup process is ensured. According to the scheme, only one old check point, namely the backup check point, is reserved during the backup of the database, and the problem of rapid increase of disk space during the backup is effectively solved.
Further, the scheme refers to the backup mark in the prior art, and the mark database is in a backup stage, so that other components enter a preset backup working state. By multiplexing the prior art, the complexity of the improvement is reduced.
Further, after the backup stage is finished, the normal functional state of other components is restored, and the database is ensured to provide services to the outside sequentially.
Further, after the backup stage is finished, the backup checkpoint is deleted through external triggering of the database, so that on one hand, the backup checkpoint is ensured not to be deleted randomly in the backup stage, and on the other hand, the corresponding disk storage space can be released after the backup stage is finished, and the disk storage pressure is reduced.
Example five
As shown in fig. 12, a block diagram of a device for recovering data in a database according to an embodiment of the present invention, where the device for recovering data in a database may be disposed in the system for backup and recovery of data in a database shown in fig. 6, and is configured to perform the steps of the method shown in fig. 9, and includes:
a backup data copying module 121, configured to copy the backup metadata file and the table data file obtained by backup to a designated directory of the database;
a database recovery module 122, configured to initiate and control the database to load the backup metadata file in the specified directory and the data in the table data file, so as to recover the data in the database;
The backup metadata file and the table data file are obtained by adopting the backup method of the data in the database according to any one of the first embodiment and the second embodiment.
The database recovery device provided by the embodiment of the invention can quickly recover the data of the database to the data at the moment of backing up the checkpoint based on the metadata file and the table data file backed up in advance.
Example six
The foregoing embodiment describes the overall architecture of a device for backing up data in a database, and the functions of the device may be implemented by an electronic device, as shown in fig. 13, which is a schematic structural diagram of the electronic device according to an embodiment of the present invention, and specifically includes: a memory 131 and a processor 132.
A memory 131 for storing a program.
In addition to the programs described above, the memory 131 may also be configured to store other various data to support operations on the electronic device. Examples of such data include instructions for any application or method operating on the electronic device, contact data, phonebook data, messages, pictures, videos, and the like.
The memory 131 may be implemented by any type of volatile or non-volatile memory device or combination thereof, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
A processor 132, coupled to the memory 131, for executing the programs in the memory 131 for:
creating backup checkpoints in the database, wherein all old checkpoints are automatically deleted after the new checkpoints are created except the backup checkpoints;
generating a backup metadata file and a table data file of the data table based on metadata of the data table generated after the backup check point operation;
copying the backup metadata file and the table data file to a backup storage path;
in the process of generating and copying the backup metadata file and the table data file to the backup storage path, the mark database is in a backup stage so that other components of the database enter a preset backup working state.
The specific processing operations described above have been described in detail in the previous embodiments, and are not repeated here.
Further, as shown in fig. 13, the electronic device may further include: communication component 133, power component 134, audio component 135, display 136, and other components. Only some of the components are schematically shown in fig. 13, which does not mean that the electronic device only comprises the components shown in fig. 13.
The communication component 133 is configured to facilitate communication between the electronic device and other devices, either wired or wireless. The electronic device may access a wireless network based on a communication standard, such as WiFi,2G, or 3G, or a combination thereof. In one exemplary embodiment, the communication component 133 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication component 133 further includes a Near Field Communication (NFC) module to facilitate short range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
A power supply assembly 134 provides power to the various components of the electronic device. The power components 134 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for electronic devices.
The audio component 135 is configured to output and/or input audio signals. For example, the audio component 135 includes a Microphone (MIC) configured to receive external audio signals when the electronic device is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal may be further stored in the memory 131 or transmitted via the communication component 133. In some embodiments, audio component 135 further comprises a speaker for outputting audio signals.
The display 136 includes a screen, which may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may sense not only the boundary of a touch or sliding action, but also the duration and pressure associated with the touch or sliding operation.
Example seven
The foregoing embodiment describes the overall architecture of a device for recovering data in a database, where the function of the device may be implemented by an electronic device, as shown in fig. 14, which is a schematic structural diagram of the electronic device according to an embodiment of the present invention, and specifically includes: a memory 141 and a processor 142.
A memory 141 for storing a program.
In addition to the programs described above, the memory 141 may also be configured to store other various data to support operations on the electronic device. Examples of such data include instructions for any application or method operating on the electronic device, contact data, phonebook data, messages, pictures, videos, and the like.
The memory 141 may be implemented by any type or combination of volatile or nonvolatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
A processor 142 coupled to the memory 141 for executing programs in the memory 141 for:
copying the backup metadata file and the table data file obtained by backup into a designated directory of a database;
Starting and controlling the database to load the backup metadata files in the appointed catalogue and the data in the table data files so as to restore the data in the database;
the backup metadata file and the table data file are obtained by adopting a backup method of data in a database.
The specific processing operations described above have been described in detail in the previous embodiments, and are not repeated here.
Further, as shown in fig. 14, the electronic device may further include: communication component 143, power supply component 144, audio component 145, display 146, and other components. Only some of the components are schematically shown in fig. 14, which does not mean that the electronic device only comprises the components shown in fig. 14.
The communication component 143 is configured to facilitate communication between the electronic device and other devices, either wired or wireless. The electronic device may access a wireless network based on a communication standard, such as WiFi,2G, or 3G, or a combination thereof. In one exemplary embodiment, the communication component 143 receives broadcast signals or broadcast related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication component 143 further includes a Near Field Communication (NFC) module to facilitate short range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
A power supply assembly 144 provides power to the various components of the electronic device. The power components 144 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for electronic devices.
The audio component 145 is configured to output and/or input audio signals. For example, the audio component 145 includes a Microphone (MIC) configured to receive external audio signals when the electronic device is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may be further stored in the memory 141 or transmitted via the communication component 143. In some embodiments, audio component 145 further comprises a speaker for outputting audio signals.
The display 146 includes a screen, which may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may sense not only the boundary of a touch or sliding action, but also the duration and pressure associated with the touch or sliding operation.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the method embodiments described above may be performed by hardware associated with program instructions. The foregoing program may be stored in a computer readable storage medium. The program, when executed, performs steps including the method embodiments described above; and the aforementioned storage medium includes: various media that can store program code, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.

Claims (14)

1. A method of backing up data in a database, comprising:
creating backup checkpoints in a database, wherein all old checkpoints are automatically deleted after new checkpoints are created except the backup checkpoints;
Generating a backup metadata file and a table data file of the data table based on metadata of the data table generated after the backup check point operation;
copying the backup metadata file and the table data file to a backup storage path;
in the process of generating and copying the backup metadata file and the table data file to a backup storage path, marking that the database is in a backup stage so as to enable other components of the database to enter a preset backup working state;
wherein, the preset backup working state comprises: automatically closing the function that all old checkpoints in the normal working state are automatically deleted after a new checkpoint is created.
2. The method of claim 1, wherein marking the database as in a backup phase to bring other components of the database into a pre-set backup operational state comprises:
creating a backup mark in a database, wherein the backup mark is used for identifying that the database is in a backup stage so as to enable the other components to enter the preset backup working state;
the method further comprises the steps of:
and after the backup mark is canceled, restoring the other components to enter a normal working state.
3. The method of claim 2, wherein,
after the backup checkpoint is created in the database, the method further comprises:
creating an additional mark for enabling the other components to automatically close the function of automatically deleting the old check points in the normal working state after the new check points are created only for the backup check points after entering the preset backup working state, so that all the old check points except the backup check points are automatically deleted after the new check points are created.
4. The method of claim 2, wherein the copying the backup metadata file and the table data file to a backup storage path further comprises:
and canceling the backup mark.
5. The method of claim 4, wherein the cancelling the backup mark further comprises, thereafter;
and deleting metadata of the data table generated by the backup check point operation in response to an external port triggered operation of deleting the backup check point.
6. A method of recovering data in a database, comprising:
copying the backup metadata file and the table data file obtained by backup into a designated directory of a database;
Starting and controlling a database to load the backup metadata files in the appointed catalogue and the data in the table data files so as to restore the data in the database;
the backup metadata file and the table data file are obtained by backup by adopting the backup method of the data in the database according to any one of claims 1-5.
7. A backup apparatus for data in a database, comprising:
the system comprises a checkpoint creation module, a backup checkpoint and a backup checkpoint generation module, wherein the checkpoint creation module is used for creating backup checkpoints in a database, and all old checkpoints are automatically deleted after new checkpoints are created except the backup checkpoints;
the backup data generation module is used for generating a backup metadata file and a table data file of the data table based on metadata of the data table generated after the backup check point operation;
the backup data storage module is used for copying the backup metadata file and the table data file to a backup storage path;
the backup state control module is used for marking the database to be in a backup stage in the process of generating and copying the backup metadata file and the table data file to a backup storage path so as to enable other components of the database to enter a preset backup working state;
Wherein, the preset backup working state comprises: automatically closing the function that all old checkpoints in the normal working state are automatically deleted after a new checkpoint is created.
8. The apparatus of claim 7, wherein the backup status control module is specifically configured to create a backup mark in a database, the backup mark being configured to identify that the database is in a backup phase to cause the other component to enter the preset backup operational state;
and the backup state control module is also used for restoring the other components to enter a normal working state after the backup mark is canceled.
9. The apparatus of claim 8, wherein,
the apparatus further comprises:
and the additional state control module is used for creating an additional mark after the backup check point is created in the database by the check point creation module, wherein the additional mark is used for enabling the other components to automatically close the function of automatically deleting the old check point in the normal working state after the new check point is created only for the backup check point after entering the preset backup working state, so that all the old check points except the backup check point are automatically deleted after the new check point is created.
10. The apparatus of claim 8, wherein the apparatus further comprises:
and the backup mark canceling module is used for canceling the backup mark after the backup metadata file and the table data file are copied to a backup storage path by the backup data generating module.
11. The apparatus of claim 10, wherein the apparatus further comprises:
and the backup check point deleting module is used for responding to the operation of deleting the backup check point triggered by an external port and deleting the metadata of the data table generated by the backup check point operation.
12. A device for recovering data in a database, comprising:
the backup data copying module is used for copying the backup metadata files and the table data files obtained by backup into the appointed catalogue of the database;
the database recovery module is used for starting and controlling the database to load the backup metadata files in the appointed catalogue and the data in the table data files so as to recover the data in the database;
the backup metadata file and the table data file are obtained by backup by adopting the backup method of the data in the database according to any one of claims 1-5.
13. An electronic device, comprising:
a memory for storing a program;
a processor coupled to the memory for executing the program for:
creating backup checkpoints in a database, wherein all old checkpoints are automatically deleted after new checkpoints are created except the backup checkpoints;
generating a backup metadata file and a table data file of the data table based on metadata of the data table generated after the backup check point operation;
copying the backup metadata file and the table data file to a backup storage path;
in the process of generating and copying the backup metadata file and the table data file to a backup storage path, marking that the database is in a backup stage so as to enable other components of the database to enter a preset backup working state;
wherein, the preset backup working state comprises: automatically closing the function that all old checkpoints in the normal working state are automatically deleted after a new checkpoint is created.
14. An electronic device, comprising:
a memory for storing a program;
a processor coupled to the memory for executing the program for:
Copying the backup metadata file and the table data file obtained by backup into a designated directory of a database;
starting and controlling a database to load the backup metadata files in the appointed catalogue and the data in the table data files so as to restore the data in the database;
the backup metadata file and the table data file are obtained by backup by adopting the backup method of the data in the database according to any one of claims 1-5.
CN201811014535.9A 2018-08-31 2018-08-31 Backup and recovery method and device for data in database and electronic equipment Active CN110874287B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811014535.9A CN110874287B (en) 2018-08-31 2018-08-31 Backup and recovery method and device for data in database and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811014535.9A CN110874287B (en) 2018-08-31 2018-08-31 Backup and recovery method and device for data in database and electronic equipment

Publications (2)

Publication Number Publication Date
CN110874287A CN110874287A (en) 2020-03-10
CN110874287B true CN110874287B (en) 2023-05-02

Family

ID=69715852

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811014535.9A Active CN110874287B (en) 2018-08-31 2018-08-31 Backup and recovery method and device for data in database and electronic equipment

Country Status (1)

Country Link
CN (1) CN110874287B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6345282B1 (en) * 1999-09-30 2002-02-05 Nortel Networks Limited Multi-processor data synchronization method and apparatus
CN102541691A (en) * 2011-12-27 2012-07-04 北京人大金仓信息技术股份有限公司 Log check point recovery method applied to memory data base OLTP (online transaction processing)
CN102750317A (en) * 2012-05-02 2012-10-24 华为技术有限公司 Method and device for data persistence processing and data base system
US8364648B1 (en) * 2007-04-09 2013-01-29 Quest Software, Inc. Recovering a database to any point-in-time in the past with guaranteed data consistency
CN105339939A (en) * 2013-06-25 2016-02-17 国际商业机器公司 Replication for on-line hot-standby database
CN105677509A (en) * 2015-12-25 2016-06-15 北京奇虎科技有限公司 Method and apparatus for recovering data in database
CN106155838A (en) * 2015-04-24 2016-11-23 中国移动通信集团河南有限公司 A kind of database back-up data restoration methods and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020103814A1 (en) * 2000-12-12 2002-08-01 Edouard Duvillier High speed, non-log based database recovery technique
US20160140132A1 (en) * 2014-11-19 2016-05-19 Unisys Corporation Online redistribution

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6345282B1 (en) * 1999-09-30 2002-02-05 Nortel Networks Limited Multi-processor data synchronization method and apparatus
US8364648B1 (en) * 2007-04-09 2013-01-29 Quest Software, Inc. Recovering a database to any point-in-time in the past with guaranteed data consistency
CN102541691A (en) * 2011-12-27 2012-07-04 北京人大金仓信息技术股份有限公司 Log check point recovery method applied to memory data base OLTP (online transaction processing)
CN102750317A (en) * 2012-05-02 2012-10-24 华为技术有限公司 Method and device for data persistence processing and data base system
CN105339939A (en) * 2013-06-25 2016-02-17 国际商业机器公司 Replication for on-line hot-standby database
CN106155838A (en) * 2015-04-24 2016-11-23 中国移动通信集团河南有限公司 A kind of database back-up data restoration methods and device
CN105677509A (en) * 2015-12-25 2016-06-15 北京奇虎科技有限公司 Method and apparatus for recovering data in database

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
覃雄派 ; 肖艳芹 ; 曹巍 ; 王珊 ; .面向更新密集型应用的内存数据库高效检查点技术.计算机学报.2009,(第11期),全文. *

Also Published As

Publication number Publication date
CN110874287A (en) 2020-03-10

Similar Documents

Publication Publication Date Title
US8538930B2 (en) Method and system for database recovery
CN108416040B (en) Database repair method and device, terminal equipment and storage medium
CN105204959A (en) Method and device for restoring deleted files in ext file system
US20130132340A1 (en) File synchronization method, electronic device and synchronization system
JP2007219883A (en) Mobile terminal device and software update method
CN105955843B (en) A kind of method and apparatus for database recovery
CN106716379B (en) Data processing method and device and terminal equipment
US20110022986A1 (en) Method and device for application archiving
JP4859465B2 (en) Software updating method and mobile terminal device
CN110874287B (en) Backup and recovery method and device for data in database and electronic equipment
US20120185440A1 (en) Method and apparatus for providing address book restoration
WO2018177193A1 (en) Software upgrade method and device
JP2012526322A (en) Capture and load operating system state
KR101085681B1 (en) System and method for recovering data in mobile terminal
CN109271442A (en) Database synchronization restoration methods, device, computer readable storage medium and electronic equipment
CN116048644B (en) System migration method, device and readable storage medium
US11449389B2 (en) Techniques for performing incremental data backups
CN110704243A (en) Data recovery method and device, terminal equipment and storage medium
WO2016110065A1 (en) Method and device for safely deleting data in mobile terminal
US11550665B2 (en) Techniques for preserving clone relationships between files
CN105446835A (en) Method and device for repairing system file
US20210303417A1 (en) Method and system for managing backup data
CN110602416A (en) Video processing method, terminal and computer readable storage medium
KR20080057441A (en) A digital camera having automatic image backup function and the method thereof
CN111274210B (en) Metadata processing method and device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant