Method and device for recovering mistakenly deleted data in file system

By reading and rewriting the tombstone mark key-value pairs in the key-value database, the directory structure and file data of the file system are restored, and the recovery problem of accidentally deleted data in the file system is solved, improving the efficiency and accuracy of data recovery.

CN119396623APending Publication Date: 2025-02-07BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411365194.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-27
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

During the use of the file system, it is easy to cause the problem of accidentally deleting data, and it is difficult for the existing technology to effectively restore accidentally deleted data.

Method used

Data recovery is achieved by reading key-value pairs with tombstone marks from the key-value database, rewrite them to the database, and recovering the file system's directory structure and target file data.

Benefits of technology

It realizes that after data is deleted accidentally, data in the file system can be recovered in a timely manner, avoiding greater losses, and enhancing the data recovery performance of the file system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119396623A_ABST
    Figure CN119396623A_ABST
Patent Text Reader

Abstract

The invention provides a method and device for recovering mistakenly deleted data in a file system, and relates to the technical field of artificial intelligence such as big data and cloud services. The method for recovering the mistakenly deleted data in the file system comprises the steps of reading at least one target value corresponding to at least one target key from a key value database of the corresponding file system; obtaining at least one target key value pair according to the at least one target key and the at least one target value, and rewriting the at least one target key value pair into the key value database; according to at least one to-be-recovered data object corresponding to the at least one target key value pair, recovering a directory structure of the file system; according to at least one piece of object node data corresponding to the at least one to-be-recovered data object, at least one piece of target file data is obtained from a target disk, and the at least one piece of target file data is rewritten into the file system. The data recovery performance of the file system can be enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to the field of artificial intelligence technology such as big data and cloud services. A method, device, electronic device and readable storage medium for recovering accidentally deleted data in a file system are provided. Background Art

[0002] When using the file system, it is inevitable that erroneous operations may occur and data in the file system may be deleted. Therefore, how to restore the deleted data as much as possible after the erroneous operation occurs and the data in the file system is a technical problem that needs to be solved urgently. Summary of the invention

[0003] According to a first aspect of the present disclosure, a method for recovering accidentally deleted data in a file system is provided, comprising: reading at least one target value value corresponding to at least one target key key from a key-value database corresponding to the file system, the target key being a key with a tombstone mark added to the key-value database; obtaining at least one target key-value pair according to the at least one target key and the at least one target value, and rewriting the at least one target key-value pair into the key-value database; restoring a directory structure of the file system according to at least one data object to be recovered corresponding to the at least one target key-value pair; obtaining at least one target file data from a target disk according to at least one object node data corresponding to the at least one data object to be recovered, and rewriting the at least one target file data into the file system.

[0004] According to a second aspect of the present disclosure, a device for recovering accidentally deleted data in a file system is provided, comprising: a reading unit, used to read at least one target value value corresponding to at least one target key key from a key-value database corresponding to the file system, wherein the target key is a key with a tombstone mark added to the key-value database; a first recovery unit, used to obtain at least one target key-value pair according to the at least one target key and the at least one target value, and rewrite the at least one target key-value pair into the key-value database; a second recovery unit, used to recover the directory structure of the file system according to at least one data object to be recovered corresponding to the at least one target key-value pair; and a third recovery unit, used to obtain at least one target file data from a target disk according to at least one object node data corresponding to the at least one data object to be recovered, and rewrite the at least one target file data into the file system.

[0005] According to a third aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method as described above.

[0006] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the method as described above.

[0007] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising a computer program, wherein the computer program implements the method as described above when executed by a processor.

[0008] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0010] Figure 1 is a schematic diagram according to a first embodiment of the present disclosure;

[0011] Figure 2 is a schematic diagram according to a second embodiment of the present disclosure;

[0012] Figure 3 is a schematic diagram according to a third embodiment of the present disclosure;

[0013] Figure 4 The present invention is a block diagram of an electronic device used to implement the method for recovering accidentally deleted data in a file system according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0014] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and mechanisms is omitted in the following description.

[0015] Figure 1 Schematic diagram of the first embodiment of the present disclosure. Figure 1 As shown, the method for recovering accidentally deleted data in the file system of this embodiment specifically includes the following steps:

