CN113407375A - Recovery method, device, equipment and storage medium for deleted data of database - Google Patents

Recovery method, device, equipment and storage medium for deleted data of database Download PDF

Info

Publication number
CN113407375A
CN113407375A CN202010183660.3A CN202010183660A CN113407375A CN 113407375 A CN113407375 A CN 113407375A CN 202010183660 A CN202010183660 A CN 202010183660A CN 113407375 A CN113407375 A CN 113407375A
Authority
CN
China
Prior art keywords
free block
data
database
target
determining
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.)
Granted
Application number
CN202010183660.3A
Other languages
Chinese (zh)
Other versions
CN113407375B (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

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

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

Description

Recovery method, device, equipment and storage medium for deleted data of database
Technical Field
The embodiment of the invention relates to the technical field of data recovery, in particular to a recovery method, a recovery device, recovery equipment and a storage medium for database deleted data.
Background
The SQLite is a light database, the design target of the SQLite is embedded, the SQLite is already used in a plurality of embedded products at present, the occupied resource is very low, and only a few hundred KB of memory is needed in the embedded device. The SQLite has a series of characteristics of less resource occupation, simple operation, zero management cost, good performance, open code source and the like, and is widely applied to the fields of embedded equipment, desktop application, Websites and the like. However, once the SQLite database-based system has data loss, it will bring inconvenience to the user.
The existing method for recovering the SQLite database comprises the steps of presetting a plurality of SQLite page characteristic rules, and matching data in a search area by taking the SQLite page characteristic rules as matching bases to obtain deleted SQLite file page fragments on the current mobile terminal; and finally, decoding the data in the deleted SQLite file page fragment on the current mobile terminal.
However, the page is used as the feature rule, 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 comprehensive enough, the integrity is 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 recovering deleted data of a database, which realize accurate recovery of the deleted data in the database by judging the integrity of data in 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 in a database, including:
determining the initial address of the free block in the database to be recovered according to the attribute information of the database to be recovered; the free block is used for storing deleted data in the database to be recovered;
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 device for recovering deleted data in a database, where the device includes:
the free block determining module is used for determining the initial address of the free block in the database to be recovered according to the attribute information of the database to be recovered; the free block is used for storing deleted data in the database to be recovered;
the data integrity type determining module is used for 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 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;
a storage device 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 implement the method for recovering database deletion data according to any embodiment of the present invention.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements a method for recovering deleted data in a database according to any embodiment of the present invention.
The embodiment of the invention determines the position of the free block storing the deleted data by analyzing the attribute of the database to be recovered; according to the length of the unit byte of the free block and the identification of the content, the data integrity of the free block is rapidly determined; and adopting corresponding recovery to realize recovery of the deleted data according to the data integrity of the free block. The method has the advantages of simple steps for judging the integrity of the free block data, wide reusability, strong applicability and realization of the maximum recovery of the deleted data through a targeted recovery strategy.
Drawings
FIG. 1 is a flowchart of a recovery method for database deleted data according to a first embodiment of the present invention;
fig. 2(a) is a data structure diagram of a component unit of a free block with a first data integrity type according to a first embodiment of the present invention;
fig. 2(b) is a data structure diagram of a component unit of a free block with a second type of data integrity in the first embodiment of the present invention;
FIG. 3 is a flowchart of a database deletion data recovery method according to a second embodiment of the present invention;
fig. 4 is a schematic structural diagram of a recovery apparatus for database deleted data according to a third embodiment of the present invention;
fig. 5 is a schematic structural diagram of an apparatus in the fourth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a flowchart of a recovery method for database deleted data in a first embodiment of the present invention, which is applicable to a case where data recovery needs to be implemented in a short time after data in an SQLite database is deleted. The method may be performed by a recovery apparatus for deleting data from a database, where the apparatus may be implemented in software and/or hardware, and may be configured in a device, for example, a device with communication and computing capabilities such as a background server. As shown in fig. 1, the method specifically includes:
step 101, determining an initial address of a free block in a database to be recovered according to attribute information of the database to be recovered; and the free block is used for storing the deleted data in the database to be recovered.
The database to be recovered refers to a database in which some data are deleted at random when the actual application operation is performed on the database. In the embodiment of the invention, the database to be recovered is an SQLite database, and as the database to be recovered is applied to the field of embedded development and has the characteristics of light weight, high processing speed and the like, the data deleted by mistake in the SQLite database can be quickly recovered. The free block is a data unit set in a deleted database, one or a plurality of deleted data units and fragments among the data units are contained in the free block, and the free block enters a free block chain table to wait for recovery.
Specifically, because the database encodes and stores the database content according to the inherent encoding format, the position of the free block can be located according to the attribute information stored in the database. And because the free block exists in the database in the form of a free block linked list, after the initial 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 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.
For example, when the database to be restored starts to be restored, the target free block is the first free block in the free block linked list, and after the data restoration of the first free block is completed, the target free block moves to the next free block, and so on. The byte length of the free block refers to the whole occupied size of the free block, 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 constituent units of the target free block include: a header field, a logical field, and a data field;
wherein, the byte length of the header field is a set interval value; each unit of the logical field is used for correspondingly describing the byte length of each unit of the data field.
Fig. 2 is a diagram showing a data structure of a constituent unit of a free block. The header field comprises two units which can be represented as CellSize and RowId, the CellSize represents the byte length occupied by the unit memory, and the maximum size of the storage space occupied by the CellSize can be judged to be 2 bytes according to the attribute of the database; RowId represents the line number occupied by the unit data, and according to the practical application scene of the SQlite database, the recording line number does not exceed the maximum integer value represented by 3 bytes, so that the maximum occupied byte of RowId is judged not to exceed 3 bytes.
The logical field consists of two types of units, one is HeaderSize which represents the number of bytes occupied by the logical field and the rest units in the logical field; the other is a Type unit, N Type units are shared in the logical field, and are sequentially stored after the HeaderSize unit. TypeN represents the size of storage space occupied by the corresponding data field in the database table. According to the database attribute, the data size of the unit content is smaller than the page size, and the field size in the table is supposed to be smaller than the page size, so that a single Type unit occupies 2 bytes at most. And the size of the space occupied by the HeaderSize unit is 1 byte according to the database attribute.
The Data field is stored with deleted effective Data content, N Data units are corresponding to N Type units in a free block, and the Type units are stored with the space occupied by the corresponding Data units. And in the free block storage, CellSize, RowId, HeaderSize, Type cell, and Data cell are sequentially stored. It is convenient to determine the type of the unit according to the number of bytes occupied by each.
In summary, in the free block, the storage space occupied by the three types of cells, except for the Type cell and the Data cell, is 3 to 6 bytes. Therefore, the byte length of the free block component unit can be obtained according to the sequentially determined unit types in the free block, and the integrity of the data in the free block can be determined by combining the byte length of the target free block obtained by identification. 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 at this time, the byte length of the unit does not match the byte length of the free block.
In this embodiment of the present invention, optionally, 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 includes:
if 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 a 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 less than or equal to the byte length of the target free block, determining that the data integrity type of the target free block is a 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 can be determined according to the 3 rd byte and the 4 th byte of the target free block, and is represented by size (FreeBlock). The byte length occupied by the three cells HeaderSize, RowId, CellSize in the free block is denoted by m, and m ∈ {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 being equal to the byte length of the target free block can be expressed by the following equation:
Figure BDA0002413421260000071
wherein length (Typei) is the number of bytes occupied by Typei, and size (Typei) is the size of data content Datai corresponding to Typei. If the equation is true, the 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 cell is missing. When the equation is satisfied, it is determined that the data integrity Type of the target free block is the first Type, and the data structure diagram of the corresponding component unit of the free block whose data integrity Type is the first Type is shown in fig. 2(a), where a gray part indicates the number of bytes occupied by m, and the unit is complete for the Type of target free block Type 1.
When the above equation is not satisfied, a Type cell is missing. And in the case of a Type cell being missing there is one case: type1 may change when data is deleted. I.e., the header field in the free block content takes 3 bytes, while Type1 may have been overwritten. In this case, the free block byte length and the byte length of each constituent unit satisfy the following inequality:
Figure BDA0002413421260000072
illustratively, the Type1 is overridden based on the establishment of the inequality described above. If the target free block lacks the content of Type1, the method determines from the 2 nd Type unit during formula calculation, and sequentially determines the content of Type units from the 4 th byte, and if the inequality is satisfied, it indicates that the content determined from the second Type unit to the nth Type unit is correct, at this time, it is determined that the data integrity Type of the target free block is the second Type, the data structure diagram of the component unit of the free block whose corresponding data integrity Type is the second Type is shown in fig. 2(b), the number of bytes occupied by the gray part is 4, and the Type of target free block Type1 unit is overwritten.
If the two situations do not meet, it is indicated that the content of the determined Type unit after the starting address of the free block is offset by m bytes is wrong, and at least two Type units are missing, which indicates that the deleted data in the free block is covered or deleted in blocks, and at this time, the position of the missing Type unit cannot be accurately located, and then it is determined that the data integrity Type of the target free block is the third Type.
And 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, Type and size of the DataN are described by Type n correspondingly, and data recovery and deletion need to be performed according to Type n, and the DataN can be sequentially taken out according to the size of the whole data unit and the actual composition of Type. The accuracy of the recovery is therefore more dependent on the accuracy of Type. Through the above-mentioned judgement to the data integrality of free block, can carry out accurate quick discernment to Type unit in the free block, and then carry out accurate judgement to the integrality of free block data according to 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, targeted recovery is carried out, which is beneficial to improving the accuracy of data recovery, and the data integrity of the free blocks is determined according to the inherent attribute information of the database, so that the judgment process is simple and quick, and the judgment efficiency of the data integrity of the free blocks is improved.
In this 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 a 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 a 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 a 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 indicates 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, if the value m for satisfying the equation is determined, the Type1 cell after m +1 bytes is determined, and the number of bytes occupied by the Data1 cell is stored in the Type1 cell, the deleted content in the Data1 cell can be determined according to the corresponding number of bytes after the Type n cell. By analogy, the deleted Data in the Data units are read in a decoding mode, the Data in the Data units can be restored one by one, and accurate restoration of the deleted contents in the target free block can be ensured.
And when the data integrity Type of the target free block is a second Type, which indicates that the contents of each Type unit except the Type1 unit in the free block are complete, recovering by adopting a strategy of reverse decoding recovery. Illustratively, the content in the DataN is read first, then the content in the Data2 is read sequentially, and finally the Data between the TypeN and the Data2 can be determined according to the determined positions of the TypeN and the Data 3526, namely the content of the Data 1. The strategy of recovery through reverse decoding can realize the accurate recovery of the deleted content in the free block.
When the data integrity type of the target free block is a third type, it is indicated that the content missing degree in the free block is serious, and in this case, accurate recovery cannot be performed, and at this time, an overall fuzzy decoding recovery method is required to be adopted to decode and recover the overall content in the free block, and then semantic analysis is adopted to refine, so as to obtain useful information, and improve the recovery accuracy of the deleted content in the free block as much as possible.
In an optional embodiment, optionally, the method further includes:
acquiring a target unused space in a database to be recovered; wherein the target unused space is non-empty;
and recovering the data of the target unused space by adopting a fuzzy decoding recovery strategy.
Deletion data in the database may be stored in unused space in addition to free blocks. For unused space, the unused space is the unused space except the memory space being used by the database and the space occupied by the free block chain table. And determining that the content in the unused space is not empty and is a target unused space, wherein the target unused space stores the deleted content in the database to be recovered.
The strategy of using fuzzy decoding to recover the target non-use space is used for recovering, the whole content in the target non-use space is decoded and recovered, then semantic analysis is adopted for refining, useful information is obtained, and the recovery accuracy of deleted content in the target non-use space is improved 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 quickly determined according to the judgment of the logical field, and therefore the deleted data can be quickly recovered according to the corresponding recovery strategy. The judgment mode is simple and quick, the reusability is wide, and the applicability is strong. Particularly, after the user deletes the data by mistake, the probability that the data is stored in the free block and is covered is low, the recovery method in the embodiment of the invention can realize the quick and accurate recovery of the deleted data, and the data recovery efficiency is improved.
The embodiment of the invention determines the position of the free block storing the deleted data by analyzing the attribute of the database to be recovered; according to the length of the unit byte of the free block and the identification of the content, the data integrity of the free block is rapidly determined; and adopting corresponding recovery to realize recovery of the deleted data according to the data integrity of the free block. The method has the advantages of simple steps for judging the integrity of the free block data, wide reusability, strong applicability and realization of the maximum recovery of the deleted data through a targeted recovery strategy.
Example two
Fig. 3 is a flowchart of a recovery method for database deletion data according to a second embodiment of the present invention, and the second embodiment is further optimized based on the first embodiment. As shown in fig. 3, the method includes:
301, acquiring attribute information in a database to be recovered according to the storage format requirement of the database; wherein the attribute information at least includes data table information.
The database stores file attributes and contents according to a certain storage format. Illustratively, the SQLite database stores each database in a separate file. The SQLite database consists of fixed-size pages (pages). The page size may be between 512-32768 (both values are included, must be an exponent of 2), with a default size of 1024 bytes (1 KB). The page size may be set just before 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 particular implementation, the page number is represented in 4 bytes and the maximum page number is limited to not exceed 2^ 31. The 1 st page is referred to as page1, the second page is referred to as page2, and so on.
Each database can be composed of at least one data table, and the data table information can obtain the relevant fields of the corresponding data pages through the system table sqlite _ master in the database. The system table sqlite master holds summary information of the database. For example, the Type can be determined according to the 1 st field in the table, the table name can be determined by the 2 nd field, the RootPage (root page number) of the table can be determined by the 4 th field, and the number of the Type fields in the data table can be determined by the 5 th field. Optionally, the attribute information further includes a page size, a database size, and a database encoding method. Illustratively, 2 bytes after the file header is offset by 16 bytes represents PageSize (page size), 4 bytes after the offset by 28 bytes represents database size, wherein the database size is in units of pages, and 4 bytes after the offset by 56 bytes represents the database encoding mode. The database coding mode is used in a fuzzy decoding recovery strategy.
Therefore, the attribute information of the database is not limited to the content described above, and other related information may be determined according to the file storage content and the storage format of the database, which is not described herein again.
In a possible embodiment, before acquiring 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 judgment of the database is performed to determine whether the file is the SQLite database, and the judgment can be performed according to 16 bytes at the front end of the file header, taking the SQLite3 as an example, the content shall be "SQLite format3\ 000".
Step 302, determining target leaf page information from the database to be recovered according to the data table information.
The types for pages in the database may be: btree pages, free pages, or overflow pages. There may not be free pages or overflow pages in a database, but necessarily Btree pages. Btree is a tree structure and can be divided into B-tree or B + tree, and the nodes of each tree are divided into internal pages and leaf pages. An SQLite database is composed of multiple Btree. Each Btree occupies at least one complete page, and each page is a node of Btree. The 1 st page of each table or index is referred to as the root page, and the root page numbers of all tables or indices are stored in the system table sqlite _ master, and the root page of the system table sqlite _ master is page 1. The first page in the SQLite database is always a Btree page. The first 100 bytes of page1 is a header file that describes the database. It includes the version of the database, the version of the format, the page size, the encoding, etc.
The start address of the free block is related to leaf page information in the database, and therefore target leaf page information in the database needs to be determined, where the target leaf page is a leaf page in the database where recorded data is stored, and the target leaf page information includes the start address information of the leaf page.
In a possible embodiment, optionally, determining target leaf page information from the database to be restored according to the data table information includes:
determining the root page numbers of all data tables in the database to be recovered according to the data table information;
determining all leaf page numbers related to the root page number according to a corresponding relation between the prestored root page number and the leaf pages;
and determining candidate leaf pages according to the leaf page numbers, and taking the leaf pages with storage record data in the candidate leaf pages as target leaf pages.
Specifically, according to the RootPage that determines the data table in the database, all leaf pages of the data table can be determined according to the number, and whether the leaf page is a B + tree leaf page that stores the record data is determined, for example, whether the first byte is "0 x 0D" can be used for determining the judgment manner. And determining all B + tree leaf pages containing the storage record data as target leaf pages according to the judgment mode.
The starting address for each leaf page in the target leaf page information may be determined according to the page size in the data table information. Illustratively, the starting address of a leaf page is determined according to the following formula:
PageAddress=(PageNum-1)×PageSzie,PageNum∈{4,5,6}
wherein, PageNum is the page number, the value range is {4,5,6} according to the attribute of the database, PageSzie is the page size. From this formula, the starting addresses of all target leaf pages can be determined.
And step 303, determining the starting address of the free block according to the target leaf page information.
Because the free block exists in the form of a free block linked list, and the address of the first free block can be determined according to 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 determined contents after the leaf page address offset in all the target leaf page information.
And step 304, identifying the byte length of the target free block and the byte length of the 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 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 of the database is acquired by analyzing the storage format of the database, so that a basis is provided for determining the address of the free block of the bit. And the simple determining method can improve the determining efficiency of the free block address, thereby improving the efficiency of data recovery.
EXAMPLE III
Fig. 4 is a schematic structural diagram of a database deleted data recovery device in the third embodiment of the present invention, which is applicable to a case of recovering deleted data in an SQLite database. As shown in fig. 4, the apparatus includes:
a free block determining module 410, configured to determine, according to the attribute information of the database to be recovered, an initial address of a free block in the database to be recovered; the free block is used for storing deleted data in the database to be recovered;
a data integrity type determining module 420, configured to identify a byte length of the target free block and a byte length of a constituent unit 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 byte length of the constituent unit of the target free block;
and a data recovery policy determining module 430, configured to determine a data recovery policy for the target free block according to the data integrity type, and recover the data of the target free block by using the data recovery policy.
The embodiment of the invention determines the position of the free block storing the deleted data by analyzing the attribute of the database to be recovered; according to the length of the unit byte of the free block and the identification of the content, the data integrity of the free block is rapidly determined; and adopting corresponding recovery to realize recovery of the deleted data according to the data integrity of the free block. The method has the advantages of simple steps for judging the integrity of the free block data, wide reusability, strong applicability and realization of the maximum recovery of the deleted data through a targeted recovery strategy.
Optionally, the unit of the target free block includes: a header field, a logical field, and a data field;
wherein, the byte length of the header field is a set interval value; each unit of the logical field is used for correspondingly describing 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 the data integrity type of the target free block is a first type if a 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;
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 minimum byte length 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;
a third type determining unit, configured to determine that the data integrity type of the target free block is a third type if the target free block is not the third type.
Optionally, the data recovery policy determining module 430 is specifically configured to:
if the data integrity type of the target free block is a 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 a 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 a third type, determining that the data recovery strategy of the target free block is fuzzy decoding recovery.
Optionally, the free block determining module 410 includes:
the attribute information acquisition unit is used for acquiring the attribute information in the database to be recovered according to the storage format requirement of the database; wherein the attribute information at least comprises data table information;
the target leaf page information determining unit is used for determining target leaf page information from the database to be recovered 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 the root page numbers of all data tables in the database to be recovered according to the data table information;
determining all leaf page numbers related to the root page number according to a corresponding relation between the prestored root page number and the leaf pages;
and determining candidate leaf pages according to the leaf page numbers, and taking the leaf pages with storage record data in the candidate leaf pages as target leaf pages.
Optionally, the apparatus further includes a target unused space data recovery module, specifically configured to:
acquiring a target unused space in a database to be recovered; wherein the target unused space is non-empty;
and recovering the data of the target unused space by adopting a fuzzy decoding recovery strategy.
The recovery device for database deleted data provided by the embodiment of the invention can execute the recovery method for 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 database deleted data.
Example four
Fig. 5 is a schematic structural diagram of an apparatus according to a fourth embodiment of the present invention. Fig. 5 illustrates 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 only an example and should not bring any limitations to the functionality and scope of use of the embodiments of the present invention.
As shown in FIG. 5, device 12 is in the form of a general purpose computing device. The components of device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory device 28, and a bus 18 that couples various system components including the system memory device 28 and the processing unit 16.
Bus 18 represents one or more of any of several types of bus structures, including a memory device bus or memory device controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, 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 may 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 storage, such as Random Access Memory (RAM)30 and/or cache storage 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 and write to non-removable, nonvolatile magnetic media (not shown in FIG. 5, and commonly referred to as a "hard drive"). Although not shown in FIG. 5, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 by one or more data media interfaces. Storage 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of 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 of which examples or some combination thereof may comprise an implementation of a network environment. Program modules 42 generally carry out the functions and/or methodologies of the described embodiments of the invention.
Device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), with one or more devices that enable a user to interact with device 12, and/or with any devices (e.g., network card, modem, etc.) that enable device 12 to communicate with one or more other computing devices. Such communication may be through an input/output (I/O) interface 22. Also, the device 12 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet) via the network adapter 20. As shown in FIG. 5, the network adapter 20 communicates with the other modules of the device 12 via the bus 18. It should be appreciated that although not shown in FIG. 5, other hardware and/or software modules may be used in conjunction with device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processing unit 16 executes various functional applications and data processing by running programs stored in the system storage device 28, for example, implementing a database deletion data recovery method provided by an embodiment of the present invention, including:
determining the initial address of the free block in the database to be recovered according to the attribute information of the database to be recovered; the free block is used for storing deleted data in the database to be recovered;
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, on which a computer program is stored, where the computer program, when executed by a processor, implements the method for recovering deleted data in a database according to the fifth embodiment of the present invention, where the method includes:
determining the initial address of the free block in the database to be recovered according to the attribute information of the database to be recovered; the free block is used for storing deleted data in the database to be recovered;
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.
Computer storage media for embodiments of the invention may employ 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. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination 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 the context of 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.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. 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 for aspects 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 + + or the like 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 type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. 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, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (10)

