Data recovery method, device, equipment and medium

By detecting file deletion operations in the distributed file system, determining the recycling bin and target storage paths, and recycling the deleted files to the target recycling bin management node, solving the resource isolation and security problems of data recycling in multi-tenant multi-namespaces, and achieving efficient data recycling and secure isolation.

CN119759853APending Publication Date: 2025-04-04INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411875646.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-18
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

In a distributed file system with multi-tenant and multi-namespace, after users delete data, the resource isolation and security of the recycling bin is difficult to guarantee, and the operation is cumbersome.

Method used

By detecting the file deletion operation, it is determined whether there is a recycling bin to the namespace where the deleted file belongs. In the case of existence, it determines the target recycling bin management node, generates the target storage path, and recycles the deleted files to the target recycling bin management node.

Benefits of technology

Isolation of namespace and system resources is achieved, data security is improved, and operational processes are simplified.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119759853A_ABST
    Figure CN119759853A_ABST
Patent Text Reader

Abstract

The present application relates to the field of distributed storage technology, and mainly to a data recovery method, device, equipment and medium, including: when a file deletion operation is detected, determining whether there is a corresponding recycle bin in the namespace to which the deleted file belongs; when there is a corresponding recycle bin in the namespace to which the deleted file belongs, determining the target recycle bin management node in the recycle bin that is closest to the hierarchical distance of the deleted file; generating a target storage path for the deleted file according to the file path of the deleted file and the user identifier of the file deletion operation; and recovering the deleted file to the target recycle bin management node according to the target storage path. By using the embodiments of the present application, system resource isolation is realized through a recycle bin at the namespace level, and on this basis, file directory hierarchical isolation and user data isolation in the recycle bin are simultaneously realized, thereby improving the security of the system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of distributed storage technology and mainly relates to a data recovery method, device, equipment and medium. Background Art

[0002] When using a distributed file system, users may accidentally delete data. If the accidentally deleted data is important, it may cause serious consequences. In response to this situation, related technologies propose to add a recycle bin function to the distributed file system. This method is to enable the recycle bin in the entire file system. For scenarios where the system is multi-tenant and multi-namespace (NS, NameSpace), if the user's deleted data is stored in the system's recycle bin, when the user's deleted data is lost, it is necessary to request to view the deleted data from the system's recycle bin. This cannot guarantee the isolation of system resources and has low security. If the isolation of system resources is guaranteed, different viewing permissions need to be configured for different users, which is cumbersome.

[0003] Therefore, how to recycle the user's deleted data to conveniently ensure the isolation of system resources and user data and improve the security of the system is an urgent problem to be solved. Summary of the invention

[0004] One of the purposes of this application is to propose a data recovery method to solve or at least partially solve the problems in the related art. The second purpose of this application is to provide a data recovery device, the third purpose of this application is to provide a device, and the fourth purpose of this application is to provide a medium.

[0005] In order to achieve the above purpose, the technical solution of this application is as follows: A data recovery method, the method comprising: When a file deletion operation is detected, determining whether there is a corresponding recycle bin in the namespace to which the deleted file belongs; In the case that a corresponding recycle bin exists in the namespace to which the deleted file belongs, determining a target recycle bin management node in the recycle bin that is closest to the level of the deleted file; the level of the target recycle bin management node is higher than or equal to the level of the deleted file; Generate a target storage path for the deleted file according to the file path of the deleted file and the user identifier of the file deletion operation; According to the target storage path, the deleted files are recycled to the target recycle bin management node.

[0006] Optionally, when a file deletion operation is detected, determining whether a corresponding recycle bin exists in the namespace to which the deleted file belongs includes: Determine, according to the file directory to which the deleted file belongs, an identifier of the namespace to which the deleted file belongs; According to the identifier, searching the metadata of the system for a recycle bin switch flag of the namespace to which the deleted file belongs; When the recycle bin switch flag is configured to be turned on, it is determined that a corresponding recycle bin exists in the namespace to which the deleted file belongs.

[0007] Optionally, when a corresponding recycle bin exists in the namespace to which the deleted file belongs, determining a target recycle bin management node in the recycle bin that is closest to the hierarchical distance of the deleted file includes: Determine the file directory level of the deleted file in the namespace; Traversing the levels of each recycle bin management node in the recycle bin from the metadata; wherein the level of each recycle bin management node is the level of each recycle bin management node in the recycle bin; According to the file directory level and the levels of each recycle bin management node, a target recycle bin management node that is closest to the level of the deleted file is determined.