[0016] S101, reading at least one target value corresponding to at least one target key from a key-value database of a corresponding file system, wherein the target key is a key with a tombstone mark added to the key-value database;

[0017] S102, obtaining at least one target key-value pair according to the at least one target key and the at least one target value, and rewriting the at least one target key-value pair into the key-value database;

[0018] S103, restoring the directory structure of the file system according to at least one to-be-restored data object corresponding to the at least one target key-value pair;

[0019] S104. Acquire at least one target file data from a target disk according to at least one object node data respectively corresponding to the at least one data object to be recovered, and rewrite the at least one target file data into the file system.

[0020] The method for recovering accidentally deleted data in the file system of the present embodiment first obtains at least one target key-value pair according to a key key with a tombstone mark added in a key-value database, and after rewriting the at least one target key-value pair into the key-value database, completes the recovery of the key-value pair of the accidentally deleted data in the key-value database, and then completes the repair of the directory structure of the file system according to at least one data object to be recovered corresponding to the at least one target key value, and finally obtains at least one target file data according to at least one object node data corresponding to the at least one data object to be recovered to rewrite into the file system, thereby completing the recovery of accidentally deleted data in the file system. The present embodiment can achieve the purpose of promptly recovering accidentally deleted data in the file system after the occurrence of accidentally deleted data, avoid causing greater losses, and enhance the data recovery performance of the file system.

[0021] In this embodiment, the file system is a distributed file system, such as CephFS (Ceph File System); the key-value database is RocksDB (Rocks Database), which is used to store OMAP (Object Map) of each directory in the file system. An OMAP includes at least one key-value pair, and each key-value pair corresponds to metadata of a file or subdirectory in the corresponding directory.

[0022] For example, if there are a dir1 directory and a file1 file under the root directory of the file system, the OMAP corresponding to the root directory in the key-value database includes two key-value pairs, one key-value pair corresponding to the dir1 directory, and the other key-value pair corresponding to the file1 file; in the key-value pair corresponding to the dir1 directory, the key key is the name of the dir1 directory, and the value value is the index node (INode, Index Node) data corresponding to the dir1 directory, and the index node data may include the index node number of the dir1 directory, the directory entries under the dir1 directory, and other data.

[0023] Specifically, when executing S101, this embodiment reads at least one target value corresponding to at least one target key from the key-value database of the corresponding file system, and the implementation method that can be adopted is: traverse the keys in the key-value database. This embodiment can use the iterator (Iterator) in RocksDB to traverse the keys in the key-value database; use at least one key with a tombstone mark found during the traversal process as at least one target key; read at least one value corresponding to the at least one target key from the key-value database as at least one target value.

[0024] Among them, when executing S101, this embodiment determines that the currently traversed key is added with a tombstone mark, the value in the key-value pair corresponding to the currently traversed key (for example, the first non-tombstone mark value in the key-value pair) can be added with an erroneous deletion parameter, and then the value with the erroneous deletion parameter added is read from the key-value database as the target value corresponding to the corresponding target key.

[0025] In addition, when executing S101, this embodiment may also include the following content: when it is detected that the data recovery function of the file system is triggered, the operation of "traversing the keys in the key-value database" is immediately executed to shorten the recovery time of accidentally deleted data, thereby recovering the accidentally deleted data as much as possible.

[0026] In this embodiment, after the data is accidentally deleted, the user can click a data recovery function button provided by the file system to trigger the data recovery function of the file system, thereby recovering the previously erroneously deleted data.

[0027] It is understandable that after a user deletes a certain data (file or directory) in the file system, the key-value database will not directly delete the key-value pair corresponding to the data, but will add a tombstone mark to the key in the key-value pair corresponding to the data, and then the key-value database will perform the operation of "deleting the key-value pair corresponding to the key with the tombstone mark" when performing a subsequent compression operation.

[0028] Therefore, this embodiment uses the above characteristics provided by the key-value database to restore the accidentally deleted data by using the key-value pairs corresponding to the accidentally deleted data that still exist in the key-value database when the data in the file system is accidentally deleted.

[0029] In this embodiment, after executing S101 to read at least one target value value corresponding to at least one target key key, S102 is executed to obtain at least one target key-value pair according to the at least one target key and the at least one target value, and the at least one target key-value pair is rewritten into the key-value database.

