CN107179965B - Database recovery method and device - Google Patents

Database recovery method and device Download PDF

Info

Publication number
CN107179965B
CN107179965B CN201710278027.0A CN201710278027A CN107179965B CN 107179965 B CN107179965 B CN 107179965B CN 201710278027 A CN201710278027 A CN 201710278027A CN 107179965 B CN107179965 B CN 107179965B
Authority
CN
China
Prior art keywords
data
backup file
restored
recovered
database
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
CN201710278027.0A
Other languages
Chinese (zh)
Other versions
CN107179965A (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.)
Beijing longzhixin Technology Co.,Ltd.
Original Assignee
Beijing Panda Mutual Entertainment Technology Co 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 Beijing Panda Mutual Entertainment Technology Co Ltd filed Critical Beijing Panda Mutual Entertainment Technology Co Ltd
Priority to CN201710278027.0A priority Critical patent/CN107179965B/en
Publication of CN107179965A publication Critical patent/CN107179965A/en
Application granted granted Critical
Publication of CN107179965B publication Critical patent/CN107179965B/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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases

Abstract

The embodiment of the application provides a database recovery method and device. The method comprises the following steps: responding to a database recovery instruction, and determining data to be recovered; identifying a physical backup file associated with data to be restored; if the data volume of the physical backup file is larger than a preset threshold value, acquiring first data required for restoring the data to be restored from a logical backup file associated with the data to be restored; and according to the first data and the backup log corresponding to the first data, performing recovery processing on the data to be recovered. The method and the device provided by the embodiment of the application can be used for rapidly recovering the data in the database.

Description

Database recovery method and device
Technical Field
The present application relates to the field of data storage technologies, and in particular, to a database recovery method and apparatus.
Background
A database is a repository that organizes, stores, and manages data according to a data structure. When a database fails in hardware or software, data may be lost, and it is necessary to perform a recovery operation on the database.
In the prior art, a database is generally subjected to physical backup periodically, and when the database needs to be restored, the database can be restored to a specified time point according to data subjected to physical backup. The speed of such database recovery is relatively slow.
Disclosure of Invention
Aspects of the present disclosure provide a database recovery method and apparatus, so as to improve a data recovery speed in a database.
The embodiment of the application provides a database recovery method, which comprises the following steps:
responding to a database recovery instruction, and determining data to be recovered;
identifying a physical backup file associated with the data to be restored;
if the data volume of the physical backup file is larger than a preset threshold value, acquiring first data required for recovering the data to be recovered from a logical backup file associated with the data to be recovered;
and according to the first data and the backup log corresponding to the first data, recovering the data to be recovered.
Optionally, the method further comprises:
if the data volume of the physical backup file is smaller than or equal to the preset threshold, acquiring second data required for restoring the data to be restored from the physical backup file;
and according to the second data and the backup log corresponding to the second data, recovering the data to be recovered.
Optionally, the obtaining, from the physical backup file, second data required for restoring the data to be restored includes:
downloading the physical backup file to the local;
starting at least one database instance corresponding to the physical backup file;
and acquiring second data required for recovering the data to be recovered from the at least one database instance.
Optionally, the obtaining, from the logical backup file associated with the data to be restored, first data required for restoring the data to be restored includes:
determining service information to be recovered according to the database recovery instruction;
and acquiring data which accords with the service information to be recovered from the logic backup file associated with the data to be recovered as the first data.
Optionally, the obtaining, as the first data, data that conforms to the service information to be restored from the logical backup file associated with the data to be restored includes:
acquiring data in accordance with the table level of the service information to be restored from the logic backup file associated with the data to be restored, wherein the data is used as the first data; or
And acquiring database-level data which accords with the service information to be restored from the logic backup file associated with the data to be restored, wherein the database-level data is used as the first data.
Optionally, determining data to be recovered includes:
acquiring a recovery time point from the database recovery instruction;
and determining the data to be recovered according to the recovery time point.
Optionally, before obtaining the recovery time point from the database recovery instruction, the method further includes:
carrying out physical backup and logical backup on the data in the database to obtain a physical backup file and a logical backup file associated with the data to be restored; and
and backing up the logs of the database between the adjacent backup time points to obtain backup logs.
An embodiment of the present application further provides a database recovery apparatus, including:
the determining module is used for responding to the database recovery instruction and determining the data to be recovered;
the identification module is used for identifying the physical backup file associated with the data to be restored;
a first obtaining module, configured to obtain, from a logical backup file associated with the data to be restored, first data required to restore the data to be restored if the data amount of the physical backup file is greater than a preset threshold;
and the first recovery module is used for performing recovery processing on the data to be recovered according to the first data and the backup log corresponding to the first data.
Optionally, the apparatus further comprises:
a second obtaining module, configured to obtain, from the physical backup file, second data required to restore the data to be restored if the data amount of the physical backup file is less than or equal to the preset threshold;
and the second recovery module is used for recovering the data to be recovered according to the second data and the backup log corresponding to the second data.
Optionally, the second obtaining module is specifically configured to:
if the data volume of the physical backup file is smaller than or equal to the preset threshold value, downloading the physical backup file to the local;
starting at least one database instance corresponding to the physical backup file;
and acquiring second data required for recovering the data to be recovered from the at least one database instance.
In the embodiment of the application, if the data volume of the physical backup file associated with the data to be restored is greater than the preset threshold, the data in the database is restored directly through the logical backup file without downloading the physical backup file with a large data volume for restoration, so that the data volume transmitted in the data restoration process is small, the consumed time is short, and the data restoration is fast.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
fig. 1 is a schematic flowchart of a database recovery method according to an embodiment of the present application;
fig. 2 is a schematic flowchart illustrating a process of acquiring second data required for recovering data to be recovered in a database recovery method according to another embodiment of the present application;
fig. 3 is a block diagram of a database recovery apparatus according to another embodiment of the present application;
fig. 4 is a block diagram of a database recovery apparatus according to another embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be described in detail and completely with reference to the following specific embodiments of the present application and the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The technical solutions provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.
Fig. 1 is a schematic flowchart of a database recovery method according to an embodiment of the present application. As shown in fig. 1, the method comprises the steps of:
s101: and responding to the database recovery instruction, and determining data to be recovered.
S102: a physical backup file associated with the data to be restored is identified.
S103: if the data volume of the physical backup file is larger than a preset threshold value, first data required for restoring the data to be restored are obtained from the logic backup file associated with the data to be restored.
S104: and according to the first data and the backup log corresponding to the first data, performing recovery processing on the data to be recovered.
When the data in the database needs to be restored, a database restoring instruction can be generated and sent to the database restoring device to perform data restoring operation.
Alternatively, the database recovery instruction may be generated and sent periodically, or may be generated and sent under the trigger of the user. For example, the code for generating the database recovery instruction may be written into a script in advance, and when the user needs to recover the data in the database, the script may be executed to generate the database recovery instruction and send the database recovery instruction to the database recovery device.
The database recovery apparatus may be responsive to the database recovery instruction, determine data to be recovered from the database recovery instruction,
the data to be restored needs to be restored depending on the backup data, and the backup data needed for restoring the data to be restored may be historical data corresponding to the data to be restored in the logical backup file or historical data corresponding to the data to be restored in the physical backup file. The recovery processing process includes a process of acquiring backup data required for recovering the data to be recovered and a process of recovering the data to be recovered.
For the process of obtaining backup data required for restoring the data to be restored, optionally, the backup data may be obtained from a backup file associated with the data to be restored. The backup files include physical backup files and logical backup files. The physical backup file stores the operating system files actually forming the database, and the logical backup file stores the data extracted from the database by using SQL language.
In the prior art, the physical backup file is unreadable. When the backup data required for restoring the data to be restored is acquired through the physical backup file, the whole physical backup file needs to be downloaded to the local, and then the backup data required for restoring the data to be restored is acquired from the physical backup file downloaded to the local. When the data volume of the physical backup file is large, downloading the physical backup file causes the transmitted data volume to be large, thereby causing a slow speed of acquiring backup data required for restoring data to be restored, and affecting data restoration efficiency. On the contrary, the logic backup file is readable, and the backup data required for recovering the data to be recovered can be directly obtained from the logic backup file without downloading the whole logic backup file, so that the speed of obtaining the backup data required for recovering the data to be recovered is higher.
For the process of recovering the data to be recovered, the process of recovering the data through the physical file is equivalent to directly copying the file, and the speed is high. The logical backup file stores SQL statement files, and one SQL statement needs to be executed in the process of restoring the data to be restored, so that the restoring process is slow.
Generally, when the amount of data of the physical backup file is large, the time consumed for downloading the physical backup file is relatively long compared with the time consumed for restoring the data through the logical backup file, and the time consumed for other operations can be relatively negligible.
Based on the analysis, the physical backup file associated with the data to be restored can be identified; judging whether a physical backup file associated with the data to be restored is larger than a preset threshold value or not; if the data volume of the physical backup file is larger than the preset threshold value, which indicates that the physical backup file is larger, the backup data required for restoring the data to be restored can be acquired from the logical backup file associated with the data to be restored. For the sake of distinction, backup data acquired from the logical backup file, which is required to restore data to be restored, is referred to as first data.
Optionally, the physical backup file associated with the data to be restored may be identified according to the information of the data to be restored. In an example, the information of the data to be restored includes the time point 11:00 of the data to be restored, and the physical backup files include a physical backup file backed up at 10:00 and a physical backup file backed up at 7:00, it may be determined that the physical backup file associated with the data to be restored is the physical backup file backed up most recently before 11:00, that is, the physical backup file backed up at 10: 00.
And then, judging whether the data volume of the physical backup file is larger than a preset threshold value. Alternatively, the preset threshold may be determined in such a manner that, when the time taken for performing the recovery processing on the data according to the physical backup file is longer than the time taken for performing the recovery processing on the data according to the logical backup file, the data amount of the physical backup file at this time is used as the preset threshold. For example, the preset threshold may be 10GB, 20GB, etc.
If the data volume of the physical backup file associated with the data to be restored is larger than the preset threshold, which means that the time consumed for restoring the data to be restored through the physical backup file is longer than that consumed for restoring the data through the logical backup file, the first data can be acquired from the logical backup file associated with the data to be restored, and then the data to be restored is restored according to the logical backup file.
Similarly, the logical backup file associated with the data to be restored can be identified according to the data to be restored information. For example, the logical backup file associated with the data to be restored may be determined to be the physical backup file that was backed up most recently before the restoration time point.
Since the logical backup file is readable, the first data can be directly acquired from the logical backup file.
And then, according to the acquired first data and the backup log corresponding to the first data, recovering the data to be recovered.
The backup log is a backup file of a database log file, and the database log file records various operations in the database. Alternatively, the backup log may be a backup file of the logical log. Based on this, the backup log corresponding to the first data is a backup file recorded with a logical log of database operations related to the first data.
In the embodiment of the application, if the data volume of the physical backup file associated with the data to be restored is greater than the preset threshold, the data in the database is restored directly through the logical backup file without downloading the physical backup file with a large data volume for restoration, so that the data volume transmitted in the data restoration process is small, the consumed time is short, and the data restoration is fast.
In the foregoing embodiment or the following embodiments, if the data amount of the physical backup file is less than or equal to the preset threshold, which means that the time consumed for performing the recovery processing on the data to be recovered through the physical backup file is shorter or the same as that consumed for performing the recovery processing on the data to be recovered through the logical backup file, the backup data required for recovering the data to be recovered is acquired from the physical backup file. For the sake of distinction, backup data acquired from the physical backup file, which is required to restore data to be restored, is referred to as second data. It is noted that the first data and the second data may or may not be the same.
And the second data is historical data corresponding to the data to be restored in the physical backup file. Similarly, a physical backup file associated with the second data may be identified according to the information of the data to be restored, and the second data may be obtained from the physical backup file.
Alternatively, the process of acquiring the second data from the physical backup file, as shown in fig. 2, includes steps S201 to S203.
S201: and downloading the physical backup file to a local place.
S202: at least one database instance corresponding to the physical backup file is started.
S203: and acquiring second data required for recovering the data to be recovered from at least one database instance.
Alternatively, the physical backup file may be downloaded to any local database server. Then, at least one database instance corresponding to the physical backup file is started through the database server, and further, second data can be obtained from the at least one database instance. Optionally, data required to restore the data to be restored may be acquired from each database instance as the second data, or data required to restore the data to be restored may be acquired from a part of the database instances as the second data.
And then, according to the second data and the backup log associated with the second data, recovering the data to be recovered. Similarly, the backup log corresponding to the second data is a backup file recorded with a logical log of database operations related to the second data.
In this embodiment, if the data amount of the physical backup file is less than or equal to the preset threshold, the data in the database is restored according to the physical backup file, which takes a short time and further makes the data restoration faster.
In the foregoing embodiment or the following embodiments, the first data may be acquired from the logical backup file associated with the data to be restored according to a service requirement. Optionally, according to the database recovery instruction, besides determining the data to be recovered, the service information to be recovered may also be determined; and acquiring data which accords with the service information to be recovered from the logic backup file associated with the data to be recovered as first data required for recovering the data to be recovered.
The database recovery instruction includes service information to be recovered, and the database recovery device may determine the service information to be recovered, such as live broadcast information, user information, comment information, and the like, according to the database recovery instruction.
Then, data that conforms to the service information to be restored may be acquired from the logical backup file associated with the data to be restored, as the first data, optionally including any one of the following two operation modes:
the first operation mode is as follows: and acquiring data in accordance with the table level of the service information to be restored from the logic backup file associated with the data to be restored as first data.
Optionally, a corresponding relationship between the identification information of the data table in the logical backup file and the service information to be restored is pre-established. The identification information of the data table may include a data table name and a database IP address, which are used to uniquely identify the data table. Optionally, one type of service information to be recovered may correspond to at least one data table.
After the service information to be restored is determined, the data in the data table required for restoring the data to be restored, that is, the data in the table level which conforms to the service information to be restored, may be further determined according to the correspondence between the identification information of the data table and the service information to be restored, as the first data required for restoring the data to be restored.
Of course, the data to be restored may be a table structure in addition to the data itself. Based on the above, the structure of the data table conforming to the service information to be recovered can also be used as the first data required for recovering the data to be recovered, and then the recovery of the table structure of the data to be recovered is carried out; or the structure of the data table conforming to the service information to be recovered and the data in the data table are jointly used as the first data required for recovering the data to be recovered, and then the recovery processing of the table structure and the content is carried out on the data to be recovered.
The second operation mode is as follows: and acquiring database-level data which accords with the service information to be restored from the logic backup file associated with the data to be restored, wherein the database-level data is used as first data required for restoring the data to be restored.
Wherein the library-level data includes all objects and data in the database. Similarly, the corresponding relationship between the identification information of the database in the logical backup file and the service information to be restored may be established in advance. The identification information of the database may be a database IP address for uniquely identifying the database. Optionally, one type of service information to be recovered may correspond to at least one database.
After the service information to be restored is determined, the object and the data in the database which conform to the service information to be restored, that is, the database-level data which conform to the service information to be restored, may be further determined according to the corresponding relationship between the identification information of the database and the service information to be restored, as the first data required for restoring the data to be restored.
In an optional embodiment, according to a service requirement, second data required for recovering the data to be recovered may also be acquired from a physical backup file associated with the data to be recovered. Optionally, a corresponding relation between the database instance and the service information to be recovered is established in advance; and acquiring data corresponding to the service information to be recovered from at least one database instance corresponding to at least the physical backup file according to the corresponding relation, and taking the data as second data.
In the embodiment, the data can be recovered according to the service information by pre-establishing the corresponding relation between the service information to be recovered and the data to be recovered; moreover, by recovering the data at the table level or the database level, the data in the database is recovered from multiple levels, increasing the flexibility of data recovery.
In the foregoing embodiment or the following embodiment, optionally, determining data to be restored includes: acquiring a recovery time point from a database recovery instruction; and determining the data to be recovered according to the recovery time point.
The database recovery instruction includes information of data to be recovered, such as a recovery time point. The database recovery apparatus may acquire a recovery time point from information to be recovered included in the database recovery instruction in response to the database recovery instruction.
After the recovery time point is obtained, the data to be recovered may be determined according to the recovery time point. The data to be restored is data generated at the restoration time point and/or data generated before the restoration time point. In one example, the recovery time point is day 11:00, the data to be recovered is 11:00, and/or data generated before the current 11:00 may also be recovered. Of course, the recovery time point should be before the current time point, or the data to be recovered should be historical data.
In order to facilitate the execution of data recovery, the database recovery instruction preferably includes a recovery time point, and on this basis, the database recovery instruction may further include service information to be recovered, a type of the data to be recovered, a number of rows/columns of the data to be recovered, a number of data to be recovered, and the like. Based on this, the database recovery apparatus may obtain, from the database recovery instruction, data that conforms to the service information to be recovered and is generated at the recovery time point, data that conforms to the type of the data to be recovered and is generated at the recovery time point, and data that conforms to the number of rows/columns of the data to be recovered or the number of data to be recovered and is generated at the recovery time point, as the data to be recovered.
In one example, the database restore instruction includes a restore time point: 10 on the day: 00, and the type of data to be recovered: a character string. The database recovery apparatus may determine that the data to be recovered is 10:00 data of string type in the database.
Data in the database as well as logs may be backed up before data recovery is performed. In an optional embodiment, before obtaining the recovery time point from the database recovery instruction, the method further includes: carrying out physical backup and logical backup on data in a database to obtain a physical backup file and a logical backup file associated with the data to be restored; and backing up the logs of the database between the adjacent backup time points to obtain backup logs.
Different from the prior art that only the data in the database is physically backed up, the embodiment of the present application also performs logical backup on the data in the database. Optionally, the physical backup and the logical backup may be performed simultaneously or may not be performed simultaneously.
Optionally, the data in the database may be backed up both physically and logically periodically. The backup period may include periods of different time granularities, such as weekly, daily, or hourly. Based on this, a variety of time-granular backup operations may be performed on the data in the database.
Alternatively, the more important the database, the shorter the period of backup may be. For example, for more important databases, a backup operation is performed every hour; executing backup operation once a day on an important database; for secondary databases, backup operations are performed weekly.
Each time a physical backup and a logical backup are performed, a physical backup file and a logical backup file are generated.
The database may be changed at any time during the database operation, and these change operations may be saved in a log. Alternatively, when the physical backup is not performed simultaneously with the logical backup, the logs of the database between the adjacent physical backup time points and the logs between the adjacent logical backup time points may be backed up to obtain backup logs. And the backup time point is the time point of executing the backup operation.
After the data and the log in the database are backed up, the data to be restored can be determined according to the restoration time point, the service information to be restored and the like. Then, referring to steps S102-S103, identifying a physical backup file associated with the data to be restored; if the data volume of the physical backup file is larger than a preset threshold value, acquiring first data from a logic backup file associated with the data to be restored;
and then, according to the first data and the backup log corresponding to the first data, recovering the data to be recovered.
Optionally, the backup log corresponding to the first data is a backup log between the backup time point of the first data and the time point to be restored.
In an example, the first data is data stored in a logical backup file of a 10:00 backup, and the data to be restored is data at a time point of 11:00 to be restored, and then the backup log corresponding to the first data is a backup log between 10:00 and 11: 00. If the first data is AB and the content of the backup log is that A is replaced by F, the time point to be recovered is 11: the result of the restoration processing on the data to be restored of 00 is FB.
Of course, if the data amount of the physical backup file is less than or equal to the preset threshold, the second data is obtained from the physical backup file. And the backup log corresponding to the second data is the backup log between the backup time point of the second data and the time point to be recovered.
Optionally, the shorter the period of backup, the shorter the time between adjacent backup time points, and the smaller the data amount of the backup log corresponding to the first data/second data. Based on this, the period of backup can be shortened, so that the data volume of the backup log corresponding to the first data/the second data is reduced, and the speed of data recovery is further improved.
The following describes the operation flow of the database recovery method in detail by using an example.
In one example, the period of backup is 1 hour, then the physical backup operation and the logical backup operation are performed at 10:00 hours, and the next physical backup operation and logical backup operation are performed at 11:00 hours. Backups are performed on logs between databases 10:00 to 11:00 to obtain backup logs. If the recovery time point is 10:30 of the day, the data to be recovered can be determined as 10:30 generated data. Further, it is possible to identify that day 10:30 is the physical ghosted file of the most recent 10:00 ghosted file 10:30 ago that day. And if the data volume of the physical backup file is larger than a preset threshold value, acquiring first data corresponding to the data to be restored from the logical backup file backed up at the speed of 10: 00. Then, extracting the backup log corresponding to the first data, namely the backup log between 10:00 and 10:30, from the backup log according to the time identification of the log in the backup log. And then, according to the first data and the extracted backup log, performing recovery processing on the data to be recovered.
On the contrary, if the data volume of the physical backup file is less than or equal to the preset threshold, second data corresponding to the data to be restored is acquired from the physical backup file backed up at 10: 00. Then, extracting the backup log corresponding to the second data, namely the backup log between 10:00 and 10:30, from the backup log according to the time identification of the log in the backup log. And then, according to the second data and the extracted backup log, performing recovery processing on the data to be recovered.
If the data to be restored is the data of the table level of the live broadcast information of 10:30 on the day, and the data volume of the physical backup file of the latest 10:00 backup before 10:30 on the day is larger than the preset threshold value, the data of the table level of the live broadcast information is acquired from the logical backup file of the 10:00 backup. Then, from the backup logs, extracting the backup log corresponding to the first data according to the time identifier of the log in the backup log and the data identifier of the table level, namely the backup log of the operation of recording the data of the table level between 10:00 and 10: 30. And then, according to the first data and the extracted backup log, performing recovery processing on the data to be recovered.
On the contrary, if the data volume of the physical backup file is smaller than or equal to the preset threshold, downloading the physical backup file with the backup ratio of 10:00 to the local, starting at least one database instance corresponding to the physical backup file, and acquiring the data of the database instance corresponding to the live broadcast information from the at least one database instance as second data. Then, from the backup logs, extracting a backup log corresponding to the second data according to the time identifier of the log in the backup log and the data identifier of the database instance, namely, the backup log records the operation of the data of the database instance between 10:00 and 10: 30. And then, according to the second data and the extracted backup log, performing recovery processing on the data to be recovered.
The embodiment of the present application further provides a database recovery apparatus 300, as shown in fig. 3, including a determining module 301, an identifying module 302, a first obtaining module 303, and a first recovering module 304.
The determining module 301 is configured to determine, in response to a database recovery instruction, data to be recovered.
An identifying module 302, configured to identify the physical backup file associated with the data to be restored determined by the determining module 301.
A first obtaining module 303, configured to obtain, if the data amount of the physical backup file identified by the identifying module 302 is greater than a preset threshold, first data required for recovering the data to be recovered from a logical backup file associated with the data to be recovered.
The first recovery module 304 is configured to perform recovery processing on the data to be recovered according to the first data acquired by the first acquisition module 303 and the backup log corresponding to the first data.
In the embodiment of the application, if the data volume of the physical backup file associated with the data to be restored is greater than the preset threshold, the data in the database is restored directly through the logical backup file without downloading the physical backup file with a large data volume for restoration processing, so that the data volume transmitted in the data restoration process is small, and the data restoration is fast.
Optionally, as shown in fig. 4, the database recovery apparatus 300 further includes a second obtaining module 305 and a second recovery module 306.
A second obtaining module 305, configured to obtain second data, which is required to restore the data to be restored, from the physical backup file if the data amount of the physical backup file identified by the identifying module 302 is less than or equal to a preset threshold.
The second recovery module 306 is configured to perform recovery processing on the data to be recovered according to the second data acquired by the second acquisition module 305 and the backup log corresponding to the second data.
Optionally, the second obtaining module 305 is specifically configured to: if the data volume of the physical backup file is less than or equal to a preset threshold value, downloading the physical backup file to the local; starting at least one database instance corresponding to the physical backup file; and acquiring second data required for recovering the data to be recovered from at least one database instance.
In this embodiment, if the data amount of the physical backup file is less than or equal to the preset threshold, the data in the database is restored according to the physical backup file, which takes a short time and further makes the data restoration faster.
Optionally, when the first obtaining module 303 obtains the first data required for recovering the data to be recovered from the logical backup file associated with the data to be recovered, the first obtaining module is specifically configured to: determining service information to be recovered according to a database recovery instruction; and acquiring data which accords with the service information to be recovered from the logic backup file associated with the data to be recovered as first data.
Optionally, the first obtaining module 303 is configured to, when obtaining data that conforms to the service information to be restored from the logical backup file associated with the data to be restored, specifically perform any one of the following operations:
acquiring data in accordance with the table level of the service information to be restored from a logic backup file associated with the data to be restored, and taking the data as first data;
and acquiring database-level data which accords with the service information to be restored from the logic backup file associated with the data to be restored as first data.
In the embodiment, the data can be recovered according to the service information by pre-establishing the corresponding relation between the service information to be recovered and the data to be recovered; moreover, by recovering data at the table level, data at the schema level, or data at the library level, the data in the database is recovered from multiple hierarchies, increasing the flexibility of data recovery.
Optionally, when determining the data to be recovered, the determining module 301 is specifically configured to: acquiring a recovery time point from a database recovery instruction; and determining the data to be recovered according to the recovery time point.
Optionally, the database recovery apparatus 300 further comprises a backup module. The backup module is used for carrying out physical backup and logical backup on data in the database before the recovery time point is acquired from the database recovery instruction so as to acquire a physical backup file and a logical backup file associated with the data to be recovered; and backing up the logs of the database between the adjacent backup time points to obtain backup logs.
The database recovery device corresponds to the description of the method flow, and reference is made to the description of the method flow for the deficiency, which is not repeated.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may 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, and the like) having computer-usable program code embodied therein.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (10)

1. A database recovery method, comprising:
responding to a database recovery instruction, and determining data to be recovered;
identifying a physical backup file associated with the data to be restored;
if the data volume of the physical backup file is larger than a preset threshold value, acquiring first data required for recovering the data to be recovered from a logical backup file associated with the data to be recovered; the preset threshold is determined in such a way that the time consumed for restoring the data according to the physical backup file is longer than the time consumed for restoring the data according to the logical backup file, and the data amount of the physical backup file at the moment is used as the preset threshold;
and according to the first data and the backup log corresponding to the first data, recovering the data to be recovered.
2. The method of claim 1, further comprising:
if the data volume of the physical backup file is smaller than or equal to the preset threshold, acquiring second data required for restoring the data to be restored from the physical backup file;
and according to the second data and the backup log corresponding to the second data, recovering the data to be recovered.
3. The method according to claim 2, wherein the obtaining, from the physical backup file, second data required for restoring the data to be restored comprises:
downloading the physical backup file to the local;
starting at least one database instance corresponding to the physical backup file;
and acquiring second data required for recovering the data to be recovered from the at least one database instance.
4. The method according to claim 1, wherein the obtaining first data required for restoring the data to be restored from the logical backup file associated with the data to be restored comprises:
determining service information to be recovered according to the database recovery instruction;
and acquiring data which accords with the service information to be recovered from the logic backup file associated with the data to be recovered as the first data.
5. The method according to claim 4, wherein the obtaining, as the first data, data that conforms to the service information to be restored from the logical backup file associated with the data to be restored comprises:
acquiring data in accordance with the table level of the service information to be restored from the logic backup file associated with the data to be restored, wherein the data is used as the first data; or
And acquiring database-level data which accords with the service information to be restored from the logic backup file associated with the data to be restored, wherein the database-level data is used as the first data.
6. The method of claim 1, wherein determining data to be recovered comprises:
acquiring a recovery time point from the database recovery instruction;
and determining the data to be recovered according to the recovery time point.
7. The method of claim 6, wherein before obtaining the recovery time point from the database recovery instruction, further comprising:
carrying out physical backup and logical backup on the data in the database to obtain a physical backup file and a logical backup file associated with the data to be restored; and
and backing up the logs of the database between the adjacent backup time points to obtain backup logs.
8. A database recovery apparatus, comprising:
the determining module is used for responding to the database recovery instruction and determining the data to be recovered;
the identification module is used for identifying the physical backup file associated with the data to be restored;
a first obtaining module, configured to obtain, from a logical backup file associated with the data to be restored, first data required to restore the data to be restored if the data amount of the physical backup file is greater than a preset threshold; the preset threshold is determined in such a way that the time consumed for restoring the data according to the physical backup file is longer than the time consumed for restoring the data according to the logical backup file, and the data amount of the physical backup file at the moment is used as the preset threshold;
and the first recovery module is used for performing recovery processing on the data to be recovered according to the first data and the backup log corresponding to the first data.
9. The apparatus of claim 8, further comprising:
a second obtaining module, configured to obtain, from the physical backup file, second data required to restore the data to be restored if the data amount of the physical backup file is less than or equal to the preset threshold;
and the second recovery module is used for recovering the data to be recovered according to the second data and the backup log corresponding to the second data.
10. The apparatus of claim 9, wherein the second obtaining module is specifically configured to:
if the data volume of the physical backup file is smaller than or equal to the preset threshold value, downloading the physical backup file to the local;
starting at least one database instance corresponding to the physical backup file;
and acquiring second data required for recovering the data to be recovered from the at least one database instance.
CN201710278027.0A 2017-04-25 2017-04-25 Database recovery method and device Active CN107179965B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710278027.0A CN107179965B (en) 2017-04-25 2017-04-25 Database recovery method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710278027.0A CN107179965B (en) 2017-04-25 2017-04-25 Database recovery method and device

Publications (2)

Publication Number Publication Date
CN107179965A CN107179965A (en) 2017-09-19
CN107179965B true CN107179965B (en) 2020-05-19

Family

ID=59831501

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710278027.0A Active CN107179965B (en) 2017-04-25 2017-04-25 Database recovery method and device

Country Status (1)

Country Link
CN (1) CN107179965B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110147529B (en) * 2018-02-13 2023-06-30 珠海金山办公软件有限公司 Method and device for recovering PDF comment
CN110737718A (en) * 2018-07-18 2020-01-31 杭州海康威视系统技术有限公司 Data backup method and device
CN109086170A (en) * 2018-08-15 2018-12-25 郑州云海信息技术有限公司 A kind of data base backup recovery method and device
CN110209527B (en) * 2018-11-30 2023-05-05 腾讯科技(深圳)有限公司 Data recovery method, device, server and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103605800A (en) * 2013-12-06 2014-02-26 贝壳网际(北京)安全技术有限公司 File processing method and file processing system
CN103853837A (en) * 2014-03-17 2014-06-11 上海爱数软件有限公司 Oracle table-level backup and recovering method for full-automatic continuously producing databases
CN104937570A (en) * 2013-01-29 2015-09-23 惠普发展公司,有限责任合伙企业 Restoration of file system object from raw image backup data

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104937570A (en) * 2013-01-29 2015-09-23 惠普发展公司,有限责任合伙企业 Restoration of file system object from raw image backup data
CN103605800A (en) * 2013-12-06 2014-02-26 贝壳网际(北京)安全技术有限公司 File processing method and file processing system
CN103853837A (en) * 2014-03-17 2014-06-11 上海爱数软件有限公司 Oracle table-level backup and recovering method for full-automatic continuously producing databases

Also Published As

Publication number Publication date
CN107179965A (en) 2017-09-19

Similar Documents

Publication Publication Date Title
CN107179965B (en) Database recovery method and device
CN106407356B (en) Data backup method and device
US8898113B2 (en) Managing replicated data
US20190102257A1 (en) Partial database restoration
CN107515874B (en) Method and equipment for synchronizing incremental data in distributed non-relational database
CN106899654B (en) Sequence value generation method, device and system
CN106844102B (en) Data recovery method and device
CN101308471B (en) Method and device for data restoration
CN108647357B (en) Data query method and device
CN103699548A (en) Method and equipment for recovering database data by using logs
CN110543386B (en) Data storage method, device, equipment and storage medium
CN105573859A (en) Data recovery method and device of database
EP3474143B1 (en) Method and apparatus for incremental recovery of data
CN109491834B (en) Data recovery method and device applied to database
CN112487083A (en) Data verification method and equipment
CN112612775A (en) Data storage method and device, computer equipment and storage medium
CN107315652B (en) Data backup method and cloud HDFS system
CN114117111A (en) Information retrieval method, device and system
CN112068981B (en) Knowledge base-based fault scanning recovery method and system in Linux operating system
CN109471901B (en) Data synchronization method and device
WO2017067397A1 (en) Data recovery method and device
CN116414914A (en) Data synchronization method and device, processor and electronic equipment
CN111698330B (en) Data recovery method and device of storage cluster and server
CN112685230B (en) Method for realizing backup and restoration of assigned time point by distributed database
CN108984343B (en) Virtual machine backup and storage management method based on content analysis

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
TR01 Transfer of patent right

Effective date of registration: 20210318

Address after: 101300 309, 3rd floor, 60 Fuqian 1st Street, Tianzhu District, Shunyi District, Beijing

Patentee after: Beijing longzhixin Technology Co.,Ltd.

Address before: 100041 room 120, 4th floor, building 17, yard 30, Shixing street, Shijingshan District, Beijing

Patentee before: BEIJING PANDA MUTUAL ENTERTAINMENT TECHNOLOGY Co.,Ltd.

TR01 Transfer of patent right