File real-time backup, recovery method and system, electronic device, and storage medium

Through real-time monitoring and local warehouse management, the systematized management and data security problems of file backup and recovery in the existing technology are solved, real-time backup and version management of specified files are realized, the risk of data loss is reduced, and the recovery is met to meet user needs is restored. Target version, saving equipment resources.

CN117573427BActive Publication Date: 2024-11-19BEIJING VRV SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311440184.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-01
Publication Date
2024-11-19
Estimated Expiration
2043-11-01

AI Technical Summary

Technical Problem

Existing file backup and recovery methods are difficult to achieve systematic management and data security. Hot backup methods may lead to the failure to back up key information and the inability to effectively manage historical modified files.

Method used

Use real-time monitoring of the specified files of the initial version, backup the updated version to the local repository, and continue monitoring with the updated version as the new initial version, and obtain the specified files of the target version from the local repository in response to user recovery instructions, and use tools such as Inotify and Git to achieve real-time Backup and restore.

Benefits of technology

Real-time backup and version management of specified files is realized, reducing the risk of data loss, restoring the target version that meets user needs, and saving device processing time and storage space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117573427B_ABST
    Figure CN117573427B_ABST
Patent Text Reader

Abstract

The disclosed embodiment discloses a method and system for real-time backup and recovery of files, an electronic device, and a storage medium. The method includes: real-time monitoring of the initial version of a specified file; when the initial version of the specified file is updated, backing up the updated version of the specified file to a preset local repository; using the updated version as the new initial version and continuing real-time monitoring; and in response to a recovery instruction for the target version of the specified file, obtaining the target version of the specified file in the local repository and restoring it. The method can not only perform real-time and timely backup of the specified file, but also perform version management on the specified file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the fields of information technology and Internet technology, and in particular to a real-time file backup and recovery method and system, electronic equipment, and storage medium. Background Art

[0002] With the rapid development and popularization of information technology and the Internet, as well as the strong support of the country, the application of domestic Linux systems by enterprises and institutions has gradually increased. With the advent of a new era of informatization and paperless office, file backup and recovery in domestic Linux systems has become particularly important.

[0003] The file backup and recovery methods currently adopted in the market are usually divided into cold backup and hot backup. The cold backup method is to back up through hardware such as USB flash drives and hard disks. However, using this method, it is difficult to achieve systematic and institutionalized management of electronic files, and there are security issues such as data loss. The hot backup method generally backs up files on a regular basis, for example, using the Rsync (Remote synchronize) algorithm. Using this method may result in some key information not being backed up successfully, and only the latest files can be backed up synchronously, and historically modified files cannot be managed. Summary of the invention

[0004] In view of this, the embodiments of the present disclosure provide a real-time file backup and recovery method and system, electronic device, and storage medium, which can not only perform real-time and timely backup of designated files, but also perform version management on designated files.

[0005] In a first aspect, the present disclosure provides a method for real-time backup and recovery of files, which adopts the following technical solution:

[0006] Real-time monitoring of the initial version of the specified files;

[0007] When the initial version of the specified file is monitored to be updated, the updated version of the specified file is backed up to a preset local warehouse;

[0008] Use the updated version as the new initial version and continue real-time monitoring;

[0009] In response to a restore instruction for a target version of a specified file, the target version of the specified file is obtained and restored in the local repository.

[0010] Preferably, the designated file includes at least one of a file in a monitoring directory designated by a user and a file to be monitored designated by a user.

[0011] Preferably, the real-time monitoring of the designated file of the initial version includes:

[0012] Use Inotify to monitor the initial version of the specified file in real time.

[0013] Preferably, the file real-time backup and recovery method further comprises: before the real-time monitoring of the initial version of the designated file,

[0014] Back up the initial version of the specified file to the local repository.

[0015] Preferably, the local warehouse stores a plurality of backup records, and the backup records correspond to the designated files one by one;

[0016] The backup record includes each version of the specified file, the backup time and the backup quantity of the specified file;

[0017] The specified file of the initial version is stored in the corresponding backup record, and the creation time or the last saved time of the specified file of the initial version is obtained and used as the backup time of the specified file of the initial version, and the backup quantity is 1;