[0030] When executing S102 in this embodiment, a target key and a target value corresponding to the target key may be taken as a target key-value pair according to the corresponding relationship between the key and the value.

[0031] Specifically, when executing S102 to rewrite at least one target key-value pair into the key-value database, the implementation method that can be adopted in this embodiment is: for each target key-value pair, determine the target object mapping corresponding to the target key-value pair in the key-value database; write the target key-value pair into the target object mapping determined in the key-value database, that is, rewrite the target key-value pair corresponding to the mistakenly deleted data into the object mapping corresponding to the corresponding directory in the key-value database.

[0032] Among them, when executing S102 to determine the target object mapping corresponding to the target key-value pair in the key-value database, this embodiment can first determine the target directory based on the target key-value pair, for example, taking the directory including the target key in the target key-value pair as the target directory, and then using the object mapping (OMAP) corresponding to the determined target directory in the key-value database as the target object mapping.

[0033] In this embodiment, at least one target key-value pair is rewritten into the key-value database by executing S102, so that the key-value database includes key-value pairs without tombstone marks and corresponding to the mistakenly deleted data, thereby completing the recovery of the key-value pairs of the mistakenly deleted data in the key-value database.

[0034] In this embodiment, after executing S102 to rewrite at least one target key-value pair into the key-value database, S103 is executed to restore the directory structure of the file system according to at least one data object to be restored corresponding to the at least one target key-value pair; in this embodiment, the data object to be restored can be a file or a directory.

[0035] In this embodiment, the directory structure of the file system is located in the metadata pool of the file system. The directory structure records the directories and files included in the file system, the relationship between different directories, and the relationship between directories and files.

[0036] In this embodiment, when executing S103, at least one data object to be restored may be determined according to at least one target key in at least one target key-value pair.

[0037] Specifically, when executing S103, the present embodiment restores the directory structure of the file system according to at least one data object to be restored that corresponds to at least one target key-value pair, and the implementation method that can be adopted is: for each data object to be restored, according to the object node (ONode, Object Node) data corresponding to the data object to be restored, obtain the storage path of the data object to be restored in the file system; according to the obtained storage path, determine the parent directory of the data object to be restored in the directory structure; under the determined parent directory, recreate the directory entry corresponding to the data object to be restored, thereby completing the recovery of the directory structure of the file system.

[0038] That is to say, this embodiment recovers the directory structure based on the object node data corresponding to the data object to be recovered. Since the object node data records the storage path of the data object to be recovered in the file system, this embodiment completes the recovery of the directory structure based on the parent directory of the data object to be recovered in the acquired storage path, which can improve the accuracy of directory structure recovery.

[0039] Among them, the object node data in this embodiment is stored in the key-value database. After completing the recovery of the key-value pairs of the accidentally deleted data in the key-value database, the object node data corresponding to the key-value pairs of the accidentally deleted data will also be restored. Therefore, when executing S103, this embodiment can obtain the object node data corresponding to the data object to be recovered based on the target key-value pairs rewritten into the key-value database.

[0040] In addition, when executing S103, this embodiment can also take the root directory of the directory structure as the starting point for each data object to be recovered, search the directories included in the directory structure according to the value (such as the index node number) corresponding to the data object to be recovered, take the directory corresponding to the value of the data object to be recovered as the parent directory, and then create a directory entry corresponding to the data object to be recovered under the searched parent directory, thereby completing the recovery of the directory structure.

[0041] After executing S103 to restore the directory structure of the file system, this embodiment executes S104 to obtain at least one target file data from the target disk according to at least one object node data corresponding to at least one data object to be recovered, and rewrites the at least one target file data into the file system; after rewriting the target file data (i.e., the file data corresponding to the mistakenly deleted data) into the file system, this embodiment completes the recovery of the mistakenly deleted data in the file system.

[0042] In this embodiment, the object node data corresponding to the data object to be recovered may include, in addition to the storage path of the data object to be recovered in the file system, the storage location of at least one data block corresponding to the data object to be recovered in the target disk.

[0043] In this embodiment, after the user deletes a certain data in the file system, the key-value database will not directly delete the key-value pair corresponding to the data, but will delete it during the subsequent compression operation; therefore, at least one data block corresponding to the data in the target disk will still be retained for a period of time after the data is deleted from the file system, and all data blocks corresponding to the key-value pair in the target disk will be deleted only after the key-value database completes the deletion of the corresponding key-value pair.

[0044] In this embodiment, the target disk is used to store all files included in the file system, and each file is divided into at least one database and stored in different locations in the target disk.

[0045] When executing S104, this embodiment obtains at least one target file data from the target disk according to at least one object node data corresponding to at least one data object to be recovered. The implementation method that can be adopted is: for each data object to be recovered, at least one storage location is determined according to the object node data corresponding to the data object to be recovered; according to the determined at least one storage location, at least one data block is obtained from the target disk; the at least one obtained data block is spliced ​​in sequence, and the target file data corresponding to the data object to be recovered is obtained according to the splicing result.

[0046] That is to say, since the file data corresponding to the data object to be recovered in this embodiment may be located in different storage locations in the target disk, this embodiment obtains different data blocks from the corresponding storage locations in the target disk to obtain the corresponding target file data based on the object node data of the data object to be recovered, thereby improving the accuracy of the obtained target file data.

[0047] In addition, when executing S104 to rewrite at least one target file data into the file system, this embodiment may also write all the acquired target data files into the file system after determining that all the target file data corresponding to all the data objects to be recovered have been acquired.

[0048] In this embodiment, after the target file data corresponding to the data object to be recovered is rewritten into the file system, the recovery of the accidentally deleted data in the file system is completed, and the user can view and operate the rewritten target file data; this embodiment can use the existing method to rewrite the target file data into the file system.

[0049] Figure 2 is a schematic diagram according to a second embodiment of the present disclosure. Figure 2 A schematic diagram showing the directory structure of the corresponding file system: Figure 2 In the embodiment, there are dir1 directory and file1 file under the root directory, and there is file2 file under the dir1 directory; under this directory structure, dir1 directory and file1 file will be saved in the OMAP of the root directory in the form of key-value pairs, and file2 file will be saved in the OMAP of the dir1 directory in the form of key-value pairs; if the data object to be recovered in this embodiment is file2 file, that is, the user deletes file2 file in the file system, "file2" under the dir1 directory in the directory structure will disappear, and this embodiment can first restore the key-value pair corresponding to file2 file in the key-value database, and then determine that the parent directory is "dir1 directory" according to the storage path ( / root directory / dir1 directory) corresponding to file2 file, and re-create the directory entry corresponding to file2 file under the "dir1 directory" of the directory structure to complete the recovery of the directory structure, and finally obtain the target file data corresponding to fiel2 file from the target disk, and after rewriting the obtained target file data into the file system, the recovery of the accidentally deleted data in the file system is completed.

[0050] Figure 3 is a schematic diagram according to the third embodiment of the present disclosure. Figure 3 As shown, the device 300 for recovering accidentally deleted data in a file system of this embodiment includes:

[0051] The reading unit 301 is used to read at least one target value value corresponding to at least one target key key from a key-value database of a corresponding file system, wherein the target key is a key with a tombstone mark added to the key-value database;

[0052] A first recovery unit 302 is configured to obtain at least one target key-value pair according to the at least one target key and the at least one target value, and rewrite the at least one target key-value pair into the key-value database;

[0053] A second restoring unit 303, configured to restore the directory structure of the file system according to at least one to-be-restored data object respectively corresponding to the at least one target key-value pair;

[0054] The third recovery unit 304 is used to obtain at least one target file data from the target disk according to at least one object node data respectively corresponding to the at least one data object to be recovered, and rewrite the at least one target file data into the file system.

[0055] Specifically, when the reading unit 301 reads at least one target value corresponding to at least one target key from the key-value database of the corresponding file system, the implementation method that can be adopted is: traversing the keys in the key-value database; taking at least one key with a tombstone mark added found during the traversal process as at least one target key; reading at least one value corresponding to at least one target key from the key-value database as at least one target value.

[0056] Among them, if it is determined that the currently traversed key has a tombstone mark added, the reading unit 301 can add an erroneous deletion parameter to the value in the key-value pair corresponding to the currently traversed key (for example, the first non-tombstone mark value in the key-value pair), and then read the value with the erroneous deletion parameter added from the key-value database as the target value corresponding to the corresponding target key.

[0057] In addition, the reading unit 301 can also perform the following operations: when it is detected that the data recovery function of the file system is triggered, immediately execute the operation of "traversing the keys in the key-value database" to shorten the recovery time of accidentally deleted data, thereby recovering the accidentally deleted data as much as possible.

[0058] In this embodiment, after the data is accidentally deleted, the user can click a data recovery function button provided by the file system to trigger the data recovery function of the file system, thereby recovering the previously erroneously deleted data.

[0059] In this embodiment, after the reading unit 301 reads at least one target value value corresponding to at least one target key key, the first recovery unit 302 obtains at least one target key-value pair based on the at least one target key and the at least one target value, and rewrites the at least one target key-value pair into the key-value database.

[0060] The first recovery unit 302 may take a target key and a target value corresponding to the target key as a target key-value pair according to the correspondence between the key and the value.

[0061] Specifically, when the first recovery unit 302 rewrites at least one target key-value pair into the key-value database, the implementation method that can be adopted is: for each target key-value pair, determine the target object mapping corresponding to the target key-value pair in the key-value database; write the target key-value pair into the target object mapping determined in the key-value database, that is, rewrite the target key-value pair corresponding to the accidentally deleted data into the object mapping corresponding to the corresponding directory in the key-value database.

[0062] Among them, when the first recovery unit 302 determines the target object mapping corresponding to the target key-value pair in the key-value database, it can first determine the target directory based on the target key-value pair, for example, taking the directory including the target key in the target key-value pair as the target directory, and then use the object mapping (OMAP) corresponding to the determined target directory in the key-value database as the target object mapping.

[0063] In this embodiment, after the first recovery unit 302 rewrites at least one target key-value pair into the key-value database, the second recovery unit 303 recovers the directory structure of the file system according to at least one data object to be recovered corresponding to the at least one target key-value pair; in this embodiment, the data object to be recovered can be a file or a directory.

[0064] In this embodiment, the directory structure of the file system is located in the metadata pool of the file system. The directory structure records the directories and files included in the file system, the relationship between different directories, and the relationship between directories and files.

[0065] The second recovery unit 303 may determine at least one data object to be recovered according to at least one target key in at least one target key-value pair.

[0066] Specifically, when the second recovery unit 303 recovers the directory structure of the file system according to at least one data object to be recovered corresponding to at least one target key-value pair, the implementation method that can be adopted is: for each data object to be recovered, according to the object node (ONode, Object Node) data corresponding to the data object to be recovered, obtain the storage path of the data object to be recovered in the file system; according to the obtained storage path, determine the parent directory of the data object to be recovered in the directory structure; under the determined parent directory, recreate the directory entry corresponding to the data object to be recovered, thereby completing the recovery of the directory structure of the file system.

[0067] That is to say, this embodiment recovers the directory structure based on the object node data corresponding to the data object to be recovered. Since the object node data records the storage path of the data object to be recovered in the file system, this embodiment completes the recovery of the directory structure based on the parent directory of the data object to be recovered in the acquired storage path, which can improve the accuracy of directory structure recovery.

[0068] Among them, the object node data in this embodiment is stored in the key-value database. After completing the recovery of the key-value pairs of the accidentally deleted data in the key-value database, the object node data corresponding to the key-value pairs of the accidentally deleted data will also be restored. Therefore, the second recovery unit 303 can obtain the object node data corresponding to the data object to be recovered based on the target key-value pairs rewritten into the key-value database.

[0069] In addition, the second recovery unit 303 can also, for each data object to be recovered, take the root directory of the directory structure as the starting point, search the directories included in the directory structure according to the value (such as the index node number) corresponding to the data object to be recovered, and use the directory corresponding to the value of the data object to be recovered as the parent directory, and then create a directory entry corresponding to the data object to be recovered under the searched parent directory, thereby completing the recovery of the directory structure.

[0070] In this embodiment, after the second recovery unit 303 recovers the directory structure of the file system, the third recovery unit 304 obtains at least one target file data from the target disk based on at least one object node data corresponding to at least one data object to be recovered, and rewrites the at least one target file data into the file system; after the target file data (i.e., the file data corresponding to the mistakenly deleted data) is rewritten into the file system, this embodiment completes the recovery of the mistakenly deleted data in the file system.