1. A recovery method for deleted data of a database is characterized by comprising the following steps:
determining the initial address of the free block in the database to be recovered according to the attribute information of the database to be recovered; the free block is used for storing deleted data in the database to be recovered;
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.
2. The method of claim 1, wherein the constituent units of the target free block comprise: a header field, a logical field, and a data field;
wherein, the byte length of the header field is a set interval value; each unit of the logical field is used for correspondingly describing 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 component unit byte length 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 component 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 logical field and the byte length of the data field is equal to the byte length of a 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 less than or equal to the byte length of the target free block, determining that the data integrity type of the target free block is a second type;
otherwise, determining that the data integrity type of the target free block is a third type.
4. The method of claim 3, wherein determining a data recovery policy for the target free block based on the data integrity type comprises:
if the data integrity type of the target free block is a 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 a 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 a 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 according to the attribute information of the database to be restored comprises:
acquiring attribute information in a database to be recovered 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 recovered 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 according to the data table information comprises:
determining the root page numbers of all data tables in the database to be recovered according to the data table information;
determining all leaf page numbers related to the root page number according to a corresponding relation between the prestored root page number and the leaf pages;
and determining candidate leaf pages according to the leaf page numbers, and taking the leaf pages with storage record data in the candidate leaf pages as target leaf pages.
7. The method of claim 1, further comprising:
acquiring a target unused space in a database to be recovered; wherein the target unused space is non-empty;
and recovering the data of the target unused space 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 initial address of the free block in the database to be recovered according to the attribute information of the database to be recovered; the free block is used for storing deleted data in the database to be recovered;
the data integrity type determining module is used for 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 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;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement a method of recovering database deletion data as recited in any one of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements a method for recovering database deletion data according to any one of claims 1 to 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 true CN113407375A (en) 2021-09-17
CN113407375B 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
CN113407375B (en) 2024-03-29