[0018] The updated version of the specified file is stored in the corresponding backup record, the storage time of the updated version of the specified file is obtained and used as the backup time of the updated version of the specified file, and the backup quantity is increased by one.

[0019] Preferably, establishing the preset local warehouse includes:

[0020] In response to a creation instruction to create the local repository at a specified address, a git init command is used to create and initialize the local repository at the specified address.

[0021] Preferably, in response to the restore instruction for the target version of the specified file, obtaining the target version of the specified file in the local repository and restoring it includes:

[0022] triggering the recovery instruction based on the target version selected by the user using the local device and the specified restore method;

[0023] In response to the restore instruction, the specified file of the target version is read from the local repository, and the specified file of the target version is restored based on a specified restore method;

[0024] The restoration method includes overwriting the source file and restoring to a specified directory.

[0025] In a second aspect, the present disclosure also provides a real-time file backup and recovery system, which adopts the following technical solution:

[0026] A first monitoring module, used for real-time monitoring of the specified files of the initial version;

[0027] A file backup module, for backing up the updated version of the specified file to a preset local repository after monitoring the update of the initial version of the specified file;

[0028] The second monitoring module is used to continue real-time monitoring using the updated version as a new initial version;

[0029] The file recovery module is used to obtain and recover the target version of the specified file in the local repository in response to a recovery instruction for the target version of the specified file.

[0030] In a third aspect, the present disclosure also provides an electronic device, which adopts the following technical solution:

[0031] The electronic device comprises:

[0032] at least one processor; and,

[0033] a memory communicatively connected to the at least one processor; wherein,

[0034] 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 so that the at least one processor can execute any of the above-mentioned real-time file backup and recovery methods.

[0035] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to execute any of the above-mentioned real-time file backup and recovery methods.

[0036] The real-time file backup and recovery method provided by the disclosed embodiment monitors the initial version of the specified file. When the initial version is updated, the updated version of the specified file is backed up to the local warehouse, and then the updated version is used as the new initial version to continue monitoring, thereby obtaining several versions of the specified file. When the user selects a target version from these versions and wants to restore, the target version of the specified file is obtained in the local warehouse in response to the restore instruction and restored. The method only monitors the specified files and backs up the specified files, which saves local device processing time and reduces the occupancy of local device storage space while meeting user needs. As long as the method monitors the initial version update of the specified file, it will back it up, effectively reducing the possibility of not backing up in time, thereby realizing differential backup of the specified file, and restoring the target version of the specified file based on user needs, thereby realizing version management of the specified file.

[0037] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the following preferred embodiments are specifically cited and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0039] Figure 1 A flowchart of a method for real-time file backup and recovery provided by an embodiment of the present disclosure;

[0040] Figure 2 A schematic diagram of the interface of "file backup and recovery" provided in an embodiment of the present disclosure;

[0041] Figure 3 A schematic diagram of the principle of file backup and recovery provided by an embodiment of the present disclosure;

[0042] Figure 4 A flowchart of the steps to be executed after a file movement event is triggered provided by an embodiment of the present disclosure;

[0043] Figure 5 A principle block diagram of a file real-time backup and recovery method system provided by an embodiment of the present disclosure;

[0044] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0045] The embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.

[0046] It should be clear that the following embodiments of the present disclosure are described by specific specific examples, and those skilled in the art can easily understand other advantages and effects of the present disclosure from the contents disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all of the embodiments. The present disclosure can also be implemented or applied through other different specific embodiments, 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 disclosure. It should be noted that the following embodiments and features in the embodiments can be combined with each other in the absence of conflict. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present disclosure.

[0047] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein may be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present disclosure, it should be understood by those skilled in the art that an aspect described herein may be implemented independently of any other aspect, and two or more of these aspects may be combined in various ways. For example, any number of aspects described herein may be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein may be used to implement this device and / or practice this method.

[0048] It should also be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present disclosure. The drawings only show components related to the present disclosure rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0049] Additionally, in the following description, specific details are provided to facilitate a thorough understanding of the examples. However, it will be understood by those skilled in the art that the aspects described may be practiced without these specific details.

[0050] The present invention provides a method for real-time backup and recovery of files. Figure 1 The file real-time backup and recovery method comprises the following steps:

[0051] S1: Monitor the initial version of the specified file in real time.

[0052] The specified file includes at least one of a file in a monitoring directory specified by the user and a file to be monitored specified by the user. If the user specifies a monitoring directory, all files in the monitoring directory are monitored; if the user specifies a file, the file is monitored.

[0053] Furthermore, the initial version of the specified file is backed up to a preset local repository as the first backup file, so that the initial version of the specified file can be managed later.

[0054] Establishing a preset local warehouse includes: responding to a creation instruction to create a local warehouse at a specified address, creating and initializing a local warehouse at the specified address. Figure 2 , the user clicks the "Enable" function in the "File Backup and Restore" interface, selects the specified file and address of the initial version, and triggers the creation instruction. Figure 3 In response to the creation instruction, the local repository is created and initialized at the specified address by running the git init command of GitLab, and Inotify is used to monitor the specified files of the initial version. GitLab is a code and document management tool, and its control principle is a distributed version control management system based on git; the specified address is the path selected by the user to create the local repository, and the path points to an empty directory.

[0055] Furthermore, if the user specifies a monitoring directory and there is no file in the monitoring directory, the git init command is first run to create and initialize the local repository at the specified address. When a file is created in the monitoring directory, the created file is marked as the initial version of the specified file and backed up to the local repository. There can be only one monitoring directory or two or more.

[0056] Furthermore, there may be multiple specified files, so multiple backup records are created in the local warehouse, and the backup records correspond to the specified files one by one. The backup record includes the specified files of each version, the backup time and the backup quantity of the specified files. When no backup files are generated, the backup record is empty.

[0057] When backing up the specified file of the initial version to the local repository, the creation time or the last saved time of the specified file of the initial version is recorded and used as the backup time of the specified file of the initial version. At this time, the backup quantity is 1.

[0058] S2: When the initial version of the specified file is monitored to be updated, the updated version of the specified file is backed up to the local warehouse.

[0059] The user manipulates the initial version of the specified file in the workspace of the local device, and the manipulation includes modification and saving. When the user clicks the "Save" button, the save instruction for the initial version of the specified file is triggered. In response to the save instruction, the save time is recorded, and the file modification event is received using Inotify. The specified file after saving is compared with the specified file before saving. If the comparison is consistent, it means that the initial version of the specified file has not been updated and does not need to be backed up. If the comparison is inconsistent, it means that the initial version of the specified file has been updated, and the specified file after saving is backed up to the local warehouse as the updated version of the specified file, and the save time is used as the backup time of the updated version of the specified file, and the backup quantity is increased by one.

[0060] Among them, backing up the updated version of the specified file to the local warehouse specifically includes: using the file descriptor of Inotify to obtain the user's changes to the specified file, temporarily storing the user's changes to the specified file in the index through the git add command, and writing the changes to the specified file in the index into the corresponding backup record at one time through the git commit command.

[0061] Furthermore, the file real-time backup and recovery method also includes real-time monitoring of the triggering of the file move event. If it is monitored that the user moves the specified file of the initial version to another directory, it is considered that the file move event is triggered, and then the following steps are executed (refer to Figure 4 ):

[0062] S5: Determine whether the specified file before moving belongs to the monitoring directory; if not, execute S6; if yes, execute S7.

[0063] S6: Use the moved designated file as the new initial version of the designated file and continue real-time monitoring.

[0064] The current directory of the specified file is recorded in real time, so that the specified file can be found and monitored later based on the current directory.

[0065] S7: Determine whether the directory where the specified file after the move is currently located is a monitoring directory; if not, execute S8; if so, execute S6.

[0066] S8: Stop monitoring the specified files after they are moved.

[0067] Furthermore, the real-time file backup and recovery method also includes real-time monitoring of the triggering of file deletion events. If it is monitored that the user deletes the initial version of the specified file, it is considered that the file deletion event is triggered and the specified file is no longer monitored.