[0008] Optionally, generating a target storage path of the deleted file according to the file path of the deleted file and a user identifier of the file deletion operation includes: Determining the primary group user to which the deleted file belongs according to the user identifier of the file deletion operation; Determine the identifier of the primary group user as the name of the secondary directory under the root directory in the recycle bin; The file path of the deleted file is added under the secondary directory name to generate a target storage path of the deleted file.

[0009] Optionally, before recycling the deleted file to the target recycle bin management node according to the target storage path, the method further includes: Detecting whether the deleted file meets a recycling condition, wherein the recycling condition includes: the size of the deleted file is lower than a preset threshold and the type of the deleted file is a preset file type; If the deleted file meets the recycling condition, detecting whether there is a file with the same name as the deleted file in the target storage path in the recycle bin; If there is no file with the same name as the deleted file under the target storage path in the recycle bin, recycling the deleted file to the target recycle bin management node according to the target storage path; If there is a file with the same name as the deleted file in the target storage path in the recycle bin, adding a timestamp to the file name of the deleted file; The deleted files are recycled to the target recycling bin management node.

[0010] Optionally, when a file deletion operation is detected, before determining whether there is a corresponding recycle bin in the namespace to which the deleted file belongs, the method further includes: A hidden folder is created under the root target of the namespace; the hidden folder is a recycle bin corresponding to the namespace; According to the current file directory of the namespace, configure the file directory of the hidden folder; One or more recycle bin management nodes are configured according to the file directory of the hidden folder.

[0011] Optionally, the method further includes: Determining a recovery file path for the deleted file according to a file recovery operation for the deleted file in the recycle bin; Detecting whether the recovery file path exists in the namespace; If the recovery file path exists in the namespace, moving the deleted file to the namespace according to the recovery file path; When the restored file path does not exist in the namespace, adjusting the file directory of the namespace according to the restored file path; According to the recovery file path, the deleted file is moved to the adjusted namespace.

[0012] A data recovery device, comprising: A first determination module is used to determine whether there is a corresponding recycle bin in the namespace to which the deleted file belongs when a file deletion operation is detected; A second determination module is used to determine, when there is a corresponding recycle bin in the namespace to which the deleted file belongs, a target recycle bin management node in the recycle bin that is closest to the level of the deleted file; the level of the target recycle bin management node is higher than or equal to the level of the deleted file; A generating module, used for generating a target storage path of the deleted file according to the file path of the deleted file and the user identifier of the file deletion operation; The recycling module is used to recycle the deleted files to the target recycling bin management node according to the target storage path.

[0013] An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned data recovery method when executing the computer program.

[0014] A non-volatile storage medium stores a computer program, which implements the above-mentioned data recovery method when executed by a processor.

[0015] Beneficial effects of this application: In the present application, when a file deletion operation is detected, it is determined whether there is a corresponding recycle bin in the namespace to which the deleted file belongs; when there is a corresponding recycle bin in the namespace to which the deleted file belongs, the target recycle bin management node in the recycle bin that is closest to the hierarchical distance of the deleted file is determined; the hierarchical level of the target recycle bin management node is higher than or equal to the hierarchical level of the deleted file; the target storage path of the deleted file is generated according to the file path of the deleted file and the user identifier of the file deletion operation; according to the target storage path, the deleted file is recycled to the target recycle bin management node. By making the recycle bin correspond to the namespace, the granularity of the recycle bin is refined to the namespace level to ensure the isolation of the namespace and system resources. On this basis, the recycle bin management node is set as a node on the target level of the recycle bin to achieve isolation at the file directory level. At the same time, the storage path of the deleted file in the recycle bin is generated based on the user identifier, which also achieves user isolation. The application of this embodiment improves the security of system data. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0017] Figure 1 is a flow chart of a data recovery method described in an embodiment of the present application; Figure 2 It is a timing diagram of establishing a recycling station in the data recycling method described in one embodiment of the present application; Figure 3 is a schematic diagram of the timing of recovering deleted data in a data recovery method described in an embodiment of the present application; Figure 4 It is a timing diagram of the recovery of deleted data in the data recovery method described in one embodiment of the present application; Figure 5 It is a schematic diagram of the framework of the data recovery device described in one embodiment of the present application.

[0018] Among them, 500-data recovery device, 501-first determination module, 502-second determination module, 503-generation module, 504-recovery module. DETAILED DESCRIPTION

[0019] The following will describe the implementation methods of the present application with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. The present application can also be implemented or applied through other different specific implementation methods, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be understood that the preferred embodiments are only for illustrating the present application, not for limiting the scope of protection of the present application.

[0020] The namespace of a distributed file system refers to the directory structure and file collection of the entire file system.