[0071] In this embodiment, the object node data corresponding to the data object to be recovered may include, in addition to the storage path of the data object to be recovered in the file system, the storage location of at least one data block corresponding to the data object to be recovered in the target disk.

[0072] In this embodiment, after the user deletes a certain data in the file system, the key-value database will not directly delete the key-value pair corresponding to the data, but will delete it during the subsequent compression operation; therefore, at least one data block corresponding to the data in the target disk will still be retained for a period of time after the data is deleted from the file system, and all data blocks corresponding to the key-value pair in the target disk will be deleted only after the key-value database completes the deletion of the corresponding key-value pair.

[0073] In this embodiment, the target disk is used to store all files included in the file system, and each file is divided into at least one database and stored in different locations in the target disk.

[0074] When the third recovery unit 304 obtains at least one target file data from the target disk according to at least one object node data corresponding to at least one data object to be recovered, the implementation method that can be adopted is: for each data object to be recovered, at least one storage location is determined according to the object node data corresponding to the data object to be recovered; according to the determined at least one storage location, at least one data block is obtained from the target disk; the at least one obtained data block is spliced ​​in sequence, and the target file data corresponding to the data object to be recovered is obtained according to the splicing result.

[0075] That is to say, since the file data corresponding to the data object to be recovered in this embodiment may be located in different storage locations in the target disk, this embodiment obtains different data blocks from the corresponding storage locations in the target disk to obtain the corresponding target file data based on the object node data of the data object to be recovered, thereby improving the accuracy of the obtained target file data.

[0076] In addition, when rewriting at least one target file data into the file system, the third recovery unit 304 may also write all the acquired target data files into the file system after determining that all the target file data corresponding to all the data objects to be recovered have been acquired.

[0077] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0078] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0079] like Figure 4, is a block diagram of an electronic device according to a method for recovering accidentally deleted data in a file system according to an embodiment of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0080] like Figure 4 As shown, the device 400 includes a computing unit 401, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 402 or a computer program loaded from a storage unit 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the device 400 can also be stored. The computing unit 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0081] A number of components in the device 400 are connected to the I / O interface 405, including: an input unit 404, such as a keyboard, a mouse, etc.; an output unit 404, such as various types of displays, speakers, etc.; a storage unit 408, such as a disk, an optical disk, etc.; and a communication unit 409, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 409 allows the device 400 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0082] The computing unit 401 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 401 performs the various methods and processes described above, such as a method for recovering accidentally deleted data in a file system. For example, in some embodiments, the method for recovering accidentally deleted data in a file system may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 408.

[0083] In some embodiments, part or all of the computer program may be loaded and / or installed on the device 400 via the ROM 402 and / or the communication unit 409. When the computer program is loaded into the RAM 403 and executed by the computing unit 401, one or more steps of the method for recovering accidentally deleted data in the file system described above may be executed. Alternatively, in other embodiments, the computing unit 401 may be configured to execute the method for recovering accidentally deleted data in the file system in any other appropriate manner (e.g., by means of firmware).

[0084] Various implementations of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0085] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a device for recovering accidentally deleted data in a general-purpose computer, a special-purpose computer, or other programmable file system, so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0086] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0087] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0088] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0089] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server for a distributed system, or a server combined with a blockchain.

[0090] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0091] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A method for recovering accidentally deleted data in a file system, comprising: Reading at least one target value corresponding to at least one target key from a key-value database of a corresponding file system, wherein the target key is a key with a tombstone mark added to the key-value database; Obtain at least one target key-value pair according to the at least one target key and the at least one target value, and rewrite the at least one target key-value pair into the key-value database; Restoring the directory structure of the file system according to at least one to-be-restored data object corresponding to the at least one target key-value pair; At least one target file data is acquired from the target disk according to at least one object node data respectively corresponding to the at least one data object to be recovered, and the at least one target file data is rewritten into the file system.

2. The method according to claim 1, wherein: The step of reading at least one target value value corresponding to at least one target key key from the key-value database of the corresponding file system comprises: Traversing the keys in the key-value database; At least one key with a tombstone mark added found during the traversal process is used as the at least one target key; At least one value value corresponding to the at least one target key is read from the key-value database as the at least one target value.