[0068] When users edit specified files, a large number of redundant events may be generated. Some of these redundant events are temporary files generated, and some are redundant operations on specified files during monitoring. Inotify is used to filter out redundant events and only retain file modification events, file move events, and file deletion events.

[0069] S3: Use the updated version as the new initial version and continue real-time monitoring.

[0070] The updated version of the designated file is used as a new initial version of the designated file, and real-time monitoring is continued to be performed so as to perform multiple backups of the designated file.

[0071] S4: In response to the restore instruction for the target version of the specified file, the specified file of the target version is obtained in the local repository and restored.

[0072] The user uses the local device to select the specified file of the target version and specify the restore method, and then clicks the "OK" button to trigger the recovery instruction. In response to the recovery instruction, the specified file of the target version is read from the corresponding backup record, and the specified file of the target version is restored based on the specified restore method.

[0073] Optionally, the premise that the user uses the local device to select the specified file of the target version is: the user uses the local device to select the specified file, triggering a query instruction for each version of the specified file, and in response to the query instruction for each version of the specified file, using the git log command to retrieve the corresponding backup record, and displaying it in the form of a file list on the interface of the local device for the user to view. After viewing, the user uses the local device to select the specified file of the target version.

[0074] Among them, the restoration methods include overwriting the source files and restoring to a specified directory. If the user checks the overwrite source files in the "File Backup and Restore" interface, it means that the restoration method selected by the user is to overwrite the source files, and the specified files of the target version overwrite the specified files of the initial version. If the user does not check the overwrite source files in the "File Backup and Restore" interface, it means that the restoration method selected by the user is to restore to a specified directory, then the specified files of the target version will be downloaded and saved to the specified directory, while the specified files of the initial version will be retained, where the specified directory is obtained by the user entering it in the relevant interface of the local device. The above restoration operation can be completed through the git checkout command: pull the specified files of the target version stored in the local warehouse and restore them to the workspace.

[0075] If the specified file of the initial version belongs to the monitoring directory, and the specified directory is not a monitoring directory, the specified file of the target version will not be monitored any further; otherwise, the target version will be used as the new initial version and real-time monitoring will continue.

[0076] In the traditional method, a large number of files need to be monitored, which will take up more processing time and storage space. The present disclosure only monitors and backs up the specified files, and filters out unnecessary time while meeting user needs, reducing the use of local device storage space and reducing the consumption of system resources. In addition, the present disclosure will back up the specified file as long as the initial version update of the specified file is monitored, effectively reducing the possibility of not backing up in time, thereby realizing differential backup of the specified file, and based on user needs, allowing users to view the specified files of various versions and restore the specified files of the target version, so as to realize version management of the specified file.

[0077] Furthermore, initializing the local warehouse includes: using a git command to connect the local warehouse with a preset remote warehouse, wherein the remote warehouse can be set in a central server, and the devices where the remote warehouse and several local warehouses are located are all in the same local area network.

[0078] Each time the local warehouse generates an updated version of a specified file, the backup record is updated accordingly. After the backup record is updated, the updated content is pushed to the remote warehouse through the git push command. Other devices in the same LAN use the gitclone / fetch command to pull the updated content of the remote warehouse to their own local warehouse, realizing multiple backups, so that other devices can also read and download the specified files of each version in the local device.

[0079] When the git checkout command cannot restore the specified files of the target version, it means that the local warehouse has not been able to store the specified files of the target version in time. Use the git pull command to pull the specified files of the target version stored in the remote warehouse and restore them to the workspace.

[0080] Optionally, when the user does not need to back up the specified files, the user can use the local device to select the "Clear Warehouse" button, specify the clearing method, trigger the clearing instruction for the target warehouse, and respond to the clearing instruction for the target warehouse, clear the target warehouse based on the specified clearing method to reduce the storage pressure of the local device. The clearing method includes clearing local records and clearing local and remote records. If the user chooses to clear local records, all backup records in the local warehouse will be cleared; if the user chooses to clear local and remote records, the entire local warehouse will be deleted, and the content related to the local warehouse in the remote warehouse will be cleared.