[0021] In a distributed file system, namespace is a key concept. It represents the logical view of the file system, that is, the structure of files and directories that users can see and operate. This logical view may span multiple physical storage locations. Through a unified namespace, users can transparently access these file resources distributed in different physical locations. The management and maintenance of the namespace is the responsibility of the metadata server of the distributed file system. These servers store and maintain the metadata of the file system, including information such as the structure, location, and access rights of files and directories. In this way, the distributed file system provides users with a centrally managed, easy-to-use file access interface without having to worry about the physical distribution and storage details of the underlying data, thereby achieving resource space isolation.

[0022] The primary group user to which a file belongs refers to the user who created the file. For data in the Recycle Bin, the user who performs the file deletion operation in the namespace is the primary group user of the deleted file in this file deletion operation.

[0023] Metadata, also known as intermediary data or relay data, is data about data. It mainly describes the properties of data, including file name, file size, file permissions, file owner, etc., as well as file block mapping information, that is, which data blocks belong to which file. These metadata are stored on the NameNode, which also maintains the mapping information of file blocks, that is, which data blocks belong to which file. It is used to support functions such as indicating storage location, historical data, resource search, and file records. Metadata can be regarded as an electronic catalog. In order to achieve the purpose of cataloging, it is necessary to describe and collect the content or characteristics of the data, thereby achieving the purpose of assisting data retrieval.

[0024] Reference Figure 1 , Figure 1 is a flow chart of a data recovery method described in an embodiment of the present application. For a distributed file system with multiple users and multiple namespaces, such as Figure 1 As shown, in one embodiment of the present application, the data recovery method is specifically performed according to the following steps: Step S101, when a file deletion operation is detected, it is determined whether there is a corresponding recycle bin in the namespace to which the deleted file belongs.

[0025] Specifically, to determine whether there is a corresponding recycle bin in the namespace to which the deleted file belongs, it is necessary to query whether the recycle bin corresponding to the namespace is turned on. After the system queries the metadata, if the recycle bin switch flag of the namespace indicates that the recycle bin is turned on, the subsequent steps can be executed. If the switch of the recycle bin corresponding to the namespace indicates that the recycle bin is turned off, the file is directly deleted without executing the subsequent steps.

[0026] If the system detects that the namespace has not been configured with a corresponding recycle bin, a corresponding recycle bin can be created under the namespace.

[0027] In a feasible implementation manner, in step S101, when a file deletion operation is detected, it is determined whether there is a corresponding recycle bin in the namespace to which the deleted file belongs. Before execution, the method further includes: A hidden folder is created under the root target of the namespace; the hidden folder is a recycle bin corresponding to the namespace; According to the current file directory of the namespace, configure the file directory of the hidden folder; One or more recycle bin management nodes are configured according to the file directory of the hidden folder.

[0028] Specifically, if the namespace has not yet been configured with a corresponding recycle bin, a corresponding recycle bin can be established under the namespace. Specifically, a hidden folder is established under the root target of the namespace; the hidden folder is the recycle bin corresponding to the namespace. It can be understood that the recycle bin corresponding to the namespace is set under the namespace. The recycle bin can be regarded as a folder consistent with the current file directory of the namespace. After the recycle bin is created, there is only a file directory but no file data. At this time, the recycle bin management node can be configured according to the file directory of the recycle bin. For example, if the file directory of the namespace is A / B / C at this time, the file directory of the recycle bin is A / B / C. The recycle bin management node R can be configured at the A layer, and the level of the recycle bin management node R is the level in the file directory where A is located (the first level). The recycle bin management node S can be configured at the B layer, and the level of the recycle bin management node S is the level in the file directory where B is located (the second level)... In this embodiment, by establishing a corresponding recycle bin for the namespace, isolation between namespaces (system resource isolation) can be achieved, and by setting a recycle bin management node in the recycle bin corresponding to the namespace, it is convenient to subsequently achieve isolation between hierarchical data.

[0029] In actual applications, if a recycle bin management node is set for the recycle bin corresponding to the namespace, a recycle bin management node corresponding to the top-level directory in the recycle bin is generated by default.

[0030] Step S102, when there is a corresponding recycle bin in the namespace to which the deleted file belongs, determine a target recycle bin management node in the recycle bin that is closest to the level of the deleted file; the level of the target recycle bin management node is higher than or equal to the level of the deleted file.

[0031] Specifically, when there is a corresponding recycle bin in the namespace to which the deleted file belongs, it indicates that the deleted data needs to be recycled at this time. Then first determine the level of the deleted file in the namespace file directory, start based on the level of the deleted file in the namespace file directory, traverse upward, and query the target recycle bin management node closest to the level of the deleted file from the metadata. In this application, the level of the target recycle bin management node must be higher than or equal to the level of the deleted file. It can be understood that if the deleted file is in C in the file directory A / B / C, and the recycle bin is set with the A layer, B layer, and C layer recycle bin management nodes, then the C layer recycle bin management node is the target management node of the deleted file; if the deleted file is in C in the file directory A / B / C / D, and the recycle bin is set with the A layer, B layer, and D layer recycle bin management nodes, then the B layer recycle bin management node is the target recycle bin management node. The D layer recycle bin management node cannot recycle the deleted file.

[0032] Step S103: generating a target storage path of the deleted file according to the file path of the deleted file and the user identifier of the file deletion operation.

[0033] Specifically, the file path of the deleted file is the original storage path of the deleted file in the namespace, and the target storage path of the deleted file is the relative path of the deleted file to be stored in the recycle bin. When generating the target storage path of the deleted file, the target storage path is generated for each deletion operation corresponding to the user according to the file path of the deleted file and the user identifier of the file deletion operation, combined with the user information and the file path of the deleted file. In this way, the isolation of the recycle bin data can be achieved based on the user information.

[0034] Step S104: Recycling the deleted files to the target recycle bin management node according to the target storage path.

[0035] Specifically, after determining the target storage path of the deleted file in the recycle bin corresponding to the namespace, the deleted file is recycled to the target recycle bin management node. It can be understood that at this time, the target recycle bin management node is isolated from other recycle bin management nodes as a partial subfolder of the recycle bin, and the deleted file is recycled to the target recycle bin management node. In this embodiment, a recycle bin management node can be regarded as a recycling subsystem that can run independently in the recycle bin. In this way, on the basis of namespace isolation (system resource isolation), not only the isolation between hierarchical directories is realized in the recycle bin corresponding to the namespace, but also the isolation of user data is realized.

[0036] In this embodiment, when a file deletion operation is detected, it is determined whether there is a corresponding recycle bin in the namespace to which the deleted file belongs; when there is a corresponding recycle bin in the namespace to which the deleted file belongs, the target recycle bin management node in the recycle bin that is closest to the hierarchical distance of the deleted file is determined; the hierarchical level of the target recycle bin management node is higher than or equal to the hierarchical level of the deleted file; the target storage path of the deleted file is generated according to the file path of the deleted file and the user identifier of the file deletion operation; according to the target storage path, the deleted file is recycled to the target recycle bin management node. By making the recycle bin correspond to the namespace, the granularity of the recycle bin is refined to the namespace level to ensure the isolation of the namespace and system resources. On this basis, the recycle bin management node is set as a node on the target level of the recycle bin to achieve isolation at the file directory level. At the same time, the storage path of the deleted file in the recycle bin is generated based on the user identifier, which also achieves user isolation. The application of this embodiment improves the security of system data.

[0037] In a feasible implementation manner, the method further includes: Determining a recovery file path for the deleted file according to a file recovery operation for the deleted file in the recycle bin; Detecting whether the recovery file path exists in the namespace; If the recovery file path exists in the namespace, moving the deleted file to the namespace according to the recovery file path; When the restored file path does not exist in the namespace, adjusting the file directory of the namespace according to the restored file path; According to the recovery file path, the deleted file is moved to the adjusted namespace.

[0038] Specifically, after the deleted data is recovered in the Recycle Bin, the data in the Recycle Bin can also be restored to the namespace. It can be understood that after the target Recycle Bin management node recovers the deleted files, the Recycle Bin directory displayed on the user side is the target Recycle Bin management node level and below. After the user triggers the file recovery operation on the user side, the system first determines the recovery file path of the deleted file based on the file recovery operation on the deleted file in the Recycle Bin. The recovery file path of the deleted file is the file path in the namespace where the deleted file is to be moved. Before restoring the deleted file according to the recovery file path, check whether the recovery file path exists in the namespace. It can be understood that if the recovery file path of the deleted file is A / B / C, and the file directory of the namespace is A / B / C at this time, the recovery file path exists; if the recovery file path of the deleted file is A / B / C, and the file directory of the namespace is A / C at this time, the recovery file path does not exist, and it is necessary to create / B / C under A / of the namespace, adjust the file directory of the namespace so that the recovery file path can exist in the namespace, and then restore the deleted file to the adjusted namespace according to the recovery file path.

[0039] In this embodiment, the recovery file path of the deleted file is determined according to the file recovery operation of the deleted file in the recycle bin; it is detected whether the recovery file path exists in the namespace; if the recovery file path exists in the namespace, the deleted file is moved to the namespace according to the recovery file path; if the recovery file path does not exist in the namespace, the file directory of the namespace is adjusted according to the recovery file path; according to the recovery file path, the deleted file is moved to the adjusted namespace, thereby restoring the files in the recycle bin to the namespace, thereby improving the convenience of the user during use.

[0040] In a feasible implementation manner, when a file deletion operation is detected, determining whether there is a corresponding recycle bin in the namespace to which the deleted file belongs includes: Determine, according to the file directory to which the deleted file belongs, an identifier of the namespace to which the deleted file belongs; According to the identifier, searching the metadata of the system for a recycle bin switch flag of the namespace to which the deleted file belongs; When the recycle bin switch flag is configured to be turned on, it is determined that a corresponding recycle bin exists in the namespace to which the deleted file belongs.

[0041] Specifically, according to the file directory to which the deleted file belongs, traverse upward to the root directory, and according to the root directory, the identifier of the namespace to which the deleted file belongs can be determined. According to the identifier, the recycle bin switch flag of the namespace is searched from the metadata of the system, and the recycle bin switch flag indicates whether the recycle bin is turned on. When the recycle bin switch flag of the namespace is configured to be turned on, it is determined that there is a corresponding recycle bin in the namespace to which the deleted file belongs. If the recycle bin switch flag of the namespace is configured to be turned off, it is determined that there is no corresponding recycle bin in the namespace to which the deleted file belongs. Optional. If there is no recycle bin switch flag in the metadata of the namespace, there is no corresponding recycle bin in the namespace to which the deleted file belongs (that is, the namespace has not established a corresponding recycle bin at this time).

[0042] In this embodiment, the recycle bin switch flag of the namespace is queried from the metadata through the identifier of the namespace to which the deleted file belongs. Based on the recycle bin switch flag, it can be determined whether to recycle the files deleted by the user. This improves the flexibility of the recycle bin in recovering files.

[0043] In a feasible implementation manner, when there is a corresponding recycle bin in the namespace to which the deleted file belongs, determining the target recycle bin management node in the recycle bin that is closest to the hierarchical distance of the deleted file includes: Determine the file directory level of the deleted file in the namespace; Traversing the levels of each recycle bin management node in the recycle bin from the metadata; wherein the level of each recycle bin management node is the level of each recycle bin management node in the recycle bin; According to the file directory level and the levels of each recycle bin management node, a target recycle bin management node that is closest to the level of the deleted file is determined.

[0044] Specifically, when determining the target recycle bin management node of a deleted file, first determine the file directory level of the deleted file in the namespace; then traverse the levels of each recycle bin management node in the recycle bin from the metadata; the level of each recycle bin management node is the level of each recycle bin management node in the recycle bin corresponding to the namespace. The recycle bin is a hidden folder that is consistent with the file directory of the namespace. Therefore, compare the levels (file directory levels) of each recycle bin management node and the deleted file to determine the target recycle bin management node that is closest in terms of level distance.

[0045] In this implementation, by determining the target recycle bin management node, the deleted files are recycled nearby, which makes it easier for users to view their previously deleted files and improves the user experience.

[0046] Exemplary, combined Figure 2-Figure 4 The data recovery method of the present application is further described.

[0047] Reference Figure 2 , Figure 2 FIG. 1 is a timing diagram of establishing a recycling station in the data recycling method described in an embodiment of the present application. Figure 2 As shown in the figure: the user configures the recycle bin for the namespace, that is, under this directory, there is a hidden directory .recyclebin for the recycle bin. Guanruan builds a data structure based on the user's configuration for the namespace. The configuration for the namespace includes the recycle bin switch, retention time, whether the recycle bin directory is visible, recycle bin operation permissions, file size limit, and file type limit. After the recycle bin is turned on, the namespace sets the recycle bin management node by default. During the configuration process, the relevant metadata inode (data structure) is updated accordingly to support subsequent query operations.

[0048] When setting the Recycle Bin management node, users can use the Recycle Bin management module to set the Recycle Bin management node for the directory. After setting, the files under the directory will be deleted by the user and will enter the Recycle Bin under the directory. If the subdirectory under the directory does not have a Recycle Bin management node set, the files under the subdirectory will also enter the Recycle Bin after being deleted. When canceling the Recycle Bin management node, the background task will clear the Recycle Bin directory; during the process of clearing the Recycle Bin, it is not allowed to set the Recycle Bin management node.

[0049] Reference Figure 3 , Figure 3 FIG. 1 is a schematic diagram of the timing of recovering deleted data in a data recovery method described in an embodiment of the present application. Figure 3 As shown: Step a1: When deleting a file, determine whether the recycle bin is enabled based on the namespace in which it is located, and traverse the parent directory hierarchically to check whether a certain level of directory has the recycle bin management node enabled.

[0050] Specifically, check whether the namespace has the Recycle Bin enabled. If not, the file is deleted normally. If the file size exceeds the file size limit set by the user or is a special type of file that is not allowed to enter the Recycle Bin, it is deleted normally. If the above recycling conditions are met, find the nearest Recycle Bin directory (target Recycle Bin management node) and start moving the file into the Recycle Bin.

[0051] Step b1: When moving, check the primary group user of the deleted file and record it, check whether the recycle bin directory .recyclebin of the parent directory of the most recent recycle bin is present, if not, create the recycle bin directory .recyclebin under the directory path. For example, the primary group user is root, with permission 777.

[0052] Step c1: Get the directory path, build a relative path for the directory, and recursively create the following directories under the recycle bin directory with the primary group user of the deleted file: user / current / relative path, and grant 700 permissions. For example: the primary group user of the deleted file is user1, the full path is: tenant1 / ns1 / dir1 / dir2 / , and the relative path is dir1 / dir2. Then the path of the file in the recycle bin is: tenant1 / ns1 / .recyclebin / user1 / dir1 / dir2, and the primary group user of each level of directory of user1 / dir1 / dir2 is user1, with 700 permissions.

[0053] Step d1: Finally, when the deleted file is moved to the Recycle Bin, determine whether the same directory and file exist in the Recycle Bin. If not, move the file directly. If so, modify the file name when moving it to the Recycle Bin to: original file name#(year-month-day hour-minute-millisecond), for example: test.txt#2024151530000.

[0054] In a feasible implementation manner, generating a target storage path of the deleted file according to the file path of the deleted file and the user identifier of the file deletion operation includes: Determining the primary group user to which the deleted file belongs according to the user identifier of the file deletion operation; Determine the identifier of the primary group user as the name of the secondary directory under the root directory in the recycle bin; The file path of the deleted file is added under the secondary directory name to generate a target storage path of the deleted file.

[0055] Referring to the example of step c1 above, in this embodiment, the primary group user to which the deleted file belongs is determined according to the user identifier of the file deletion operation; the identifier of the primary group user is determined as the secondary directory name under the root directory in the recycle bin; the file path of the deleted file is added to the secondary directory name to generate the target storage path of the deleted file. In this way, the target storage path of the deleted file is generated according to the identifier of the primary group user, and the deleted data displayed to the user on the front end of the system are all the user's own deleted files, thus achieving the isolation of the deleted data corresponding to the user in the recycle bin.

[0056] Reference Figure 4 , Figure 4 FIG. 1 is a timing diagram of the recovery of deleted data in the data recovery method described in an embodiment of the present application. Figure 4 As shown, to recover deleted data from the Recycle Bin, execute: Step a2: When executing the CLI (Command Line Interface) command or the service interface to enter the recycle bin directory for file recovery, you need to determine in advance whether the destination path for file recovery exists. If it exists, perform permission verification. If the path does not exist, you need to create the path in advance. The permissions of the hierarchical directory where the path is located are controlled by the user to ensure normal recovery and access of files in the recycle bin. Step b2: The next level under each recycle bin directory is the user directory (i.e., the secondary directory under the root directory is used to distinguish users). When a file is deleted, if the namespace is configured with permissions for the root user, all files will be placed in the root user directory, and files will be searched for in this directory during recovery. If the namespace is configured with permissions for ordinary users, the system will create a user directory (the primary group user to which the deleted file belongs) under the recycle bin directory, and the file will be placed in this directory.

[0057] In a feasible implementation manner, before recycling the deleted file to the target recycle bin management node according to the target storage path, the method further includes: Detecting whether the deleted file meets a recycling condition, wherein the recycling condition includes: the size of the deleted file is lower than a preset threshold and the type of the deleted file is a preset file type; If the deleted file meets the recycling condition, detecting whether there is a file with the same name as the deleted file in the target storage path in the recycle bin; If there is no file with the same name as the deleted file under the target storage path in the recycle bin, recycling the deleted file to the target recycle bin management node according to the target storage path; If there is a file with the same name as the deleted file in the target storage path in the recycle bin, adding a timestamp to the file name of the deleted file; The deleted files are recycled to the target recycling bin management node.

[0058] Specifically, before the deleted file is recycled to the target recycle bin management node, it is necessary to detect whether the deleted file meets the recycling conditions. The recycling conditions include: the size of the deleted file is lower than the preset threshold and the type of the deleted file is the preset file type, that is, at this time the user has specified which files are relatively important and need to be recycled. If the deleted file does not meet the recycling conditions, it is directly deleted and not recycled. If the deleted file meets the recycling conditions, it is further detected whether there is a file with the same name as the deleted file in the target storage path in the recycle bin. If there is a file with the same name as the deleted file in the target storage path in the recycle bin (it may be a previous version of the deleted file), a timestamp is added to the file name of the deleted file to distinguish it from the file with the same name, and the deleted file after the file name is changed is recycled to the target recycle bin management node.

[0059] In this embodiment, deleted files can be flexibly identified by setting recycling conditions, and only deleted files that the user needs to recycle are recycled. At the same time, before recycling the deleted files, if there are files with the same name as the deleted files in the target storage path, the file name of the deleted files is adjusted in advance to ensure that the deleted files are successfully recycled.

[0060] In a feasible implementation, the metadata of the namespace also stores feature data of the file. Before the deleted file is recovered, the deleted file can be parsed to determine the target feature of the deleted file. According to the target feature, the target storage path of the deleted file is adjusted. In this way, the deleted files are further classified and stored according to the file features, which is conducive to users to quickly find the deleted files to be recovered.

[0061] In combination with the above embodiments, the technical solution of the present application includes: 1) Recycle Bin Configuration: The granularity of the Recycle Bin switch is refined to the namespace level. The user can open the Recycle Bin for the namespace and then configure the Recycle Bin; after opening, the user can set the Recycle Bin management node for the directory under the namespace. 2) File deletion enters the Recycle Bin: When the user deletes a file, check whether the namespace where the Recycle Bin is located is open; when the Recycle Bin is opened, the file system will check the directory according to the level, select the nearest Recycle Bin management node, and the file meets the conditions for entering the Recycle Bin and enters the Recycle Bin after deletion; if the namespace does not open the Recycle Bin, the file executes the normal deletion process. 3) Recycle Bin data recovery: The user recovers data through this function, including file data recovery, file permission recovery, and directory structure recovery. Applying the technical solution of the present application, while ensuring the isolation of system resources in multiple namespaces, the data of the Recycle Bin is also isolated. In this way, the convenience and isolation of user use are guaranteed by switching the Recycle Bin to the namespace; at the same time, the various configurations of the Recycle Bin are used to ensure the timely deletion and scalability of the Recycle Bin data.

[0062] Reference Figure 5 , Figure 5 FIG. 1 is a schematic diagram of a data recovery device according to an embodiment of the present application. Figure 5 As shown, in one embodiment of the present application, based on the same or similar technical concept as the above embodiment, a data recovery device 500 is provided, the device comprising: The first determination module 501 is used to determine whether there is a corresponding recycle bin in the namespace to which the deleted file belongs when a file deletion operation is detected; The second determination module 502 is used to determine, when there is a corresponding recycle bin in the namespace to which the deleted file belongs, a target recycle bin management node in the recycle bin that is closest to the level of the deleted file; the level of the target recycle bin management node is higher than or equal to the level of the deleted file; A generating module 503, configured to generate a target storage path of the deleted file according to the file path of the deleted file and the user identifier of the file deletion operation; The recycling module 504 is used to recycle the deleted files to the target recycling bin management node according to the target storage path.

[0063] In this embodiment, when a file deletion operation is detected, it is determined whether there is a corresponding recycle bin in the namespace to which the deleted file belongs; when there is a corresponding recycle bin in the namespace to which the deleted file belongs, the target recycle bin management node in the recycle bin that is closest to the hierarchical distance of the deleted file is determined; the hierarchical level of the target recycle bin management node is higher than or equal to the hierarchical level of the deleted file; the target storage path of the deleted file is generated according to the file path of the deleted file and the user identifier of the file deletion operation; according to the target storage path, the deleted file is recycled to the target recycle bin management node. By making the recycle bin correspond to the namespace, the granularity of the recycle bin is refined to the namespace level to ensure the isolation of the namespace and system resources. On this basis, the recycle bin management node is set as a node on the target level of the recycle bin to achieve isolation at the file directory level. At the same time, the storage path of the deleted file in the recycle bin is generated based on the user identifier, which also achieves user isolation. The application of this embodiment improves the security of system data.

[0064] In the present application, the description of the device embodiment is relatively short, and specific details can be referred to the above method embodiment, which will not be repeated here.

[0065] In one embodiment of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned data recovery method when executing the computer program.

[0066] In one embodiment of the present application, a non-volatile storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the data recovery method as described in the above embodiment is implemented.

[0067] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0068] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0069] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0070] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0071] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0072] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.

[0073] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0074] The above provides a detailed introduction to a data recovery method, device, electronic device and medium. This article uses specific examples to illustrate the principles and embodiments of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific embodiments and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A data recovery method, characterized in that: The method comprises: When a file deletion operation is detected, determining whether there is a corresponding recycle bin in the namespace to which the deleted file belongs; In the case that a corresponding recycle bin exists in the namespace to which the deleted file belongs, determining a target recycle bin management node in the recycle bin that is closest to the level of the deleted file; the level of the target recycle bin management node is higher than or equal to the level of the deleted file; Generate a target storage path for the deleted file according to the file path of the deleted file and the user identifier of the file deletion operation; According to the target storage path, the deleted files are recycled to the target recycle bin management node.

2. The method according to claim 1, characterized in that The step of determining whether there is a corresponding recycle bin in the namespace to which the deleted file belongs when a file deletion operation is detected includes: Determine, according to the file directory to which the deleted file belongs, an identifier of the namespace to which the deleted file belongs; According to the identifier, searching the metadata of the system for a recycle bin switch flag of the namespace to which the deleted file belongs; When the recycle bin switch flag is configured to be turned on, it is determined that a corresponding recycle bin exists in the namespace to which the deleted file belongs.

3. The method according to claim 1, characterized in that In the case that a corresponding recycle bin exists in the namespace to which the deleted file belongs, determining a target recycle bin management node in the recycle bin that is closest to the hierarchical distance of the deleted file comprises: Determine the file directory level of the deleted file in the namespace; Traversing the levels of each recycle bin management node in the recycle bin from the metadata; wherein the level of each recycle bin management node is the level of each recycle bin management node in the recycle bin; According to the file directory level and the levels of each recycle bin management node, a target recycle bin management node that is closest to the level of the deleted file is determined.

4. The method according to claim 1, characterized in that: The step of generating a target storage path of the deleted file according to the file path of the deleted file and the user identifier of the file deletion operation comprises: Determining the primary group user to which the deleted file belongs according to the user identifier of the file deletion operation; Determine the identifier of the primary group user as the name of the secondary directory under the root directory in the recycle bin; The file path of the deleted file is added under the secondary directory name to generate a target storage path of the deleted file.

5. The method according to claim 1, characterized in that Before recycling the deleted file to the target recycle bin management node according to the target storage path, the method further includes: Detecting whether the deleted file meets a recycling condition, wherein the recycling condition includes: the size of the deleted file is lower than a preset threshold and the type of the deleted file is a preset file type; If the deleted file meets the recycling condition, detecting whether there is a file with the same name as the deleted file in the target storage path in the recycle bin; If there is no file with the same name as the deleted file under the target storage path in the recycle bin, recycling the deleted file to the target recycle bin management node according to the target storage path; If there is a file with the same name as the deleted file in the target storage path in the recycle bin, adding a timestamp to the file name of the deleted file; The deleted files are recycled to the target recycling bin management node.

6. The method according to claim 1, characterized in that In the case where a file deletion operation is detected, before determining whether there is a corresponding recycle bin in the namespace to which the deleted file belongs, the method further includes: Creating a hidden folder under the root target of the namespace; the hidden folder is a recycle bin corresponding to the namespace; According to the current file directory of the namespace, configure the file directory of the hidden folder; One or more recycle bin management nodes are configured according to the file directory of the hidden folder.

7. The method according to claim 1, characterized in that The method further comprises: Determining a recovery file path for the deleted file according to a file recovery operation for the deleted file in the recycle bin; Detecting whether the recovery file path exists in the namespace; If the recovery file path exists in the namespace, moving the deleted file to the namespace according to the recovery file path; When the restored file path does not exist in the namespace, adjusting the file directory of the namespace according to the restored file path; According to the recovery file path, the deleted file is moved to the adjusted namespace.

8. A data recovery device, characterized in that: The device comprises: A first determination module is used to determine whether there is a corresponding recycle bin in the namespace to which the deleted file belongs when a file deletion operation is detected; A second determination module is used to determine, when there is a corresponding recycle bin in the namespace to which the deleted file belongs, a target recycle bin management node in the recycle bin that is closest to the level of the deleted file; the level of the target recycle bin management node is higher than or equal to the level of the deleted file; A generating module, used for generating a target storage path of the deleted file according to the file path of the deleted file and the user identifier of the file deletion operation; The recycling module is used to recycle the deleted files to the target recycling bin management node according to the target storage path.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the data recovery method as described in any one of claims 1-7 is implemented.

10. A non-volatile storage medium, characterized in that: A computer program is stored thereon, and when the program is executed by a processor, the data recovery method as described in any one of claims 1 to 7 is implemented.