3. The method according to claim 2, wherein: The traversing of the keys in the key-value database includes: When it is detected that the data recovery function of the file system is triggered, the operation of traversing the keys in the key-value database is performed.

4. The method according to claim 1, wherein: The rewriting of the at least one target key-value pair into the key-value database comprises: For each target key-value pair, determining a target object mapping corresponding to the target key-value pair in the key-value database; The target key-value pair is written into the target object map in the key-value database.

5. The method according to claim 1, wherein: The step of restoring the directory structure of the file system according to at least one to-be-restored data object respectively corresponding to the at least one target key-value pair comprises: For each data object to be restored, according to the object node data corresponding to the data object to be restored, obtaining the storage path of the data object to be restored in the file system; Determine the parent directory of the data object to be restored in the directory structure according to the storage path; A directory entry corresponding to the data object to be restored is recreated under the parent directory to complete the restoration of the directory structure.

6. The method according to claim 1, wherein: The acquiring at least one target file data from the target disk according to at least one object node data respectively corresponding to the at least one data object to be recovered comprises: For each data object to be restored, determining at least one storage location according to object node data corresponding to the data object to be restored; Retrieving at least one data block from the target disk according to the at least one storage location; The at least one data block is spliced ​​in sequence, and target file data corresponding to the data object to be restored is obtained according to the splicing result.

7. A device for recovering accidentally deleted data in a file system, comprising: A reading unit, used for reading at least one target value value corresponding to at least one target key key from a key-value database of a corresponding file system, wherein the target key is a key with a tombstone mark added to the key-value database; A first recovery unit, configured to obtain at least one target key-value pair according to the at least one target key and the at least one target value, and rewrite the at least one target key-value pair into the key-value database; A second recovery unit, configured to recover the directory structure of the file system according to at least one to-be-recovered data object respectively corresponding to the at least one target key-value pair; The third recovery unit is used to obtain at least one target file data from the target disk according to at least one object node data respectively corresponding to the at least one data object to be recovered, and rewrite the at least one target file data into the file system.

8. The device according to claim 7, wherein: When the reading unit reads at least one target value value corresponding to at least one target key key from the key-value database of the corresponding file system, the reading unit specifically performs: Traversing the keys in the key-value database; At least one key with a tombstone mark added found during the traversal process is used as the at least one target key; At least one value value corresponding to the at least one target key is read from the key-value database as the at least one target value.

9. The device according to claim 8, wherein: When traversing the keys in the key-value database, the reading unit specifically performs: When it is detected that the data recovery function of the file system is triggered, the operation of traversing the keys in the key-value database is performed.

10. The device according to claim 7, wherein: When rewriting the at least one target key-value pair into the key-value database, the first recovery unit specifically performs: For each target key-value pair, determining a target object mapping corresponding to the target key-value pair in the key-value database; The target key-value pair is written into the target object map in the key-value database.

11. The device according to claim 7, wherein: When the second recovery unit recovers the directory structure of the file system according to the at least one to-be-recovered data object respectively corresponding to the at least one target key-value pair, the second recovery unit specifically performs: For each data object to be restored, according to the object node data corresponding to the data object to be restored, obtaining the storage path of the data object to be restored in the file system; Determine the parent directory of the data object to be restored in the directory structure according to the storage path; A directory entry corresponding to the data object to be restored is recreated under the parent directory to complete the restoration of the directory structure.

12. The device according to claim 7, wherein: When the third recovery unit obtains at least one target file data from the target disk according to at least one object node data respectively corresponding to the at least one data object to be recovered, the third recovery unit specifically performs: For each data object to be restored, determining at least one storage location according to object node data corresponding to the data object to be restored; Retrieving at least one data block from the target disk according to the at least one storage location; The at least one data block is spliced ​​in sequence, and target file data corresponding to the data object to be restored is obtained according to the splicing result.

13. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.

14. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 6.

15. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method for reconstructing disaster data file directory structure

    CN105677514A

  • Method and device for reconstructing an NTFS file directory tree, and storage medium

    CN111125298A

  • Method and device for deleting and recovering LevelDB or IndexedDB database records

    CN117370075A

  • Method for re-setting up catalogue structure and restoring data in FAI volume

    CN1945571A

  • Method for rebuilding directory structure and recovering data in NTFS volume

    CN1959649A