Similar Documents

Publication Publication Date Title
CN111090628B (en) Data processing method and device, storage medium and electronic equipment
US8788473B2 (en) Matching transactions in multi-level records
CN111949710B (en) Data storage method, device, server and storage medium
CN109471851B (en) Data processing method, device, server and storage medium
CN108921552B (en) Evidence verification method and device
CN111552792B (en) Information query method and device, electronic equipment and storage medium
CN110990346A (en) File data processing method, device, equipment and storage medium based on block chain
CN113760894A (en) Data calling method and device, electronic equipment and storage medium
CN110737678B (en) Data searching method, device, equipment and storage medium
CN110990406B (en) Fuzzy query method, device, equipment and medium
WO2019071907A1 (en) Method for identifying help information based on operation page, and application server
CN116126997B (en) Document deduplication storage method, system, device and storage medium
CN114385891B (en) Data searching method and device, electronic equipment and storage medium
CN115080684B (en) Network disk document indexing method and device, network disk and storage medium
US8463759B2 (en) Method and system for compressing data
CN107729347B (en) Method, device and equipment for acquiring synonym label and computer readable storage medium
CN113407375B (en) Database deleted data recovery method, device, equipment and storage medium
CN112506651B (en) Method and equipment for data operation in large-data-volume environment
CN109635228B (en) Method, device, equipment and storage medium for determining difference degree between ordered arrays
CN112394876A (en) Large file storage/reading method, storage/reading device and computer equipment
CN109491620B (en) Storage data rewriting method, device, server and storage medium
CN111400342A (en) Database updating method, device, equipment and storage medium
CN110134691B (en) Data verification method, device, equipment and medium
CN113609318B (en) Graph data processing method and device, electronic equipment and storage medium
CN112486960B (en) SQLite database redundant data clearing method

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