[0081] The present invention provides a file real-time backup and recovery system. Figure 5 , the file real-time backup and recovery system includes:

[0082] A first monitoring module, used for real-time monitoring of the specified files of the initial version;

[0083] The file backup module is used to back up the updated version of the specified file to a preset local repository after monitoring the update of the initial version of the specified file;

[0084] The second monitoring module is used to continue real-time monitoring using the updated version as a new initial version;

[0085] The file recovery module is used to obtain and recover the target version of the specified file in the local repository in response to a recovery instruction for the target version of the specified file.

[0086] The various variations and specific examples of the real-time file backup and recovery method provided above are also applicable to the real-time file backup and recovery system provided by the present disclosure. Through the above detailed description of the real-time file backup and recovery method, those skilled in the art can clearly know the implementation method of the real-time file backup and recovery system. For the sake of brevity of the specification, it will not be described in detail here.

[0087] The electronic device according to an embodiment of the present disclosure includes a memory and a processor. The memory is used to store non-temporary computer-readable instructions. Specifically, the memory may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may, for example, include a random access memory (RAM) and / or a cache memory (cache), etc. The non-volatile memory may, for example, include a read-only memory (ROM), a hard disk, a flash memory, etc.

[0088] The processor may be a central processing unit (CPU) or other forms of processing units with data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device to perform desired functions. In one embodiment of the present disclosure, the processor is used to run the computer-readable instructions stored in the memory, so that the electronic device performs all or part of the steps of the real-time file backup and recovery methods of the aforementioned embodiments of the present disclosure.

[0089] Those skilled in the art should be able to understand that in order to solve the technical problem of how to obtain a good user experience, the present embodiment may also include well-known structures such as a communication bus and an interface, and these well-known structures should also be included in the protection scope of the present disclosure.

[0090] like Figure 6 The present invention provides a schematic diagram of the structure of an electronic device according to an embodiment of the present invention, which is suitable for implementing the electronic device in the embodiment of the present invention. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0091] like Figure 6 As shown, the electronic device may include a processor (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) or a program loaded from a storage device into a random access memory (RAM). In the RAM, various programs and data required for the operation of the electronic device are also stored. The processor, ROM, and RAM are connected to each other via a bus. An input / output (I / O) interface is also connected to the bus.

[0092] Typically, the following devices can be connected to the I / O interface: input devices such as sensors or visual information acquisition devices; output devices such as display screens; storage devices such as magnetic tapes and hard disks; and communication devices. The communication device can allow the electronic device to communicate with other devices (such as edge computing devices) wirelessly or by wire to exchange data. Figure 6 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0093] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processor, all or part of the steps of the real-time file backup and recovery method of the embodiment of the present disclosure are executed.

[0094] For detailed description of this embodiment, reference may be made to the corresponding descriptions in the aforementioned embodiments, which will not be repeated here.

[0095] According to the computer-readable storage medium of the embodiment of the present disclosure, non-transitory computer-readable instructions are stored thereon. When the non-transitory computer-readable instructions are executed by a processor, all or part of the steps of the real-time file backup and recovery method of the above-mentioned embodiments of the present disclosure are executed.

[0096] The above-mentioned computer-readable storage media include, but are not limited to: optical storage media (e.g., CD-ROM and DVD), magneto-optical storage media (e.g., MO), magnetic storage media (e.g., magnetic tape or mobile hard disk), media with built-in rewritable non-volatile memory (e.g., memory card) and media with built-in ROM (e.g., ROM box).

[0097] For detailed description of this embodiment, reference may be made to the corresponding descriptions in the aforementioned embodiments, which will not be repeated here.

[0098] The basic principles of the present disclosure are described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, effects, etc. mentioned in the present disclosure are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. are required by each embodiment of the present disclosure. In addition, the specific details disclosed above are only for the purpose of illustration and ease of understanding, and are not limitations. The above details do not limit the present disclosure to the necessity of adopting the above specific details to be implemented.

[0099] In the present disclosure, 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 that there is any such actual relationship or order between these entities or operations. The block diagrams of the devices, devices, equipment, and systems involved in the present disclosure are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagram. As will be appreciated by those skilled in the art, these devices, devices, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including", "comprising", "having", etc. are open words, referring to "including but not limited to", and can be used interchangeably with them. The words "or" and "and" used here refer to the words "and / or" and can be used interchangeably with them, unless the context clearly indicates otherwise. The words "such as" used here refer to the phrase "such as but not limited to", and can be used interchangeably with them.

[0100] Additionally, as used herein, "or" used in a list of items beginning with "at least one" indicates a separate list, so that, for example, a list of "at least one of A, B, or C" means A or B or C, or AB or AC or BC, or ABC (i.e., A and B and C). Furthermore, the word "exemplary" does not mean that the example described is preferred or better than other examples.

[0101] It should also be noted that in the system and method of the present disclosure, each component or each step can be decomposed and / or recombined. Such decomposition and / or recombination should be regarded as equivalent solutions of the present disclosure.

[0102] Various changes, substitutions, and modifications of the techniques described herein may be made without departing from the teachings defined by the appended claims. Furthermore, the scope of the claims of the present disclosure is not limited to the specific aspects of the processes, machines, manufactures, compositions of events, means, methods, and actions described above. Currently existing or later to be developed processes, machines, manufactures, compositions of events, means, methods, or actions that perform substantially the same functions or achieve substantially the same results as the corresponding aspects described herein may be utilized. Thus, the appended claims include such processes, machines, manufactures, compositions of events, means, methods, or actions within their scope.

[0103] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the aspects shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

[0104] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.

Claims

1. A method for real-time backup and recovery of files. It is characterized in that include: Real-time monitoring of the initial version of the specified files; When the initial version of the specified file is monitored to be updated, the updated version of the specified file is backed up to a preset local warehouse; Use the updated version as the new initial version and continue real-time monitoring; In response to a restore instruction for a target version of a specified file, obtaining and restoring the target version of the specified file in the local repository; The establishment of the preset local warehouse includes: In response to a creation instruction to create the local repository at a specified address, using a git init command to create and initialize the local repository at the specified address; When the initial version of the specified file is updated, the updated version of the specified file is backed up to a preset local repository, including: In response to the save instruction of the initial version of the specified file, Inotify is used to receive the file modification event, and the specified file after saving is compared with the specified file before saving; if the comparison is consistent, it means that the initial version of the specified file has not been updated and does not need to be backed up; if the comparison is inconsistent, it means that the initial version of the specified file has been updated, and the saved specified file is backed up to the local warehouse as the updated version of the specified file; The updated version of the specified file is backed up to the local repository, specifically including: using the file descriptor of Inotify to obtain the user's modification of the specified file, temporarily storing the user's modification of the specified file in the index through the git add command, and writing the modification of the specified file in the index to the corresponding backup record at one time through the git commit command; Use Inotify to filter out redundant events, which are temporary files generated when users edit specified files. Monitor the triggering of file move events in real time. If it is monitored that the user moves the specified file of the initial version to another directory, the file move event is considered to be triggered. Determine whether the specified file before the move belongs to the monitoring directory; if it does not belong to the monitoring directory, use the specified file after the move as the new initial version of the specified file and continue real-time monitoring; If it belongs to the monitoring directory, determine whether the directory where the specified file is currently located after being moved is a monitoring directory; If it is not a monitored directory, the specified file will no longer be monitored after it is moved; If it is a monitoring directory, the moved specified file is used as the new initial version of the specified file and continues to be monitored in real time; The step of obtaining and restoring the target version of the specified file in the local repository in response to the restore instruction for the target version of the specified file includes: triggering the recovery instruction based on the target version selected by the user using the local device and the specified restore method; In response to the restore instruction, the specified file of the target version is read from the local repository, and the specified file of the target version is restored based on a specified restore method; The restoration method includes overwriting the source file and restoring to a specified directory; If the specified file of the initial version belongs to the monitoring directory, and the specified directory is not a monitoring directory, the specified file of the target version will not be monitored any further; otherwise, the target version will be used as the new initial version and real-time monitoring will continue.

2. The method for real-time file backup and recovery according to claim 1, It is characterized in that The designated file includes at least one of a file in a monitoring directory designated by a user and a file to be monitored designated by a user.

3. The method for real-time file backup and recovery according to claim 1, It is characterized in that The real-time monitoring of the specified files of the initial version includes: Use Inotify to monitor the initial version of the specified file in real time.

4. The method for real-time file backup and recovery according to claim 2, It is characterized in that Also includes: Prior to the real-time monitoring of the initial version of the specified file, Back up the initial version of the specified file to the local repository.

5. The file real-time backup and recovery method according to claim 4, It is characterized in that The local warehouse stores a plurality of backup records, and the backup records correspond to the designated files one by one; The backup record includes each version of the specified file, the backup time and the backup quantity of the specified file; The specified file of the initial version is stored in the corresponding backup record, and the creation time or the last saved time of the specified file of the initial version is obtained and used as the backup time of the specified file of the initial version, and the backup quantity is 1; The updated version of the specified file is stored in the corresponding backup record, the storage time of the updated version of the specified file is obtained and used as the backup time of the updated version of the specified file, and the backup quantity is increased by one.

6. A real-time file backup and recovery system, It is characterized in that include: A first monitoring module, used for real-time monitoring of the specified files of the initial version; A file backup module, for backing up the updated version of the specified file to a preset local repository after monitoring the update of the initial version of the specified file; The second monitoring module is used to continue real-time monitoring using the updated version as a new initial version; A file recovery module, configured to, in response to a recovery instruction for a target version of a specified file, obtain and recover the specified file of the target version in the local repository; The establishment of the preset local warehouse includes: In response to a creation instruction to create the local repository at a specified address, using a git init command to create and initialize the local repository at the specified address; When the initial version of the specified file is updated, the updated version of the specified file is backed up to a preset local repository, including: In response to the save instruction of the initial version of the specified file, Inotify is used to receive the file modification event, and the specified file after saving is compared with the specified file before saving; if the comparison is consistent, it means that the initial version of the specified file has not been updated and does not need to be backed up; if the comparison is inconsistent, it means that the initial version of the specified file has been updated, and the saved specified file is backed up to the local warehouse as the updated version of the specified file; The updated version of the specified file is backed up to the local repository, specifically including: using the file descriptor of Inotify to obtain the user's modification of the specified file, temporarily storing the user's modification of the specified file in the index through the git add command, and writing the modification of the specified file in the index to the corresponding backup record at one time through the git commit command; Use Inotify to filter out redundant events, which are temporary files generated when users edit specified files. Monitor the triggering of file move events in real time. If it is monitored that the user moves the specified file of the initial version to another directory, the file move event is considered to be triggered. Determine whether the specified file before the move belongs to the monitoring directory; if it does not belong to the monitoring directory, use the specified file after the move as the new initial version of the specified file and continue real-time monitoring; If it belongs to the monitoring directory, determine whether the directory where the specified file is currently located after being moved is a monitoring directory; If it is not a monitored directory, the specified file will no longer be monitored after it is moved; If it is a monitoring directory, the moved specified file is used as the new initial version of the specified file and continues to be monitored in real time; The step of obtaining and restoring the target version of the specified file in the local repository in response to the restore instruction for the target version of the specified file includes: triggering the recovery instruction based on the target version selected by the user using the local device and the specified restore method; In response to the restore instruction, the specified file of the target version is read from the local repository, and the specified file of the target version is restored based on a specified restore method; The restoration method includes overwriting the source file and restoring to a specified directory; If the specified file of the initial version belongs to the monitoring directory, and the specified directory is not a monitoring directory, the specified file of the target version will not be monitored any further; otherwise, the target version will be used as the new initial version and real-time monitoring will continue.

7. An electronic device, It is characterized in that The electronic device comprises: at least one processor; and, 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 so that the at least one processor can execute the real-time file backup and recovery method described in any one of claims 1-5.

8. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the real-time file backup and recovery method described in any one of claims 1-5.