CN108038028B - File backup method and device and file restoration method and device - Google Patents

File backup method and device and file restoration method and device Download PDF

Info

Publication number
CN108038028B
CN108038028B CN201711337162.4A CN201711337162A CN108038028B CN 108038028 B CN108038028 B CN 108038028B CN 201711337162 A CN201711337162 A CN 201711337162A CN 108038028 B CN108038028 B CN 108038028B
Authority
CN
China
Prior art keywords
document
backup
main
value
main document
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201711337162.4A
Other languages
Chinese (zh)
Other versions
CN108038028A (en
Inventor
林皓
陈海龙
毕永东
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beixinyuan System Integration Co Ltd
Original Assignee
Beixinyuan System Integration Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beixinyuan System Integration Co Ltd filed Critical Beixinyuan System Integration Co Ltd
Priority to CN201711337162.4A priority Critical patent/CN108038028B/en
Publication of CN108038028A publication Critical patent/CN108038028A/en
Application granted granted Critical
Publication of CN108038028B publication Critical patent/CN108038028B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The invention provides a file backup method and device and a file restoration method and device, and relates to the technical field of file systems, wherein the file backup method comprises the following steps: firstly, judging whether a main document is a main document needing to be backed up, if so, searching whether a backup document corresponding to the main document exists in a database, if not, creating the backup document, copying the content in the main document into the backup document, and writing the path of the backup document into the database, so that when the backup document exists, editing the main document, synchronously editing the backup document through hook, then closing the main document and the backup document, calculating the backup md5 value of the backup document, and storing the backup md5 value in the database.

Description

File backup method and device and file restoration method and device
Technical Field
The present invention relates to the field of file system technologies, and in particular, to a file backup method and apparatus, and a file restore method and apparatus.
Background
With the popularization of computer applications, various original paper-based main documents are beginning to be converted into electronic main documents. Therefore, when the electronic main document is used, people can directly open the electronic main document stored before for use and re-edit, and after the use is finished, the electronic main document is saved. In order to avoid the situation that the electronic main document is lost due to misoperation and the like, the main document is usually backed up.
In the existing processing process, the main document backup adopts an active backup mode, that is, the backup operation is manually performed each time the backup is needed, so that one backup document is regenerated after each backup operation, and a plurality of backup documents generated by a plurality of backup operations have many repeated contents and occupy a large amount of storage space. Moreover, the backup operation is performed after the main document is modified every time, otherwise, when the main document is lost or damaged, a part of data may be lost after the backup document restores the main document.
In addition, under the large background of the continuous flooding of Lesog viruses, some backup documents (such as txt, doc, pdf and the like) with obvious suffixes can be encrypted at any time, and the function of recovering the main document is lost in serious cases.
In summary, no effective solution exists for the problem of complicated operation in the file backup and recovery process.
Disclosure of Invention
In view of this, embodiments of the present invention provide a file backup method and apparatus, and a file restoration method and apparatus, in which a backup document is set, and a main document is associated with a corresponding backup document through a hook technology, so that convenient backup and restoration of the main document are achieved.
In a first aspect, an embodiment of the present invention provides a file backup method, including: judging whether the main document is a main document needing to be backed up or not;
if yes, searching whether a backup document corresponding to the main document exists in the database;
when the backup document is found to be absent, creating the backup document, copying the content in the main document into the backup document, and writing the path of the backup document into a database;
when the backup document is found to exist, editing the main document, and synchronously editing the backup document through hook;
closing the main document and the backup document, calculating the backup md5 value of the backup document, and storing the backup md5 value in the database.
With reference to the first aspect, an embodiment of the present invention provides a first possible implementation manner of the first aspect, where before determining whether the main document is a main document that needs to be backed up, the method further includes:
setting a main document to be backed up as an automatic backup document;
the md5 value for the main document path is calculated and the md5 value is written to the database.
With reference to the first possible implementation manner of the first aspect, an embodiment of the present invention provides a second possible implementation manner of the first aspect, where the determining whether the main document is a main document that needs to be backed up includes:
call kernel 32! CreateFile opens the main document;
looking up in the database whether the md5 value corresponding to the master document exists;
and when the search result is present, judging that the main document is the main document needing to be backed up.
With reference to the first possible implementation manner of the first aspect, an embodiment of the present invention provides a third possible implementation manner of the first aspect, where creating a backup document when the backup document is found to be absent includes:
when the backup document is found to be absent, creating the backup document;
the suffix is removed from the backup document and the contents of the primary document are copied into the backup document.
With reference to the third possible implementation manner of the first aspect, an embodiment of the present invention provides a fourth possible implementation manner of the first aspect, where editing the main document when the backup document is found to exist, and implementing synchronous editing on the backup document through hook includes:
when the backup document is found to exist, the attribute of the backup document is modified to be writable, and the backup document is opened;
call kernel 32! The WriteFile modifies the main document, and realizes the synchronous editing of the backup document through hook;
call kernel 32! CloseHandle closes the main and backup documents and modifies the properties of the backup document to read-only.
In a second aspect, an embodiment of the present invention provides a file restoring method, including:
call kernel 32! The CreateFile opens the main document and acquires the path of the backup document corresponding to the main document;
calculating the path of the main document to obtain the md5 value of the path;
obtaining a backup md5 value of a backup document stored in a database;
comparing whether the backup md5 value is the same as the md5 value;
and when the comparison result is different, copying the content of the backup document into the main document.
In a third aspect, an embodiment of the present invention further provides a file backup apparatus, including: the requirement judging module is used for judging whether the main document is the main document needing to be backed up or not;
the backup searching module is used for searching whether a backup document corresponding to the main document exists in the database if the main document exists;
the backup module is used for creating a backup document when the backup document is found to be absent, copying the content in the main document into the backup document, and writing the path of the backup document into the database;
the synchronous editing module is used for editing the main document when the backup document is found to exist, and synchronously editing the backup document through hook;
and the storage module is used for closing the main document and the backup document, calculating a backup md5 value of the backup document, and storing the backup md5 value in the database.
In a fourth aspect, an embodiment of the present invention further provides a file restoring apparatus, including:
a main document opening module for calling kernel 32! The CreateFile opens the main document and acquires the path of the backup document corresponding to the main document;
the path acquisition module is used for calculating the path of the main document to obtain the md5 value of the path;
the md5 value acquisition module is used for acquiring backup md5 values of backup documents stored in the database;
the md5 value judging module is used for comparing whether the backup md5 value is the same as the md5 value;
and the restoring module is used for copying the content of the backup document into the main document when the comparison results are different.
In a fifth aspect, an embodiment of the present invention further provides a terminal, including a memory and a processor, where the memory is used to store a program that supports the processor to execute the file backup method provided in the foregoing aspect, and the processor is configured to execute the program stored in the memory.
In a sixth aspect, the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps of any one of the methods described above.
The embodiment of the invention provides a file backup method and device and a file restoration method and device, wherein the file backup method comprises the following steps: firstly, judging whether a main document is a main document needing to be backed up, if so, namely the current main document is the main document needing to be backed up, searching whether a backup document corresponding to the main document exists in a database, and when the backup document is found to exist, finding the existing backup document; when the backup document is found to be absent, the backup document is created, the content in the main document is copied into the backup document, and the path of the backup document is written into the database, so that when the backup document is found to be present, the main document is edited, synchronous editing of the backup document is realized through hook, then the main document and the backup document are closed, the backup md5 value of the backup document is calculated, and the backup md5 value is stored in the database, so that the main document and the corresponding backup document are saved, the path of the backup document is saved through storage of the backup md5 value in the database, and through the processing procedures, the backup operation of the main document after being edited every time is avoided, and the backup operation of the main document is conveniently and quickly realized.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a flow chart illustrating a file backup method provided by an embodiment of the invention;
FIG. 2 is a flowchart illustrating a file restoring method according to an embodiment of the present invention;
fig. 3 is a diagram illustrating a structural connection of a file backup apparatus according to an embodiment of the present invention;
fig. 4 shows a structural connection diagram of the file restoring apparatus according to the embodiment of the present invention.
Icon: 1-a demand determination module; 2-backup searching module; 3-a backup module; 4-synchronous editing module; 5-a storage module; 6-main document opening module; 7-a path acquisition module; an 8-md5 value acquisition module; 9-md5 value judgment module; 10-reduction module.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
At present, in the process of storing a main document, an active backup mode is often adopted to implement backup operation on the main document, but as a result, a backup document is regenerated after each backup operation, and a plurality of backup documents generated by a plurality of backup operations have many repeated contents and occupy a large amount of storage space. Moreover, the backup operation is performed after the main document is modified every time, otherwise, when the main document is lost or damaged, a part of data may be lost after the backup document restores the main document, and the repeated editing and saving operations become very complicated.
Based on this, embodiments of the present invention provide a file backup method and apparatus, and a file restoration method and apparatus, which are described below by way of embodiments.
Example 1
Referring to fig. 1, the file backup method provided in this embodiment specifically includes the following steps:
step S101: and judging whether the main document is the main document needing to be backed up.
Step S102: if so, the database is searched for the existence of a backup document corresponding to the primary document.
Step S103: and when the backup document is found to be absent, creating the backup document, copying the content in the main document into the backup document, and writing the path of the backup document into the database.
Step S104: and when the backup document is found to exist, editing the main document, and synchronously editing the backup document through hook.
Step S105: closing the main document and the backup document, calculating the backup md5 value of the backup document, and storing the backup md5 value in the database.
As will be explained in detail below, before determining whether the main document is a main document that needs to be backed up, the method further includes:
(1) the main document to be backed up is set as an automatic backup document, and it should be noted here that the purpose of setting the main document as the automatic backup document is that when a user modifies the main document, the backup document is modified at the same time, and when the main document is closed, the backup document is closed at the same time. That is to say, the main document and the backup document are synchronized in real time and are imperceptible to the user, the backup is not required to be actively triggered, and the possibility of forgetting the backup is avoided. And the system is considered to be synchronous in real time, and the extra backup time required by active backup is avoided.
(2) The md5 value for the main document path is calculated and the md5 value is written to the database. It should be noted that md5 is an abbreviation of Message-Digest Algorithm 5, and the chinese name information-Digest Algorithm 5 is used to ensure that information transmission is complete and consistent. md5 mainly realizes the operation of data (such as Chinese characters) into another fixed length value, and the md5 algorithm has the following characteristics: 1. the compressibility is strong: the calculated md5 value length is fixed for data of any length, and the md5 algorithm can process a plurality of data together when a plurality of data need to be compared. 2. Easy to calculate: the process of calculating the md5 value from the raw data is simple to calculate. 3. The modification resistance is good: any change to the original data, even if only 1 byte is modified, the obtained md5 values are greatly different, so that the difference is more obvious. In this embodiment, the md5 value of the calculated main document path is written into the database to mark the current document as a document that needs to be automatically backed up.
Judging whether the main document is the main document needing backup or not, comprising the following steps:
(1) call kernel 32! CreateFile opens the main document, and first, it should be explained that kernel32.dll is a 32-bit dynamic link library file in Windows, and belongs to a kernel-level file. It controls the memory management, data input and output operation and interrupt processing of the system, when Windows starts, kernel32.dll resides in the specific write protection area in the memory, so that other programs can not occupy the memory area. In this embodiment, the API mainly includes: kernel 32! CreateFile, kernel 32! WriteFile, kernel 32! WriteFile and kernel 32! CloseHandle, namely, the operations of opening, reading, writing and closing files are respectively realized through the above API. In which kernel32 is called! CreateFile opens the master document, i.e. determines that the currently opened document is the master document.
(2) The database is looked up for the presence of the md5 value corresponding to the primary document, i.e., it is determined whether the current primary document has been set as the primary document that needs to be backed up.
(3) If the search result is present, determining that the main document is the main document needing to be backed up, at this time, further searching whether a backup document corresponding to the main document exists, and if the corresponding backup document exists, performing step S104; if there is no corresponding backup document, step S103 is performed.
When the backup document is found to be absent, creating the backup document, wherein the creating comprises the following steps:
(1) and when the backup document is found to be not existed, creating the backup document, namely creating the backup document associated with the current main document.
(2) The backup document is removed the suffix, for example, the text in the format of txt, doc, pdf, etc. is removed the suffix, and the content of the main document is copied to the backup document, so as to realize the backup of the main document.
When the backup document is found to exist, the main document is edited, and synchronous editing of the backup document is realized through hook, wherein the synchronous editing comprises the following steps:
(1) when the backup document is found to exist, the attribute of the backup document is modified to be writable, and the backup document is opened, wherein the purpose of modifying the attribute of the backup document to be writable is to realize the editing and updating of the backup document.
(2) Call kernel 32! The WriteFile modifies the main document, and realizes synchronous editing of the backup document through hook, wherein the following hook technology is explained first, and when programming is performed under a windows system, about 2000 API functions are commonly used, and API hook is one of the API functions. The original function of a system API can be changed through the API hook, and the basic method is to change the address of the API function to point to a new self-defined function through "touching" the hook to the entry point of the API function to be modified. The APIhook needs to improve the own authority through the basic hook, and the aim of modifying the API function address is achieved by crossing the access limitation among different processes. Microsoft itself also uses this technology within the Windows operating system, such as Windows compatible mode, etc. In the application process, the computer virus usually uses the API hook technology to achieve the purpose of hiding itself. Call kernel 32! The purpose of modifying the main document by the WriteFile is to edit the main document and synchronously edit the backup document.
(3) Call kernel 32! CloseHandle closes the main and backup documents and modifies the properties of the backup document to read-only. The backup document is stored in a mode of adding no suffix name, and is set as read-only authority during storage, so that certain viruses (such as Lesojous virus) encrypted aiming at a specific suffix name can be prevented, and the viruses can be prevented from tampering the backup document (without writing authority).
In summary, the file backup method provided in this embodiment includes: firstly, judging whether a main document is a main document needing to be backed up, when judging that the current main document needs to be backed up, namely judging that a judgment result is yes, searching whether a backup document corresponding to the main document exists in a database, creating the backup document when the backup document is found to be absent, copying the content in the main document into the backup document, and writing the path of the backup document into the database, so that when the backup document is found to exist, editing the main document, realizing synchronous editing of the backup document through hook, then closing the main document and the backup document, calculating the backup md5 value of the backup document, storing the backup md5 value into the database, conveniently and quickly knowing whether the backup document is the latest version through the numerical change of the backup md5 value, and realizing synchronous editing and saving of the main document and the backup document through the processing process, the operation process of creating backup documents for many times is avoided, and the backup operation of the main document is conveniently and quickly realized.
Example 2
Referring to fig. 2, the file restoring method provided in this embodiment specifically includes the following steps:
step S201: call kernel 32! CreateFile opens the primary document and obtains the path of the backup document corresponding to the primary document. It should be noted here that, while the primary document is opened, the path of the associated backup document stored in the database is acquired.
Step S202: and calculating the path of the main document to obtain the md5 value of the path, wherein md5 is the abbreviation of Message-Digest Algorithm 5, and the Chinese name information-Digest Algorithm 5 is used for ensuring the completeness and consistency of information transmission. md5 mainly realizes the operation of data (such as Chinese characters) into another fixed length value, and the md5 algorithm has the following characteristics: 1. the compressibility is strong: the calculated md5 value length is fixed for data of any length, and the md5 algorithm can process a plurality of data together when a plurality of data need to be compared. 2. Easy to calculate: the process of calculating the md5 value from the raw data is simple to calculate. 3. The modification resistance is good: any change to the original data, even if only 1 byte is modified, the obtained md5 values are greatly different, so that the difference is more obvious. In this embodiment, the md5 value is used to determine whether the version of the master document is updated in real-time, thereby avoiding the operation of saving multiple copies of the master document.
Step S203: similar to step S202, in the step, the application of the backup md5 value can calibrate the version of the stored backup document in time and accurately, so that the backup md5 value of the backup document stored in the database can be simply and quickly compared with the main document.
Step S204: comparing the backup md5 value with the md5 value, if the master document is tampered with or subjected to a virus intrusion, the md5 value of the current version of the master document must change. Then, when the compared backup md5 value is not the same as the md5 value, it indicates that the current main document is abnormal and needs to be restored.
Step S205: and when the comparison result is different, copying the content of the backup document into the main document. That is, during the restoring process, the contents of the backup document are copied to the main document to ensure that the current main document is restored to the due version, that is, the version consistent with the backup document.
In summary, the file restoring method provided in this embodiment includes: first, a call to kernel 32! The CreateFile opens the main document, acquires the path of the backup document corresponding to the main document, calculates the path of the main document to obtain the md5 value of the path, acquires the backup md5 value of the backup document stored in the database, compares whether the backup md5 value is the same as the md5 value, and determines whether the current main document is falsified or invaded by a virus according to the difference between the backup md5 value and the md5 value, so that the content of the backup document is copied to the main document when the comparison result is different, and the restoration of the main document is conveniently and quickly realized.
Example 3
Referring to fig. 3, the present embodiment provides a file backup apparatus including: the requirement judging module 1 is used for judging whether a main document is a main document needing to be backed up, the backup searching module 2 is used for searching whether a backup document corresponding to the main document exists in a database if yes, the backup module 3 is used for creating the backup document when the backup document is found to not exist, copying the content in the main document into the backup document, writing the path of the backup document into the database, the synchronous editing module 4 is used for editing the main document when the backup document is found to exist, realizing synchronous editing on the backup document through hook, the storage module 5 is used for closing the main document and the backup document, calculating a backup md5 value of the backup document, and storing a backup md5 value in the database.
The file backup device provided by the embodiment of the invention has the same technical characteristics as the file backup method provided by the embodiment, so that the same technical problems can be solved, and the same technical effects can be achieved.
Example 5
Referring to fig. 4, the present embodiment provides a file restoring apparatus including: the main document opening module 6 is used to call kernel 32! The CreateFile opens a main document, acquires a path of a backup document corresponding to the main document, the path acquisition module 7 is configured to calculate the path of the main document to obtain an md5 value of the path, the md5 value acquisition module 8 is configured to acquire a backup md5 value of the backup document stored in the database, the md5 value judgment module 9 is configured to compare whether the backup md5 value is the same as the md5 value, and the restoration module 10 is configured to copy the content of the backup document to the main document when the comparison result is different.
The file restoration device provided by the embodiment of the invention has the same technical characteristics as the file restoration method provided by the embodiment, so that the same technical problems can be solved, and the same technical effects can be achieved.
An embodiment of the present invention further provides a terminal, including a memory and a processor, where the memory is used to store a program that supports the processor to execute the method of the above embodiment, and the processor is configured to execute the program stored in the memory.
An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps of any one of the above methods.
It should be noted that, in the present specification, the embodiments are all described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments may be referred to each other. The implementation principle and the generated technical effect of the file backup method and device and the file restoration method and device provided by the embodiment of the invention are the same as those of the method embodiment, and for the sake of brief description, the corresponding contents in the method embodiment can be referred to where the device embodiment is not mentioned.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, each functional module or unit in each embodiment of the present invention may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions or without necessarily implying any relative importance. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (9)

1. The file backup method is characterized by comprising the following steps:
judging whether the main document is a main document needing to be backed up or not;
if yes, searching whether a backup document corresponding to the main document exists in a database;
when the backup document is found to be absent, creating a backup document, copying the content in the main document into the backup document, and writing the path of the backup document into a database;
when the backup document is found to exist, editing the main document, and synchronously editing the backup document through hook;
closing the main document and the backup document, calculating a backup md5 value of the backup document, and storing the backup md5 value in the database;
when the backup document is found to exist, the main document is edited, and synchronous editing of the backup document is realized through hook, including:
when the backup document is found to exist, modifying the attribute of the backup document to be writable, and opening the backup document;
call kernel 32! The WriteFile modifies the main document, and synchronous editing of the backup document is realized through hook;
call kernel 32! And the CloseHandle closes the main document and the backup document, and modifies the attribute of the backup document into read-only.
2. The method for backing up files according to claim 1, wherein before determining whether the primary document is a primary document to be backed up, the method further comprises:
setting the main document to be backed up as an automatic backup document;
the md5 value for the main document path is calculated and the md5 value is written into a database.
3. The method for backing up files according to claim 2, wherein said determining whether the primary document is a primary document to be backed up comprises:
call kernel 32! CreateFile opens the master document;
looking up in a database whether the md5 value corresponding to the primary document exists;
and when the search result is present, judging that the main document is the main document needing to be backed up.
4. The method for file backup according to claim 2, wherein the creating a backup document when the backup document is found to be absent comprises:
when the backup document is found to be absent, creating the backup document;
and removing suffixes from the backup document, and copying the content of the main document into the backup document.
5. The file restoration method is characterized in that the file comprises a main document and a backup document, wherein the backup document is obtained by the main document based on the file backup method of any one of claims 1 to 4, and the method comprises the following steps:
call kernel 32! The CreateFile opens a main document and acquires a path of a backup document corresponding to the main document;
calculating the path of the main document to obtain the md5 value of the path;
obtaining a backup md5 value of the backup document stored in a database;
comparing whether the backup md5 value and the md5 value are the same;
and when the comparison result is different, copying the content of the backup document into the main document.
6. A file backup apparatus, comprising:
the requirement judging module is used for judging whether the main document is the main document needing to be backed up or not;
the backup searching module is used for searching whether a backup document corresponding to the main document exists in a database if the main document exists;
the backup module is used for creating a backup document when the backup document is found to be absent, copying the content in the main document into the backup document, and writing the path of the backup document into a database;
the synchronous editing module is used for editing the main document when the backup document is found to exist, and synchronously editing the backup document through hook;
a storage module, configured to close the main document and the backup document, calculate a backup md5 value of the backup document, and store the backup md5 value in the database;
wherein the synchronous editing module is further configured to:
when the backup document is found to exist, modifying the attribute of the backup document to be writable, and opening the backup document;
call kernel 32! The WriteFile modifies the main document, and synchronous editing of the backup document is realized through hook;
call kernel 32! And the CloseHandle closes the main document and the backup document, and modifies the attribute of the backup document into read-only.
7. The file restoring apparatus, wherein the file includes a main document and a backup document, wherein the backup document is obtained by the main document based on the file backup method according to any one of claims 1 to 4, and includes:
a main document opening module for calling kernel 32! The CreateFile opens a main document and acquires a path of a backup document corresponding to the main document;
the path acquisition module is used for calculating the path of the main document to obtain the md5 value of the path;
an md5 value obtaining module, configured to obtain a backup md5 value of the backup document stored in a database;
an md5 value determination module for comparing whether the backup md5 value is the same as the md5 value;
and the restoring module is used for copying the content of the backup document to the main document when the comparison result is different.
8. A terminal, comprising a memory for storing a program that enables the processor to perform the method of any of claims 1 to 5 and a processor configured to execute the program stored in the memory.
9. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method according to any one of the claims 1 to 5.
CN201711337162.4A 2017-12-13 2017-12-13 File backup method and device and file restoration method and device Active CN108038028B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711337162.4A CN108038028B (en) 2017-12-13 2017-12-13 File backup method and device and file restoration method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711337162.4A CN108038028B (en) 2017-12-13 2017-12-13 File backup method and device and file restoration method and device

Publications (2)

Publication Number Publication Date
CN108038028A CN108038028A (en) 2018-05-15
CN108038028B true CN108038028B (en) 2021-03-23

Family

ID=62102972

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711337162.4A Active CN108038028B (en) 2017-12-13 2017-12-13 File backup method and device and file restoration method and device

Country Status (1)

Country Link
CN (1) CN108038028B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109683980B (en) * 2018-11-28 2021-11-19 卡斯柯信号有限公司 Method for realizing reliable loading of U disk configuration file of trackside safety platform

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1543617A (en) * 2001-08-20 2004-11-03 ��Ϣ���Ŀƽ����޹�˾ Efficient computer file backup system and method
CN101038591A (en) * 2007-04-11 2007-09-19 华为技术有限公司 Method and system for synchronizing data base
CN101436151A (en) * 2008-12-01 2009-05-20 成都索贝数码科技股份有限公司 Data real time backup method and system based on file system
CN102110032A (en) * 2011-02-23 2011-06-29 杭州海康威视数字技术股份有限公司 Method and device for improving reliability of configuration file
CN104021132A (en) * 2013-12-08 2014-09-03 郑州正信科技发展股份有限公司 Method and system for verification of consistency of backup data of host database and backup database
CN105824723A (en) * 2016-03-18 2016-08-03 北京春鸿企业管理咨询有限公司 Method and system for backup of data of public cloud storage account
CN106598785A (en) * 2016-12-16 2017-04-26 广东美晨通讯有限公司 File system backup and restoration method and device
CN106775714A (en) * 2016-12-15 2017-05-31 武汉斗鱼网络科技有限公司 A kind of code synchronisation method and system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7516287B2 (en) * 2006-09-28 2009-04-07 Emc Israel Development Center, Ltd. Methods and apparatus for optimal journaling for continuous data replication

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1543617A (en) * 2001-08-20 2004-11-03 ��Ϣ���Ŀƽ����޹�˾ Efficient computer file backup system and method
CN101038591A (en) * 2007-04-11 2007-09-19 华为技术有限公司 Method and system for synchronizing data base
CN101436151A (en) * 2008-12-01 2009-05-20 成都索贝数码科技股份有限公司 Data real time backup method and system based on file system
CN102110032A (en) * 2011-02-23 2011-06-29 杭州海康威视数字技术股份有限公司 Method and device for improving reliability of configuration file
CN104021132A (en) * 2013-12-08 2014-09-03 郑州正信科技发展股份有限公司 Method and system for verification of consistency of backup data of host database and backup database
CN105824723A (en) * 2016-03-18 2016-08-03 北京春鸿企业管理咨询有限公司 Method and system for backup of data of public cloud storage account
CN106775714A (en) * 2016-12-15 2017-05-31 武汉斗鱼网络科技有限公司 A kind of code synchronisation method and system
CN106598785A (en) * 2016-12-16 2017-04-26 广东美晨通讯有限公司 File system backup and restoration method and device

Also Published As

Publication number Publication date
CN108038028A (en) 2018-05-15

Similar Documents

Publication Publication Date Title
CN109117425B (en) Method, system, and medium for digital asset synchronization
RU2646334C2 (en) File management using placeholders
US10148730B2 (en) Network folder synchronization
US10204016B1 (en) Incrementally backing up file system hard links based on change logs
US9864736B2 (en) Information processing apparatus, control method, and recording medium
US10120595B2 (en) Optimizing backup of whitelisted files
US20070299888A1 (en) Automatically maintaining metadata in a file backup system
WO2013044794A1 (en) Terminal backup and recovery method
KR101765211B1 (en) System and method for preventing ransomware
CN107832403B (en) Directory file management method and device, electronic terminal and readable storage medium
US20170293529A1 (en) Cataloging file system-level changes to a source storage between image backups of the source storage
CN108572888B (en) Disk snapshot creating method and disk snapshot creating device
CN110674084A (en) Method, apparatus, and computer-readable storage medium for data protection
CN108459927B (en) Data backup method and device and server
IL284409B1 (en) Modified Representation of Backup Copy on Restore
CN108038028B (en) File backup method and device and file restoration method and device
CN112230947A (en) Upgrading method and upgrading system of operating system
JP5720366B2 (en) File management system and backup method
US10055407B2 (en) Maintaining access control lists in non-identity-preserving replicated data repositories
CN111488195A (en) Virtual machine cloning method, device, equipment and computer readable storage medium
US10157106B1 (en) Method controlling backup data by using snapshot type image table
US9547651B1 (en) Establishing file relationships based on file operations
US10423494B2 (en) Trimming unused blocks from a versioned image backup of a source storage that is stored in a sparse storage
US10437687B2 (en) Filtering a directory enumeration of a directory of an image backup
KR100897479B1 (en) Method for file backup

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: Room 2298, Yingying building, 99 Tuanjie Road, yanchuangyuan, Jiangbei new district, Nanjing, Jiangsu Province, 211800

Applicant after: Beixinyuan system integration Co., Ltd

Address before: 210000 No.3, Ruiyun Road, Jiangpu street, Pukou District, Nanjing City, Jiangsu Province

Applicant before: JIANGSU SHENZHOU XINYUAN SYSTEM ENGINEERING Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant