CN113407375B - Database deleted data recovery method, device, equipment and storage medium - Google Patents

Database deleted data recovery method, device, equipment and storage medium Download PDF

Info

Publication number
CN113407375B
CN113407375B CN202010183660.3A CN202010183660A CN113407375B CN 113407375 B CN113407375 B CN 113407375B CN 202010183660 A CN202010183660 A CN 202010183660A CN 113407375 B CN113407375 B CN 113407375B
Authority
CN
China
Prior art keywords
free block
data
database
target
type
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
CN202010183660.3A
Other languages
Chinese (zh)
Other versions
CN113407375A (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.)
Zhejiang Uniview Technologies Co Ltd
Original Assignee
Zhejiang Uniview Technologies 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 Zhejiang Uniview Technologies Co Ltd filed Critical Zhejiang Uniview Technologies Co Ltd
Priority to CN202010183660.3A priority Critical patent/CN113407375B/en
Publication of CN113407375A publication Critical patent/CN113407375A/en
Application granted granted Critical
Publication of CN113407375B publication Critical patent/CN113407375B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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

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 discloses a method, a device, equipment and a storage medium for recovering deleted data of a database. The recovery method of the deleted data of the database comprises the following steps: determining the starting address of a free block in the database to be restored according to the attribute information of the database to be restored; the free block is used for storing deleted data in the database to be restored; identifying the byte length of the target free block and the byte length of a component unit of the target free block, and determining the data integrity type of the target free block according to the byte length of the target free block and the byte length of the component unit of the target free block; and determining a data recovery strategy for the target free block according to the data integrity type, and recovering the data of the target free block by adopting the data recovery strategy. The method has the advantages of simple judgment step on the integrity of the free block data, wide reusability, realization of maximum recovery of the deleted data through a targeted recovery strategy and strong applicability.

Description

Database deleted data recovery method, device, equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of data recovery, in particular to a recovery method, a device, equipment and a storage medium for deleting data from a database.
Background
SQLite is a lightweight database whose design goal is embedded, and is currently used in many embedded products, which occupy very low resources, requiring only a few hundred KB of memory in the embedded device. SQLite is widely applied to the fields of embedded equipment, desktop application, websites and the like by a series of characteristics of less resource occupation, simple operation, zero management cost, good performance, code open source and the like. However, once the data loss occurs in the SQLite database-based system, a great deal of inconvenience is often brought to the user.
The existing method for recovering the SQLite database comprises the steps of presetting a plurality of SQLite page feature rules, and matching data in a search area by taking the SQLite page feature rules as matching basis to obtain deleted SQLite file page fragments on the current mobile terminal; and finally, decoding the data in the deleted SQLite file page fragments on the current mobile terminal.
However, pages are used as characteristic rules, so that the rule screening range of data recovery is too large, the refinement degree of recovered data is not high, the data recovery is still not complete enough, the integrity is still to be improved, and the operation efficiency is low.
Disclosure of Invention
The embodiment of the invention provides a method, a device, equipment and a storage medium for restoring deleted data of a database, which realize the accurate restoration of the deleted data in the database by judging the data integrity of a free block storing the deleted data in the database.
In a first aspect, an embodiment of the present invention provides a method for recovering deleted data from a database, including:
determining the starting address of a free block in the database to be restored according to the attribute information of the database to be restored; the free block is used for storing deleted data in the database to be restored;
identifying the byte length of a target free block and the byte length of a composition unit of the target free block, and determining the data integrity type of the target free block according to the byte length of the target free block and the byte length of the composition unit of the target free block;
and determining a data recovery strategy for the target free block according to the data integrity type, and recovering the data of the target free block by adopting the data recovery strategy.
In a second aspect, an embodiment of the present invention further provides a recovery apparatus for deleting data from a database, including:
the free block determining module is used for determining the starting address of the free block in the database to be restored according to the attribute information of the database to be restored; the free block is used for storing deleted data in the database to be restored;
The data integrity type determining module is used for identifying the byte length of the target free block and the byte length of a composition unit of the target free block, and determining the data integrity type of the target free block according to the byte length of the target free block and the byte length of the composition unit of the target free block;
and the data recovery strategy determining module is used for determining a data recovery strategy for the target free block according to the data integrity type and recovering the data of the target free block by adopting the data recovery strategy.
In a third aspect, an embodiment of the present invention further provides an apparatus, including:
one or more processors;
storage means for storing one or more programs,
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement a method for recovering database deletion data according to any of the embodiments of the present invention.
In a fourth aspect, an embodiment of the present invention further provides a computer readable storage medium, where a computer program is stored, where the program when executed by a processor implements a method for restoring database deletion data according to any embodiment of the present invention.
According to the embodiment of the invention, the attribute of the database to be restored is analyzed, and the position of the free block storing the deleted data is determined; the data integrity of the free block is rapidly determined according to the byte length of the free block composition unit and the identification of the content; and adopting corresponding recovery to realize the recovery of the deleted data according to the data integrity of the free block. The method has the advantages of simple judgment step on the integrity of the free block data, wide reusability, realization of maximum recovery of the deleted data through a targeted recovery strategy and strong applicability.
Drawings
FIG. 1 is a flowchart of a method for recovering database deleted data in a first embodiment of the present invention;
FIG. 2 (a) is a block diagram of the data integrity type of the free blocks of the first type in accordance with the first embodiment of the present invention;
FIG. 2 (b) is a block diagram of the data integrity type of the free blocks of the second type in the first embodiment of the present invention;
FIG. 3 is a flowchart of a method for recovering database deleted data in a second embodiment of the present invention;
fig. 4 is a schematic structural diagram of a database deleted data restoring device in the third embodiment of the present invention;
fig. 5 is a schematic structural view of an apparatus in a fourth embodiment of the present invention.
Detailed Description
The invention is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the structures related to the present invention are shown in the drawings.
Example 1
Fig. 1 is a flowchart of a method for restoring database deleted data in the first embodiment of the present invention, and this embodiment may be applicable to a case where data restoration is required to be implemented in a short time after deleting data in the SQLite database. The method may be performed by a database deletion data retrieval device, which may be implemented in software and/or hardware, and may be configured in a device, e.g., a device having communication and computing capabilities, such as a background server. As shown in fig. 1, the method specifically includes:
step 101, determining the initial address of a free block in the database to be restored according to attribute information of the database to be restored; and the free block is used for storing the deleted data in the database to be restored.
The database to be restored refers to a database in which some data are deleted randomly when the actual application operation is performed on the database. In the embodiment of the invention, the database to be recovered is the SQLite database, and the database to be recovered is applied to the embedded development field and has the characteristics of light weight, high processing speed and the like, so that the data deleted by mistake in the SQLite database can be recovered quickly. Free blocks refer to a collection of data units in a deleted database, which contains one or more deleted data units and fragments among the data units, and the free blocks enter a free block linked list to wait for recovery.
Specifically, the database encodes and stores the database content according to the inherent encoding format, so that the position of the free block can be positioned according to the attribute information stored in the database. And because the free blocks exist in the database in the form of free block chain list, after the starting address of the free block is determined, the addresses of all the free blocks in the database can be determined.
Step 102, identifying the byte length of the target free block and the byte length of the constituent unit of the target free block, and determining the data integrity type of the target free block according to the byte length of the target free block and the byte length of the constituent unit of the target free block.
The target free block refers to a currently recovered free block, for example, when the database to be recovered starts to recover, the target free block is the first free block in the free block chain table, after the data recovery of the first free block is completed, the target free block moves to the next free block, and so on. The byte length of a free block refers to the size of the free block as a whole, and the byte length of the free block can be determined according to the 3 rd byte and the 4 th byte of the free block according to the attribute of the database.
The composition unit of the target free block comprises: header fields, logical fields, and data fields;
Wherein, the byte length of the header field is a set interval value; each unit of the logical field is used to correspondingly describe the byte length of each unit of the data field.
Fig. 2 is a diagram showing a data structure of constituent units of a free block. The header field comprises two units, which can be represented as CellSize and RowId, wherein CellSize represents the byte length occupied by a unit memory, and the maximum size of the storage space occupied by CellSize can be judged to be 2 bytes according to the attribute of the database; the RowId represents the number of lines occupied by the unit data, and the number of lines recorded does not exceed the maximum integer value represented by 3 bytes according to the practical application scene of the SQlite database, so that the maximum occupied byte of the RowId is judged not to exceed 3 bytes.
The logic field consists of two types of units, one is HeaderSize, which represents the number of bytes occupied by the logic field and the rest of the units in the logic field; the other is a Type unit, N Type units in total in the logical field, and sequentially stored after the HeaderSize unit. TypeN represents the size of storage space occupied by the corresponding data field in the database table. The size of the unit content data is smaller than the page size, and the field size in the table should be smaller than the page size, so that a single Type unit occupies 2 bytes at maximum. And the size of the space occupied by the HeaderSize unit is 1 byte according to the attribute of the database.
The deleted effective Data content is stored in the Data field, N Data units corresponding to the N Type units in one free block are stored, and the size of the space occupied by the corresponding Data units is stored in the Type units. And in free block storage CellSize, rowId, headerSize, type units and Data units are stored sequentially. The determination of cell types based on the number of bytes occupied by each is facilitated.
In summary, in a free block, the three other types of units occupy 3 to 6 bytes of memory, except for the Type unit and the Data unit. Therefore, the byte length of the unit composed of the free blocks can be obtained according to the unit types sequentially determined in the free blocks, and the integrity of the data in the free blocks can be determined by combining the byte length of the target free blocks obtained through recognition. If the Data in the free block is incomplete, it indicates that the Type unit and the Data unit are missing, and the byte length of the unit cannot be determined, and the byte length of the unit is not matched with the byte length of the free block.
In an embodiment of the present invention, optionally, identifying a byte length of a target free block and a constituent unit byte length of the target free block, and determining a data integrity type of the target free block according to the byte length of the target free block and the constituent unit byte length of the target free block includes:
If the sum of the byte length of the header field, the byte length of the logic field and the byte length of the data field is equal to the byte length of the target free block, determining that the data integrity type of the target free block is a first type;
if the sum of the byte length minimum value of the header field, the byte length of the logic field and the byte length of the data field is smaller than or equal to the byte length of the target free block, determining that the data integrity type of the target free block is the second type;
otherwise, determining that the data integrity type of the target free block is a third type.
Specifically, the byte length of the free block, indicated by Size (FreeBlock), can be determined from the 3 rd byte and the 4 th byte of the target free block. The byte length occupied by the HeaderSize, rowId, cellSize three units in the free block is denoted by m, and m e {4,5,6} according to the above description. Illustratively, the sum of the byte length of the header field, the byte length of the logical field, and the byte length of the data field is equal to the byte length of the target free block can be expressed by the following equation:
the Length (Typei) is the number of bytes occupied by Typei, and the Size (Typei) is the Size of the data content Datai corresponding to Typei. If the equation is true, N Type units are complete, wherein the Type units are sequentially determined according to m+1 bytes; if the equation is not satisfied, the Type element is missing. When the equation is established, determining that the data integrity Type of the target free block is the first Type, and the corresponding data integrity Type is the composition unit data structure diagram of the free block of the first Type as shown in fig. 2 (a), wherein the gray part represents the number of bytes occupied by m, and the Type1 unit is complete for the target free block of the first Type.
When the above equation is not established, the Type element is missing. And in the case of a Type unit deletion there is one: type1 may change when deleting data. I.e., the header field in the free block content occupies 3 bytes, while Type1 may already be overwritten. In this case, the free block byte length and the byte length of each constituent unit satisfy the following inequality:
illustratively, on the basis that the above inequality holds, it is explained that Type1 is covered. And if the inequality is satisfied, the content from the second Type unit to the N Type unit is determined to be correct, the data integrity Type of the target free block is determined to be the second Type, the data structure diagram of the constituent units of the free block with the corresponding data integrity Type being the second Type is shown in fig. 2 (b), the number of bytes occupied by gray parts is 4, and the Type1 unit of the target free block is covered.
If the two conditions are not met, the content of the Type unit determined after the initial address of the free block deviates from m bytes is wrong, the Type unit lacks at least two, the deleted data in the free block is covered or deleted in blocks, at the moment, the position of the deleted Type unit cannot be accurately positioned, and the data integrity Type of the target free block is determined to be a third Type.
And step 103, determining a data recovery strategy for the target free block according to the data integrity type, and recovering the data of the target free block by adopting the data recovery strategy.
In the free block, the Type N correspondingly describes the Type and the size of the DataN, and the data to be deleted need to be recovered according to the Type N, and the DataN can be sequentially fetched according to the size of the whole data unit and the actual composition of the Type. The accuracy of recovery is therefore more dependent on the accuracy of Type. Through the judgment of the integrity of the free block data, the Type unit in the free block can be accurately and rapidly identified, and then the integrity of the free block data can be accurately judged according to the Type unit.
In the embodiment of the invention, different data recovery strategies are adopted for the data in the free blocks with different integrity types, the targeted recovery is favorable for improving the accuracy of data recovery, and the basis adopted in the process of determining the data integrity of the free blocks is the inherent attribute information of the database, so that the judging process is simple and quick, and the judging efficiency of the data integrity of the free blocks is improved.
In an embodiment of the present invention, optionally, determining a data recovery policy for the target free block according to the data integrity type includes:
If the data integrity type of the target free block is the first type, determining that the data recovery strategy of the target free block is sequential decoding recovery;
if the data integrity type of the target free block is the second type, determining that the data recovery strategy of the target free block is reverse decoding recovery;
and if the data integrity type of the target free block is the third type, determining that the data recovery strategy of the target free block is fuzzy decoding recovery.
Specifically, when the Data integrity Type of the target free block is the first Type, it is indicated that the content of each Type unit in the free block is complete, and the Data in the Data unit can be correspondingly fetched according to the content in the Type unit for recovery. For example, determining the m value that establishes the equation, determining the Type1 unit after m+1 bytes, and storing the number of bytes occupied by the Data1 unit in the Type1 unit, and determining the deletion content in the Data1 unit according to the number of bytes corresponding to the Type n unit. By analogy, the deleted Data in the Data units are read in a decoding mode, the Data in the Data units can be recovered one by one, and the accurate recovery of the deleted content in the target free block can be ensured.
When the data integrity Type of the target free block is the second Type, the content of each Type unit except the Type1 unit in the free block is complete, and then a reverse decoding recovery strategy is adopted for recovery. For example, the content in DataN is read first, then the content in Data2 is read sequentially, and finally the Data between the TypeN and the Data2 can be determined to be the content of Data1 according to the determined positions of the TypeN and the Data 2. The accurate recovery of deleted content in the free block can be realized by a strategy of reverse decoding recovery.
When the data integrity type of the target free block is the third type, the content deletion degree in the free block is severe, and in this case, accurate recovery cannot be performed, at this time, an integral fuzzy decoding recovery method is needed to decode and recover the integral content in the free block, semantic analysis is adopted to refine, useful information is obtained from the decoded and recovered content, and the recovery accuracy of deleting the content in the free block is improved as much as possible.
In an alternative embodiment, optionally, the method further comprises:
acquiring an unused space of a target in a database to be restored; wherein the unused space of the target is non-empty;
and recovering the data of the unused space of the target by adopting a fuzzy decoding recovery strategy.
The deleted data in the database may be stored in unused space in addition to the free blocks. For unused space, the unused space is in addition to the memory space being used by the database and the space occupied by the free block list. And determining that the content in the unused space is non-empty as a target unused space, and storing deleted content in the database to be restored in the target unused space.
And recovering the target unused space by using a fuzzy decoding recovery strategy, decoding and recovering the whole content in the target unused space, and then refining by adopting semantic analysis to obtain useful information, thereby improving the recovery accuracy of deleting the content in the target unused space as much as possible.
The method for recovering the deleted data in the database has the advantages that whether the free block is complete or not can be rapidly determined according to the judgment of the logic field, and therefore the recovery of the deleted data can be rapidly realized according to the corresponding recovery strategy. The judging mode is simple and quick, the reusability is wide, and the applicability is strong. Especially for the situation that after a user deletes data by mistake, the possibility that the data is stored in a free block and covered is low, the method for recovering the deleted data can achieve quick and accurate recovery of the deleted data, and data recovery efficiency is improved.
According to the embodiment of the invention, the attribute of the database to be restored is analyzed, and the position of the free block storing the deleted data is determined; the data integrity of the free block is rapidly determined according to the byte length of the free block composition unit and the identification of the content; and adopting corresponding recovery to realize the recovery of the deleted data according to the data integrity of the free block. The method has the advantages of simple judgment step on the integrity of the free block data, wide reusability, realization of maximum recovery of the deleted data through a targeted recovery strategy and strong applicability.
Example two
Fig. 3 is a flowchart of a method for recovering database deleted data in the second embodiment of the present invention, which is further optimized based on the first embodiment. As shown in fig. 3, the method includes:
step 301, obtaining attribute information in a database to be restored according to a storage format requirement of the database; wherein the attribute information includes at least data table information.
The database stores the file attributes and the content according to a certain storage format. The SQLite database, for example, stores each database in a separate file. The SQLite database consists of fixed size pages (pages). The page size may be between 512 and 32768 (including an exponent of 2 for both values), with a default size of 1024 bytes (1 KB). The page size may be set at the very time the database is created, and once the database object is created, this value cannot be changed any more. All pages in the database are numbered sequentially starting with 1. In a specific implementation, the page number is represented by 4 bytes and the maximum page number is limited to not exceed 2≡31. Page1 is called page1, page2 is called the second page, and so on.
Each database may be composed of at least one data table, and the data table information may obtain the relevant fields of the corresponding data page through a system table sqlite_master in the database. The system table sqlite_master holds summary information of the database. For example, the data table may be determined according to the 1 st field, the Type, the table name may be determined through the 2 nd field, the RootPage (root page number) of the table may be determined through the 4 th field, and the number of the Type fields of the data table may be determined through the 5 th field. Optionally, the attribute information further includes a page size, a database size, and a database encoding mode. Illustratively, 2 bytes after the header is shifted by 16 bytes represent PageSize (Page size), 4 bytes after the header is shifted by 28 bytes represent database size, where database size is in pages, and 4 bytes after the header is shifted by 56 bytes are database encoding. The database coding mode is used in the fuzzy decoding recovery strategy.
Therefore, the attribute information of the database is not limited to the above-described content, and other related information can be determined according to the file storage content and the storage format of the database, which is not described herein.
In one possible embodiment, before obtaining the attribute information in the database to be restored according to the storage format requirement of the database, the method further includes: the type of database is determined.
Specifically, the database is judged to determine whether the file is an SQLite database, which can be judged according to 16 bytes at the front end of the file header, taking SQLite3 as an example, and the content should be "SQLite format3\000".
And 302, determining target leaf page information from the database to be restored according to the data table information.
The types for pages in the database may be: btree pages, free pages, or overflow pages. There may be no free pages or overflow pages in a database, but there must be Btree pages. Btree is a tree structure and can be divided into a B-tree or a B+tree, and nodes of each tree are divided into an inner page and a leaf page. An SQLite database is made up of multiple Btrees. Each Btree occupies at least one complete page, each page being a junction of btrees. The 1 st page of each table or index is called the root page, the root page numbers of all tables or indexes are stored in the system table sqlite_master, and the root page of the system table sqlite_master is page1. The first page in the SQLite database is always the Btree page. The first 100 bytes of page1 are a header file describing the database. It includes version of database, version of format, page size, encoding, etc.
The start address of the free block is related to leaf page information in the database, so that target leaf page information in the database needs to be determined, wherein the target leaf page is a leaf page in the database storing record data, and the target leaf page information comprises the start address information of She Ziye.
In a possible embodiment, optionally, determining target leaf page information from the database to be restored according to the data table information includes:
determining root page numbers of all data tables in the database to be restored according to the data table information;
determining all leaf page numbers associated with the root page numbers according to the corresponding relation between the prestored root page numbers and the leaf pages;
and determining a candidate She Ziye according to the leaf page number, and taking the leaf page with stored record data in the candidate leaf pages as a target leaf page.
Specifically, according to the above-mentioned RootPage determining the data table in the database, all She Ziye of the data table can be determined according to the number, and whether the leaf page is the b+tree She Ziye storing the record data is determined, for example, whether the first byte is "0x0D" may be adopted for determining. All the b+tree She Ziye containing the stored record data are determined as the target leaf page according to the above-described determination method.
The starting address for each leaf page in the target leaf page information may be determined based on the page size in the data table information. Illustratively, the starting address of the leaf page is determined according to the following formula:
PageAddress=(PageNum-1)×PageSzie,PageNum∈{4,5,6}
the PageNum is the page number, and the value interval is {4,5,6} according to the attribute of the database, and PageSzie is the page size. From this formula, the starting addresses of all targets She Ziye can be determined.
And step 303, determining the starting address of the free block according to the target leaf page information.
Since the free blocks are in the form of free block lists, and the address of the first free block can be determined from the contents of two bytes after the leaf page is offset by one byte. Therefore, the starting address of the first free block can be found according to the content of the determined offset of the leaf page addresses in all the target leaf page information.
Step 304, identifying the byte length of the target free block and the byte length of the constituent unit of the target free block, and determining the data integrity type of the target free block according to the byte length of the target free block and the byte length of the constituent unit of the target free block.
And 305, determining a data recovery strategy for the target free block according to the data integrity type, and recovering the data of the target free block by adopting the data recovery strategy.
According to the embodiment of the invention, the attribute information is obtained by analyzing the storage format of the database, so that the basis is provided for determining the address of the position free block. And the simple determination method can improve the determination efficiency of the free block address, thereby improving the data recovery efficiency.
Example III
Fig. 4 is a schematic structural diagram of a database deleted data restoring apparatus according to a third embodiment of the present invention, and this embodiment is applicable to a case of restoring deleted data in an SQLite database. As shown in fig. 4, the apparatus includes:
a free block determining module 410, configured to determine a start address of a free block in the database to be restored according to attribute information of the database to be restored; the free block is used for storing deleted data in the database to be restored;
a data integrity type determining module 420, configured to identify a byte length of a target free block and a constituent unit byte length of the target free block, and determine a data integrity type of the target free block according to the byte length of the target free block and the constituent unit byte length of the target free block;
the data recovery policy determining module 430 is configured to determine a data recovery policy for the target free block according to the data integrity type, and recover data of the target free block by using the data recovery policy.
According to the embodiment of the invention, the attribute of the database to be restored is analyzed, and the position of the free block storing the deleted data is determined; the data integrity of the free block is rapidly determined according to the byte length of the free block composition unit and the identification of the content; and adopting corresponding recovery to realize the recovery of the deleted data according to the data integrity of the free block. The method has the advantages of simple judgment step on the integrity of the free block data, wide reusability, realization of maximum recovery of the deleted data through a targeted recovery strategy and strong applicability.
Optionally, the composition unit of the target free block includes: header fields, logical fields, and data fields;
wherein, the byte length of the header field is a set interval value; each unit of the logical field is used to correspondingly describe the byte length of each unit of the data field.
Optionally, the data integrity type determining module 420 includes:
a first type determining unit, configured to determine that a data integrity type of a target free block is a first type if a sum of a byte length of the header field, a byte length of the logical field, and a byte length of the data field is equal to a byte length of the target free block;
A second type determining unit, configured to determine that the data integrity type of the target free block is a second type if a sum of the byte length minimum value of the header field, the byte length of the logical field, and the byte length of the data field is less than or equal to the byte length of the target free block;
and the third type determining unit is used for determining that the data integrity type of the target free block is the third type if not.
Optionally, the data recovery policy determining module 430 is specifically configured to:
if the data integrity type of the target free block is the first type, determining that the data recovery strategy of the target free block is sequential decoding recovery;
if the data integrity type of the target free block is the second type, determining that the data recovery strategy of the target free block is reverse decoding recovery;
and if the data integrity type of the target free block is the third type, determining that the data recovery strategy of the target free block is fuzzy decoding recovery.
Optionally, the free block determination module 410 includes:
the attribute information acquisition unit is used for acquiring attribute information in the database to be restored according to the storage format requirement of the database; wherein the attribute information at least comprises data table information;
A target leaf page information determining unit, configured to determine target leaf page information from the database to be restored according to the data table information;
and the starting address determining unit is used for determining the starting address of the free block according to the target leaf page information.
Optionally, the target leaf page information determining unit is specifically configured to:
determining root page numbers of all data tables in the database to be restored according to the data table information;
determining all leaf page numbers associated with the root page numbers according to the corresponding relation between the prestored root page numbers and the leaf pages;
and determining a candidate She Ziye according to the leaf page number, and taking the leaf page with stored record data in the candidate leaf pages as a target leaf page.
Optionally, the device further includes a target unused space data recovery module, specifically configured to:
acquiring an unused space of a target in a database to be restored; wherein the unused space of the target is non-empty;
and recovering the data of the unused space of the target by adopting a fuzzy decoding recovery strategy.
The recovery device for the database deleted data provided by the embodiment of the invention can execute the recovery method for the database deleted data provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of executing the recovery method for the database deleted data.
Example IV
Fig. 5 is a schematic structural diagram of an apparatus according to a fourth embodiment of the present invention. Fig. 5 shows a block diagram of an exemplary device 12 suitable for use in implementing embodiments of the present invention. The device 12 shown in fig. 5 is merely an example and should not be construed as limiting the functionality and scope of use of embodiments of the present invention.
As shown in fig. 5, device 12 is in the form of a general purpose computing device. Components of device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory device 28, a bus 18 that connects the various system components, including the system memory device 28 and the processing unit 16.
Bus 18 represents one or more of several types of bus structures, including a memory device bus or memory device controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. By way of example, and not limitation, such architectures include Industry Standard Architecture (ISA) bus, micro channel architecture (MAC) bus, enhanced ISA bus, video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Device 12 typically includes a variety of computer system readable media. Such media can be any available media that is accessible by device 12 and includes both volatile and nonvolatile media, removable and non-removable media.
The system storage 28 may include computer system readable media in the form of volatile memory such as Random Access Memory (RAM) 30 and/or cache memory 32. Device 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from or write to non-removable, nonvolatile magnetic media (not shown in FIG. 5, commonly referred to as a "hard disk drive"). Although not shown in fig. 5, a magnetic disk drive for reading from and writing to a removable non-volatile magnetic disk (e.g., a "floppy disk"), and an optical disk drive for reading from or writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In such cases, each drive may be coupled to bus 18 through one or more data medium interfaces. The storage device 28 may include at least one program product having a set (e.g., at least one) of program modules configured to carry out the functions of the embodiments of the invention.
A program/utility 40 having a set (at least one) of program modules 42 may be stored, for example, in storage 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment. Program modules 42 generally perform the functions and/or methods of the embodiments described herein.
Device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), one or more devices that enable a user to interact with device 12, and/or any devices (e.g., network card, modem, etc.) that enable device 12 to communicate with one or more other computing devices. Such communication may occur through an input/output (I/O) interface 22. Also, device 12 may communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN) and/or a public network, such as the Internet, via network adapter 20. As shown in fig. 5, network adapter 20 communicates with other modules of device 12 over bus 18. It should be appreciated that although not shown in fig. 5, other hardware and/or software modules may be used in connection with device 12, including, but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, data backup storage systems, and the like.
The processing unit 16 executes various functional applications and data processing by running a program stored in the system storage device 28, for example, to implement a database deletion data recovery method provided by an embodiment of the present invention, including:
Determining the starting address of a free block in the database to be restored according to the attribute information of the database to be restored; the free block is used for storing deleted data in the database to be restored;
identifying the byte length of a target free block and the byte length of a composition unit of the target free block, and determining the data integrity type of the target free block according to the byte length of the target free block and the byte length of the composition unit of the target free block;
and determining a data recovery strategy for the target free block according to the data integrity type, and recovering the data of the target free block by adopting the data recovery strategy.
Example five
The fifth embodiment of the present invention further provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements a method for restoring database deletion data as provided by the embodiments of the present invention, including:
determining the starting address of a free block in the database to be restored according to the attribute information of the database to be restored; the free block is used for storing deleted data in the database to be restored;
identifying the byte length of a target free block and the byte length of a composition unit of the target free block, and determining the data integrity type of the target free block according to the byte length of the target free block and the byte length of the composition unit of the target free block;
And determining a data recovery strategy for the target free block according to the data integrity type, and recovering the data of the target free block by adopting the data recovery strategy.
The computer storage media of embodiments of the invention may take the form of any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
Note that the above is only a preferred embodiment of the present invention and the technical principle applied. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, while the invention has been described in connection with the above embodiments, the invention is not limited to the embodiments, but may be embodied in many other equivalent forms without departing from the spirit or scope of the invention, which is set forth in the following claims.

Claims (10)

1. A method for recovering deleted data of a database, comprising:
determining the starting address of a free block in the database to be restored according to the attribute information of the database to be restored; the free block is used for storing deleted data in the database to be restored;
identifying the byte length of a target free block and the byte length of a composition unit of the target free block, and determining the data integrity type of the target free block according to the byte length of the target free block and the byte length of the composition unit of the target free block; wherein the composition unit of the target free block comprises: the header field, the logic field and the data field, wherein the logic field consists of two types of units, one is HeaderSize which represents the number of bytes occupied by the header and the rest units in the logic field; the other Type is a Type unit, wherein N types of units are shared in the logic field and are sequentially stored after the HeaderSize unit, and the Type N represents the size of the storage space occupied by the corresponding data field in the database table; the data integrity Type of the target free block is used for representing the content integrity of the Type unit;
And determining a data recovery strategy for the target free block according to the data integrity type, and recovering the data of the target free block by adopting the data recovery strategy.
2. The method of claim 1, wherein the constituent units of the target free mass comprise: header fields, logical fields, and data fields;
wherein, the byte length of the header field is a set interval value; each unit of the logical field is used to correspondingly describe the byte length of each unit of the data field.
3. The method of claim 2, wherein identifying the byte length of the target free block and the constituent unit byte length of the target free block, and determining the data integrity type of the target free block based on the byte length of the target free block and the constituent unit byte length of the target free block comprises:
if the sum of the byte length of the header field, the byte length of the logic field and the byte length of the data field is equal to the byte length of the target free block, determining that the data integrity type of the target free block is a first type;
if the sum of the byte length minimum value of the header field, the byte length of the logic field and the byte length of the data field is smaller than or equal to the byte length of the target free block, determining that the data integrity type of the target free block is the second type;
Otherwise, determining that the data integrity type of the target free block is a third type.
4. A method according to claim 3, wherein determining a data recovery policy for a target free block based on the data integrity type comprises:
if the data integrity type of the target free block is the first type, determining that the data recovery strategy of the target free block is sequential decoding recovery;
if the data integrity type of the target free block is the second type, determining that the data recovery strategy of the target free block is reverse decoding recovery;
and if the data integrity type of the target free block is the third type, determining that the data recovery strategy of the target free block is fuzzy decoding recovery.
5. The method of claim 1, wherein determining the starting address of the free block in the database to be restored based on the attribute information of the database to be restored comprises:
acquiring attribute information in a database to be restored according to the storage format requirement of the database; wherein the attribute information at least comprises data table information;
determining target leaf page information from the database to be restored according to the data table information;
and determining the starting address of the free block according to the target leaf page information.
6. The method of claim 5, wherein determining target leaf page information from the database to be restored based on the data table information comprises:
determining root page numbers of all data tables in the database to be restored according to the data table information;
determining all leaf page numbers associated with the root page numbers according to the corresponding relation between the prestored root page numbers and the leaf pages;
and determining a candidate She Ziye according to the leaf page number, and taking the leaf page with stored record data in the candidate leaf pages as a target leaf page.
7. The method according to claim 1, wherein the method further comprises:
acquiring an unused space of a target in a database to be restored; wherein the unused space of the target is non-empty;
and recovering the data of the unused space of the target by adopting a fuzzy decoding recovery strategy.
8. A database deletion data recovery apparatus, comprising:
the free block determining module is used for determining the starting address of the free block in the database to be restored according to the attribute information of the database to be restored; the free block is used for storing deleted data in the database to be restored;
The data integrity type determining module is used for identifying the byte length of the target free block and the byte length of a composition unit of the target free block, and determining the data integrity type of the target free block according to the byte length of the target free block and the byte length of the composition unit of the target free block; wherein the composition unit of the target free block comprises: the header field, the logic field and the data field, wherein the logic field consists of two types of units, one is HeaderSize which represents the number of bytes occupied by the header and the rest units in the logic field; the other Type is a Type unit, wherein N types of units are shared in the logic field and are sequentially stored after the HeaderSize unit, and the Type N represents the size of the storage space occupied by the corresponding data field in the database table; the data integrity Type of the target free block is used for representing the content integrity of the Type unit;
and the data recovery strategy determining module is used for determining a data recovery strategy for the target free block according to the data integrity type and recovering the data of the target free block by adopting the data recovery strategy.
9. An apparatus, comprising:
one or more processors;
Storage means for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the method of recovering database deletion data as claimed in any one of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements a method for restoring database deletion data as claimed in any one of claims 1-7.
CN202010183660.3A 2020-03-16 2020-03-16 Database deleted data recovery method, device, equipment and storage medium Active CN113407375B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010183660.3A CN113407375B (en) 2020-03-16 2020-03-16 Database deleted data recovery method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010183660.3A CN113407375B (en) 2020-03-16 2020-03-16 Database deleted data recovery method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113407375A CN113407375A (en) 2021-09-17
CN113407375B true CN113407375B (en) 2024-03-29

Family

ID=77676837

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010183660.3A Active CN113407375B (en) 2020-03-16 2020-03-16 Database deleted data recovery method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113407375B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20140083556A (en) * 2012-12-26 2014-07-04 고려대학교 산학협력단 Method and Apparatus for recovering deleted data for SQLite database
CN104866610A (en) * 2015-06-04 2015-08-26 东南大学 Method for recovering SQLite deleted data based on similar type matching and estimation
KR101575246B1 (en) * 2014-12-10 2015-12-21 고려대학교 산학협력단 Corrupted record recovery method in SQLite database file
CN106844607A (en) * 2017-01-16 2017-06-13 重庆邮电大学 A kind of SQLite data reconstruction methods suitable for non-integer major key and idle merged block
KR20180043922A (en) * 2016-10-21 2018-05-02 고려대학교 산학협력단 METHOD, APPARATUS AND COMPUTER PROGRAM FOR RECOVERING THE DELETED RECORD IN ABNORMAL PAGE AND JOURNAL FILE OF SQLite

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20140083556A (en) * 2012-12-26 2014-07-04 고려대학교 산학협력단 Method and Apparatus for recovering deleted data for SQLite database
KR101575246B1 (en) * 2014-12-10 2015-12-21 고려대학교 산학협력단 Corrupted record recovery method in SQLite database file
CN104866610A (en) * 2015-06-04 2015-08-26 东南大学 Method for recovering SQLite deleted data based on similar type matching and estimation
KR20180043922A (en) * 2016-10-21 2018-05-02 고려대학교 산학협력단 METHOD, APPARATUS AND COMPUTER PROGRAM FOR RECOVERING THE DELETED RECORD IN ABNORMAL PAGE AND JOURNAL FILE OF SQLite
CN106844607A (en) * 2017-01-16 2017-06-13 重庆邮电大学 A kind of SQLite data reconstruction methods suitable for non-integer major key and idle merged block

Also Published As

Publication number Publication date
CN113407375A (en) 2021-09-17

Similar Documents

Publication Publication Date Title
US8788473B2 (en) Matching transactions in multi-level records
CN111949710B (en) Data storage method, device, server and storage medium
CN110532347B (en) Log data processing method, device, equipment and storage medium
CN110990406B (en) Fuzzy query method, device, equipment and medium
CN108921552B (en) Evidence verification method and device
WO2021051624A1 (en) Data acquisition method and apparatus, and electronic device and storage medium
CN110990346A (en) File data processing method, device, equipment and storage medium based on block chain
WO2019071907A1 (en) Method for identifying help information based on operation page, and application server
CN112052120B (en) Database deleted data recovery method and device
CN110287338B (en) Industry hotspot determination method, device, equipment and medium
US11379421B1 (en) Generating readable, compressed event trace logs from raw event trace logs
WO2020168763A1 (en) Data classification and storage method and apparatus of application program, device, and storage medium
US20160253374A1 (en) Data file writing method and system, and data file reading method and system
CN110737678B (en) Data searching method, device, equipment and storage medium
CN113407375B (en) Database deleted data recovery method, device, equipment and storage medium
CN113760894A (en) Data calling method and device, electronic equipment and storage medium
CN114385891B (en) Data searching method and device, electronic equipment and storage medium
CN112380174B (en) XFS file system analysis method containing deleted files, terminal device and storage medium
CN110795405B (en) Fragment data restoration method, terminal device and storage medium
CN115080684A (en) Network disk document indexing method and device, network disk and storage medium
WO2020211371A1 (en) Image restoration method and apparatus, device and storage medium
CN109635228B (en) Method, device, equipment and storage medium for determining difference degree between ordered arrays
US20220083918A1 (en) Intelligent scoring of missing data records
CN111782588A (en) File reading method, device, equipment and medium
CN109582850B (en) Webpage crawling method and device, storage medium 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