WO2021115117A1 - 文件备份方法、恢复方法、更新方法及装置 - Google Patents

文件备份方法、恢复方法、更新方法及装置 Download PDF

Info

Publication number
WO2021115117A1
WO2021115117A1 PCT/CN2020/131216 CN2020131216W WO2021115117A1 WO 2021115117 A1 WO2021115117 A1 WO 2021115117A1 CN 2020131216 W CN2020131216 W CN 2020131216W WO 2021115117 A1 WO2021115117 A1 WO 2021115117A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
check value
backup
master
master file
Prior art date
Application number
PCT/CN2020/131216
Other languages
English (en)
French (fr)
Inventor
孙永康
杨欣
吴飏
张文垂
Original Assignee
杭州海康威视数字技术股份有限公司
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 杭州海康威视数字技术股份有限公司 filed Critical 杭州海康威视数字技术股份有限公司
Publication of WO2021115117A1 publication Critical patent/WO2021115117A1/zh

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/1458Management of the backup or restore process
    • G06F11/1469Backup restoration techniques
    • 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/1474Saving, restoring, recovering or retrying in transactions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/82Solving problems relating to consistency

Definitions

  • This application relates to the field of data processing technology, and in particular to a file backup method, restoration method, update method and device.
  • the program may be abnormally terminated due to accidents, such as device power failure, system crash, etc., during the running of the program.
  • accidents such as device power failure, system crash, etc.
  • the file will be damaged. Damage, which may cause the program to not run normally after the device restarts.
  • files can be backed up to obtain backup files, so that even if the main file is damaged, the backup file can still be used to restore the main file, so as to ensure the stability and stability of the program during operation. reliability.
  • the backup process can be performed separately for a single main file, and when the main file is damaged, the recovery process is performed separately for the single main file, which will lead to complex business scenarios.
  • only part of the multiple master files are damaged, only recovering the damaged part of the files will cause some of the multiple master files to belong to the new version, and the remaining files belong to the old version, that is, the multiple master files
  • the data consistency of the data is damaged, in this case the program is likely to still not run normally.
  • the present application provides a file backup method, recovery method and device to solve the file backup method and file recovery method of performing backup and recovery of a single master file, which may easily cause the data consistency of multiple master files to be damaged , Resulting in the problem that the program cannot run normally.
  • a file recovery method including:
  • the backup file set of the file set determines that the main file in the main file set is to be rolled back, the main file in the main file set is rolled back to be the same as the main file in the backup file set.
  • the file name of the backup file is the same.
  • a file backup method including:
  • the first check value set When it is detected that the first check value set corresponding to the master file set does not exist, the first check value set is determined, and the first check value set includes the first check value set corresponding to each master file in the master file set.
  • a backup file set corresponding to the main file set is generated and a second check value set corresponding to the backup file set is determined, and the backup file set includes For backup files of each master file in the master file set, the second check value set includes a second check value corresponding to each backup file in the backup file set.
  • a file update method includes: receiving a file update instruction, and updating each master file in the master file set according to the file update instruction; After all the master files in the master file set are updated, the first check value corresponding to each updated master file in the master file set is recalculated, and the first check value is updated with the recalculated first check value Set; regenerate the backup file corresponding to each updated master file in the master file set, update the backup file set with the regenerated backup file, and recalculate the second check value corresponding to each backup file in the backup file set , Use the recalculated second check value to update the second check value set.
  • a file recovery device including:
  • the verification module is used to verify whether the master file in the master file set and the first check value in the first check value set meet the consistency requirements
  • a determining module configured to determine whether to perform data rollback on the main file in the main file set according to the second check value in the second check value set and the backup file set of the main file set;
  • the file recovery module is used to verify that the master file in the master file set and the first check value in the first check value set do not meet the consistency requirements, and according to the second check value in the second check value set.
  • the verification value and the backup file set of the master file set determine that when data rollback is performed on the master file in the master file set, the master file in the master file set is rolled back to the backup file set It is consistent with the backup file with the same file name corresponding to the main file.
  • a file backup device including:
  • the first check value determining module is configured to determine the first check value set when it is detected that the first check value set corresponding to the master file set does not exist, and the first check value set includes the master file set. The first check value corresponding to each master file in the file set;
  • the file backup module is configured to generate a backup file set corresponding to the main file set when it is detected that the backup file set corresponding to the main file set does not exist, and the backup file set includes each main file in the main file set ’S backup file;
  • a second check value determining module configured to determine a second check value set corresponding to the backup file set, where the second check value set includes a second check value corresponding to each backup file in the backup file set .
  • a file update device including: a file update module, configured to receive a file update instruction, and update each master file in the master file set according to the file update instruction; and a calculation module , Used to recalculate the first check value corresponding to each updated master file in the master file set after the file update module completes the update of all master files in the master file set, and use the renew The calculated first check value updates the first check value set; the backup module is used to regenerate the backup file corresponding to each updated master file in the master file set and update the backup file set with the regenerated backup file, The second check value corresponding to each backup file in the backup file set is recalculated, and the second check value set is updated with the recalculated second check value.
  • an electronic device including a readable storage medium and a processor
  • the readable storage medium is used to store machine executable instructions
  • the processor is configured to read the machine executable instructions on the readable storage medium, and execute the instructions to implement the steps of the file recovery method, file backup method, or file update method provided in the embodiments of the present application .
  • a computer-readable storage medium in which a computer program is stored, and when the computer program is executed by a processor, the file recovery provided in the embodiments of the present application is realized Method, file backup method, or file update method.
  • a computer program product includes computer instructions, and when the computer instructions are executed by a processor, the file recovery method and file backup method provided in the above examples of the present application can be implemented Or the steps of the file update method.
  • the master file in the master file set and the first check value in the first check value set do not meet the consistency requirement, and the second check value in the second check value set is not satisfied.
  • the check value and the backup file set of the main file set determine that when data rollback is performed on the main file in the main file set, the main file in the main file set is rolled back to the same file in the backup file set that corresponds to the main file.
  • the backup file of the name is consistent, which realizes the recovery of multiple files in the unit of collection, and can effectively ensure the data consistency of each file after the recovery.
  • Fig. 1 is a flowchart of a file backup method according to an exemplary embodiment of the present application
  • Fig. 2 is a flowchart of a file update process according to an exemplary embodiment of the application
  • Fig. 3 is a flowchart of a method for restoring a file according to an exemplary embodiment of the application
  • FIG. 4 is a flowchart for implementing step 302 provided by an exemplary embodiment of this application.
  • Fig. 5A is a flowchart of a method for restoring a file according to another exemplary embodiment of the present application.
  • FIG. 5B is a flowchart for implementing step 502 according to an exemplary embodiment of this application.
  • FIG. 6 is a block diagram of a file recovery device provided by an exemplary embodiment of this application.
  • FIG. 7 is a block diagram of a file backup device provided by an exemplary embodiment of this application.
  • Fig. 8 is a hardware structure diagram of an electronic device according to an exemplary embodiment of the application.
  • a corresponding backup file is generated for each master file in the master file set, and all backup files are grouped into the same backup file set, and in order to realize the subsequent file recovery process , Generate the first check value set of the main file set, the first check value set includes the first check value corresponding to each main file in the main file set, and correspondingly, generate the second check value set of the backup file set , The second check value set includes the second check value corresponding to each backup file in the backup file set.
  • each master file in the master file set has data consistency according to the first check value in the first check value set. If each master file in the master file set is checked If the main file does not have data consistency, you can check whether each backup file in the backup file set has data consistency based on the second check value in the second check value set. If you check out each backup file in the backup file set With data consistency, data rollback can be performed on each master file according to the backup file in the backup file set, so as to roll back the master file in the master file set to the file name corresponding to the master file in the backup file set. The backup files are consistent, so that the main file can be restored.
  • the master files in the above master file set have business relevance between each other.
  • the "business relevance" mentioned here is reflected in the dependency or calling relationship between the main files.
  • main.c contains the function void AAA()
  • Main.c contains the function extern void AAA(), so when running main.c, you can call Ac.
  • FIG. 1 For ease of understanding, firstly, the flow chart illustrated in FIG. 1 is shown to introduce the file backup method provided by this application.
  • the flow chart illustrated in FIG. 1 includes the following steps:
  • Step 101 When it is detected that the first check value set corresponding to the master file set does not exist, the first check value set is determined, and the first check value set includes the first check value corresponding to each master file in the master file set. value.
  • the main file set when the main file set is backed up, it may first be detected whether the first check value set corresponding to the main file set exists. It can be understood by those skilled in the art that in the case where the master file set is backed up for the first time, the first check value set does not exist. In this case, the first check value set can be determined first.
  • the first check value in the first check value set is the master file check value.
  • MD5 operation can be performed on each master file in the master file set to obtain the MD5 value of the master file, use the MD5 value as the master file check value, and calibrate the calculated master file
  • the verification value is included in the first verification value set as the first verification value. Assuming that the master file set includes 100 master files, the first check value set includes the first check values corresponding to the 100 master files, that is, the first check value set includes 100 first check values. Value.
  • Step 102 When it is detected that the backup file set corresponding to the main file set does not exist, generate a backup file set corresponding to the main file set and determine a second check value set corresponding to the backup file set, where the backup file set includes the main file set For backup files of each master file, the second check value set includes the second check value corresponding to each backup file in the backup file set.
  • the main file set when the main file set is backed up, it may first be detected whether the backup file set corresponding to the main file set exists.
  • the backup file set when the main file set is backed up for the first time, the backup file set does not exist.
  • the backup file of each main file in the main file set can be generated, and each main file The backup files are included in the same backup file collection.
  • the second check value set corresponding to the backup file set may also be determined.
  • the second check value in the second check value set is the backup file check value.
  • MD5 calculations can be performed on each backup file in the backup file set to obtain the MD5 value of the backup file, use the MD5 value as the backup file check value, and calibrate the calculated backup file.
  • the verification value is included in the above-mentioned second verification value set as the second verification value. Assuming that the backup file set includes 100 backup files, the second check value set may include the backup file check values corresponding to the 100 backup files, that is, the second check value set may include 100 Prepare file check value.
  • Step 201 Receive a file update instruction, and update each master file in the master file set according to the file update instruction.
  • Step 202 After completing the update of all the master files in the master file set, recalculate the first check value corresponding to each updated master file in the master file set, and update the first check value with the recalculated first check value A set of check values.
  • the first check value set corresponding to the master file set can be updated continuously.
  • the first check value corresponding to each updated master file needs to be recalculated.
  • Step 203 Regenerate the backup file corresponding to each updated master file in the master file set and use the regenerated backup file to update the backup file set, recalculate the second check value corresponding to each backup file in the backup file set, and use the new The calculated second check value updates the second check value set.
  • the backup file set of the updated main file set can be regenerated, and the second check value set corresponding to the updated backup file set can be re-determined.
  • This process is similar to the backup process of the updated master file set. Therefore, the backup process of the updated master file set can refer to the relevant description in the above step 102, which will not be repeated here.
  • the file backup method shown in FIG. 1 is executed first. For the specific steps of the file backup method, refer to the example shown in FIG. 1. After the file backup method is completed, if a file update instruction is received, the file update method is performed according to the file update method shown in FIG. 2.
  • the updated multiple master files are updated in the unit of collection.
  • Performing a re-backup can effectively ensure the data consistency between the backup files of multiple master files, and ensure the data consistency between the updated master file set and the backed up backup file set; after the master file set is updated
  • the first check value set is continued to be updated in the unit of set, and after the backup file set is backed up again, the second check value set is continued to be updated in the unit of set, which can facilitate the implementation of the subsequent file recovery process.
  • file update failure may occur during the file update process.
  • file update failure may occur.
  • an abnormal program termination occurs during the process of updating each master file in the master file set according to the file update instruction, it is determined that the file update has failed.
  • the program is abnormally terminated during the process of recalculating the first check value corresponding to each updated master file in the master file set, it is determined that the file update has failed.
  • the program is abnormally terminated during the process of regenerating the backup file corresponding to each updated main file in the main file set, it is determined that the file update has failed.
  • the following file recovery method when it is determined that the file update fails, the following file recovery method can be performed.
  • the abnormal termination of the program occurs during the process of updating each main file in the main file set according to the file update instruction, that is, the abnormal termination of the program occurs when the update of all the main files in the main file set is not completed;
  • the abnormal program termination occurs during the process of regenerating the backup file corresponding to each updated main file in the main file set, that is, the abnormal program termination occurs when the backup process of the updated main file set is not completed.
  • each backup file in the backup file set is normal (the old version) and each backup file in the backup file set meets data consistency.
  • the backup file in the backup file set and the first The first check value in a check value set meets the consistency requirement, and the backup file in the backup file set and the second check value in the second check value set also meet the consistency requirement.
  • each backup file in the backup file set is normal (the old version) and each backup file in the backup file set meets data consistency.
  • the backup file in the backup file set and the first The first check value in a check value set does not meet the consistency requirement, and the backup file in the backup file set and the second check value in the second check value set meet the consistency requirement.
  • the master file set has been updated, and the first check value set is also updated, so that the master file in the master file set is consistent with the first check value in the first check value set
  • the data consistency of each backup file in the backup file set has been damaged.
  • the backup file in the backup file set and the first check value in the first check value set do not meet the consistency requirements, and the backup file The backup file in the set and the second check value in the second check value set also do not meet the consistency requirement.
  • FIG. 3 is shown to describe the file recovery method provided by the present application.
  • the flowchart illustrated in FIG. 3 includes the following steps:
  • Step 301 Check whether the master file in the master file set and the first check value in the first check value set meet the consistency requirement.
  • the first check value in the first check value set is the master file check value.
  • the master file check value of each master file in the master file set can be calculated, for example, the MD5 value. Afterwards, for each master file, whether the calculated master file check value of the master file is consistent with the master file check value of the master file in the first check value set is compared.
  • Step 302 If it is not satisfied, determine whether to perform data rollback on the main file in the main file set according to the second check value in the second check value set and the backup file set of the main file set.
  • step 301 if step 301 is executed to obtain the result that the master file in the master file set and the first check value in the first check value set do not meet the consistency requirement, it can be considered that the master file in the master file set The data consistency of each file is damaged, that is, the main file set is damaged.
  • step 302 it may be determined whether to perform data rollback on the main file in the main file set according to the second check value in the second check value set and the backup file set of the main file set.
  • the second check value can be the main file check value or the backup file check value.
  • the second check value set may be the first check value set.
  • the backup file is checked Whether the first check value in the set and the first check value set meets the consistency requirement, if so, it is determined to perform data rollback on the master file in the master file set.
  • the second check value in the second check value set is the main file check value.
  • the check value in the backup file set can be further verified. Whether the check value of the backup file and the master file in the second check value set meets the consistency requirement, if the check value of the backup file in the backup file set and the master file in the second check value set meet the consistency requirements.
  • the above situation (1) occurs during the file update process.
  • each backup file in the backup file set meets data consistency, that is, the backup file The file collection is intact, therefore, data rollback can be performed on the master file in the master file collection.
  • the second check value in the second check value set is the backup file check value.
  • the check value in the backup file set can be further verified. Whether the check value of the backup file in the backup file and the second check value set meets the consistency requirement, if the check value of the backup file in the backup file set and the backup file in the second check value set meet the consistency requirements.
  • the above situation (1) or (2) occurs during the file update process.
  • each backup file in the set of backup files The file meets data consistency, that is, the set of backup files is intact.
  • data rollback can be performed on the main file in the main file set.
  • the backup file in the backup file set Before verifying whether the backup file in the backup file set and the backup file check value in the second check value set meet the consistency requirements, the backup file in the backup file set can be further verified with the first check value set. Whether the first check value meets the consistency requirements.
  • the backup file in the backup file set and the first check value in the first check value set do not meet the consistency requirements
  • the backup file in the backup file set is further verified with the backup file in the second check value set. Whether the file check value meets the consistency requirements.
  • step 302 can also be implemented in other ways, such as the embodiment shown in FIG. 4. As for the embodiment shown in FIG. 4, there will be corresponding descriptions below, and will not be repeated here.
  • Step 303 When it is determined to roll back the main file in the main file set, roll back the main file in the main file set to be consistent with the backup file with the same file name corresponding to the main file in the backup file set.
  • the master file in the master file set and the first check value in the first check value set do not meet the consistency requirement by verifying that the second check value in the second check value set is not satisfied.
  • the check value and the backup file set of the main file set determine that when data rollback is performed on the main file in the main file set, the main file in the main file set is rolled back to the same file in the backup file set that corresponds to the main file.
  • the backup files of the name are consistent, which realizes the recovery of multiple files in the unit of collection, and can effectively guarantee the data consistency of the restored files.
  • FIG. 4 is a flowchart for implementing step 302 provided by an exemplary embodiment of this application. As shown in Figure 4, the process includes the following steps:
  • Step 401 Check whether the check value of the backup file in the backup file set and the master file in the second check value set meets the consistency requirement, if it is satisfied, go to step 403; if not, go to step 402.
  • Step 402 Check whether the backup file in the backup file set and the backup file check value in the second check value set meet the consistency requirement, if it is satisfied, then go to step 403, if not, go to step 404.
  • Step 403 Determine to perform data rollback on the master file in the master file set.
  • Step 404 Determine not to perform data rollback on the master file in the master file set.
  • the second check value in the second check value set may include the main file check value and the backup file check value.
  • the backup file in the set and the check value of the master file in the second check value set meet the consistency requirement. According to the above description, it can be determined that the data rollback of the master file in the master file set can be determined at this time.
  • the master file check value in the first check value set can be copied in the second check value set to realize that the second check value set not only includes the backup file check
  • the verification value also includes the master file verification value.
  • check value of the backup file in the backup file set and the master file in the second check value set does not meet the consistency requirements, continue to check the backup file in the backup file set and the check value in the second check value set. Whether the check value of the backup file meets the consistency requirements.
  • FIG. 5A refers to the process illustrated in FIG. 3 above, and includes the following steps:
  • Step 501 Check whether the master file in the master file set and the first check value in the first check value set meet the consistency requirement, if it is satisfied, then go to step 505, if not, go to step 502.
  • Step 502 Determine whether to perform data rollback on the main file in the main file set according to the second check value in the second check value set and the backup file set of the main file set, if yes, go to step 503, if not, The process ends.
  • Step 503 Roll back the main file in the main file set to be consistent with the backup file with the same file name corresponding to the main file in the backup file set.
  • step 501 to step 503 please refer to the related description of step 301 to step 303 in the flow shown in FIG. 3, which will not be repeated here.
  • Step 504 Recalculate the first check value corresponding to each master file in the master file set, update the first check value in the first check value set to the recalculated first check value; end the process.
  • the first check value corresponding to each master file in the restored master file set can be recalculated, and the first check value can be updated set.
  • the data consistency between the master file set and the first check value set can be guaranteed.
  • Step 505 Check whether the backup file in the backup file set and the first check value in the first check value set meet the consistency requirement, if not, perform step 506, if yes, end the process.
  • Step 506 When it is verified that the backup file in the backup file set and the first check value in the first check value set do not meet the consistency requirement, the backup file corresponding to each main file in the main file set is regenerated and used The regenerated backup file updates the backup file collection.
  • Step 507 Recalculate the second check value corresponding to each backup file in the backup file set, and update the second check value in the second check value set to the recalculated second check value.
  • step 506 Similar to the above step 504, after the restoration of the backup file set is achieved by performing step 506, the second check value corresponding to the backup file in the restored backup file set can be recalculated, and the second check value set can be updated. Through this processing, the data consistency between the backup file set and the second check value set can be guaranteed.
  • the verification value of the master file in the master file set and the master file in the first verification value set meets the consistency requirement
  • the backup file in the backup file set is obtained by verification.
  • the backup file corresponding to each master file in the master file set is regenerated and the backup file set is updated with the regenerated backup file to ensure the main file Data consistency between the collection and the backup file collection.
  • FIG. 5B is a flowchart for implementing step 502 according to an exemplary embodiment of this application. As shown in Figure 5B, the process includes the following steps:
  • Step 5021 Check whether the backup file in the backup file set and the first check value in the first check value set meet the consistency requirement, if it is satisfied, step 5023 is executed; if not, step 5022 is executed.
  • Step 5022 verify whether the backup file in the backup file set and the backup file check value in the second check value set meet the consistency requirement, if it is satisfied, then execute step 5023; if not, then end the process.
  • Step 5023 Determine to perform data rollback on the master file in the master file set. When it is determined that data rollback is performed on the main file in the main file set, the main file in the main file set is rolled back to be consistent with the backup file with the same file name corresponding to the main file in the backup file set.
  • each master file in the master file set is updated according to the file update instruction; after the completion of all master files in the master file set After the file is updated, recalculate the first check value corresponding to each updated master file in the master file set, and use the recalculated first check value to update the first check value set;
  • the backup file corresponding to each updated master file in the master file set is used to update the backup file set with the regenerated backup file, and the second check value corresponding to each backup file in the backup file set is recalculated, using The recalculated second check value updates the second check value set.
  • file update failure may occur during the file update process.
  • file update failure may occur.
  • an abnormal program termination occurs during the process of updating each master file in the master file set according to the file update instruction, it is determined that the file update has failed.
  • the program is abnormally terminated during the process of recalculating the first check value corresponding to each updated master file in the master file set, it is determined that the file update has failed.
  • the program is abnormally terminated during the process of regenerating the backup file corresponding to each updated main file in the main file set, it is determined that the file update has failed.
  • the above-mentioned file recovery method when it is determined that the file update fails, the above-mentioned file recovery method can be executed.
  • this application also provides an embodiment of a file recovery device.
  • FIG. 6 is a block diagram of an embodiment of a file recovery apparatus provided by an exemplary embodiment of this application.
  • the device may include: a verification module 61, a determination module 62, and a file recovery module 63.
  • the verification module 61 is configured to verify whether the master file in the master file set and the first check value in the first check value set meet the consistency requirement;
  • the determining module 62 is configured to determine whether to perform data rollback on the main file in the main file set according to the second check value in the second check value set and the backup file set of the main file set;
  • the file recovery module 63 is used for verifying that the master file in the master file set and the first check value in the first check value set do not meet the consistency requirement, and based on the second check value in the second check value set.
  • the check value and the backup file set of the master file set determine that data rollback is performed on the master file in the master file set, the master file in the master file set is rolled back to the backup file set
  • the backup file with the same file name corresponding to the main file is the same.
  • the second check value is the main file check value; when the check module 61 verifies that the main file in the main file set is compared with the main file in the first check value set The first check value does not meet the consistency requirement, and the check module 61 is further configured to check whether the check value of the backup file in the backup file set and the master file in the second check value set meets Consistency requirements.
  • the determining module 62 is configured to verify that the master file in the master file set and the first check value in the first check value set do not meet the consistency requirement and the backup file in the backup file set When the file and the master file in the second check value set meet the consistency requirement, it is determined to perform data rollback on the master file in the master file set.
  • the second check value is the backup file check value; when the check module 61 verifies that the main file in the main file set is compared with the one in the first check value set When the first check value does not meet the consistency requirement, the verification module 61 is further configured to check whether the backup file in the backup file set and the backup file in the second check value set meet the consistency Claim.
  • the determining module 62 is configured to verify that the master file in the master file set and the first check value in the first check value set do not meet the consistency requirement and the backup file in the backup file set When the file and the backup file check value in the second check value set meet the consistency requirement, it is determined to perform data rollback on the main file in the main file set.
  • the verification module 61 before verifying whether the backup file in the backup file set and the backup file in the second check value set meet the consistency requirements, the verification module 61 is also used to verify Whether the backup file check value in the second check value set and the first check value in the first check value set meet the consistency requirement.
  • the determining module 62 is configured to, when it is verified that the master file in the master file set and the first check value in the first check value set do not meet the consistency requirement, the backup in the backup file set When the file and the first check value in the first check value set do not meet the consistency requirement, and the backup file in the backup file set and the backup file in the second check value set meet the consistency requirement , Determining to perform data rollback on the master file in the master file set.
  • the second check value includes a main file check value and a backup file check value; if the main file in the main file set and the first check value in the first check value set If the verification value does not meet the consistency requirement, the verification module 61 is further configured to verify whether the verification value of the backup file in the backup file set and the master file in the second verification value set meets the consistency requirement
  • the determining module 62 is configured to determine whether the backup file in the backup file set and the master file in the second check value set meet the consistency requirements, then determine the master file in the master file set File data rollback; if the check value of the backup file in the backup file set and the master file in the second check value set do not meet the consistency requirement, the check module 61 is also used to check Whether the backup file in the backup file set and the backup file check value in the second check value set meet the consistency requirement; the determining module 62 is configured to if the backup file in the backup file set is If the check value of the backup file in the second check value set meets the consistency requirement, it is determined to perform data roll
  • the device further includes (not shown in Figure 6):
  • the first calculation module is configured to recalculate the first check value corresponding to each master file in the master file set, and update the first check value in the first check value set to the recalculated first check value Value.
  • the device further includes (not shown in Figure 6):
  • the first backup module is configured to regenerate the master file set when it is verified that the backup file in the backup file set and the second check value in the second check value set do not meet the consistency requirement And update the backup file set with the backup file corresponding to each master file in the backup file.
  • the device further includes (not shown in Figure 6):
  • the second calculation module is configured to calculate a second check value corresponding to each backup file in the backup file set, and update the second check value in the second check value set to the recalculated second file calibration Value.
  • the device further includes (not shown in Figure 6):
  • the master file update module is configured to receive a file update instruction, and update each master file in the master file set according to the file update instruction;
  • the third calculation module is used to recalculate the first check value corresponding to each updated master file in the master file set after completing the update of all master files in the master file set, and use the recalculation Update the first check value set with the first check value of
  • the second backup module is configured to regenerate the backup file corresponding to each updated master file in the master file set, update the backup file set with the regenerated backup file, and recalculate each backup file in the backup file set For the corresponding second check value, the second check value set is updated with the recalculated second check value.
  • the device further includes (not shown in Figure 6):
  • the update failure determination module is configured to execute any one of the following: if an abnormal termination of the program occurs during the process of updating each master file in the master file set according to the file update instruction, it is determined that the file update has failed; If an abnormal program termination occurs during the process of the first check value corresponding to each updated master file in the master file set, it is determined that the file update has failed; or, each updated master file in the master file set is regenerated If the program terminates abnormally during the corresponding file preparation process, it is determined that the file update has failed.
  • each master file in the master file set has business relevance.
  • this application also provides an embodiment of a file backup device.
  • FIG. 7 is a block diagram of an embodiment of a file backup device provided by an exemplary embodiment of this application.
  • the device includes: a first check value determining module 71, a file backup module 72, and a second check value determining module 73.
  • the first check value determining module 71 is configured to determine the first check value set when it is detected that the first check value set corresponding to the master file set does not exist, and the first check value set includes The first check value corresponding to each master file in the master file set;
  • the file backup module 72 is configured to generate a backup file set corresponding to the main file set when it is detected that the backup file set corresponding to the main file set does not exist, and the backup file set includes each main file set in the main file set.
  • the second check value determining module 73 is configured to determine a second check value set corresponding to the backup file set, and the second check value set includes a second check corresponding to each backup file in the backup file set. value.
  • this application also provides an embodiment of a file update device.
  • the file update device includes a file update module, which is used to receive a file update instruction, and update each master file in the master file set according to the file update instruction; the calculation module is used to update the file After the module completes the update of all the master files in the master file set, it recalculates the first check value corresponding to each updated master file in the master file set, and uses the recalculated first check value to update The first check value set; the backup module is used to regenerate the backup file corresponding to each updated master file in the master file set, update the backup file set with the regenerated backup file, and recalculate the backup file set The second check value corresponding to each backup file is used to update the second check value set with the recalculated second check value.
  • the file update device further includes an update failure determining module, configured to execute any one of the following: if in the process of updating each master file in the master file set according to the file update instruction If the program terminates abnormally, it is determined that the file update has failed; in the process of recalculating the first check value corresponding to each updated master file in the master file set, the program is abnormally terminated, then it is determined that the file update has failed; or In the process of generating the backup file corresponding to each updated main file in the main file set, if the program terminates abnormally, it is determined that the file update has failed.
  • the file update device further includes a file recovery module, which is used to verify that the master file in the master file set and the first check value in the first check value set are verified When the consistency requirement is not met, and the data rollback of the master file in the master file set is determined based on the second check value in the second check value set and the backup file set of the master file set , Roll back the main file in the main file set to be consistent with the backup file with the same file name corresponding to the main file in the backup file set.
  • the file update device may further include the verification module 61 and the determination module 62 in the file recovery device shown in FIG. 6, and the function of the file recovery module included in the file update device may be the same as that of the file recovery device. The function of the file recovery module 63 is the same.
  • the present application also provides an electronic device including a processor and a readable storage medium, where the readable storage medium is used to store machine-executable instructions, and the processor is used to read the machine-executable instructions on the readable storage medium and execute The instructions are used to implement the steps of the file recovery method, file backup method, or file update method provided in the embodiments of the present application.
  • this application also provides an electronic device, including a processor 801, a communication interface 802, a memory 803, and a communication bus 804.
  • the memory 803 includes a non-transitory machine-readable storage medium.
  • the processor 801, the communication interface 802, and the memory 803 communicate with each other through the communication bus 804;
  • the memory 803 is used to store computer programs
  • the processor 801 is configured to execute a computer program stored in the memory 803, and when the processor 801 executes the computer program, the steps of the file recovery method, file backup method, or file update method provided in the embodiments of the present application are implemented.
  • the present application also provides a computer-readable storage medium on which a computer program is stored.
  • the computer program when executed by a processor, implements the steps of the file recovery method, file backup method, or file update method provided in the embodiments of the present application.
  • the computer-readable storage medium includes a non-transitory computer-readable storage medium.
  • the present application also provides a computer program product, which includes computer instructions that, when executed by a processor, can implement the steps of the file recovery method, file backup method, or file update method provided in the above examples of the application.
  • the relevant part can refer to the part of the description of the method embodiment.
  • the device embodiments described above are merely illustrative.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in One place, or it can be distributed to multiple network units.
  • Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of the present application. Those of ordinary skill in the art can understand and implement it without creative work.

Landscapes

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

Abstract

一种文件备份方法、恢复方法及装置,所述文件恢复方法包括:当校验出主文件集合中的主文件与第一校验值集合中的第一校验值不满足一致性要求,且依据第二校验值集合中的第二校验值和所述主文件集合的备文件集合确定出对所述主文件集合中的主文件进行数据回滚时,将所述主文件集合中的主文件回滚至与所述备文件集合中与该主文件对应相同文件名的备文件一致。应用该方法,可以实现以集合为单位对多个文件进行恢复,并可以有效保障恢复后的各文件的数据一致性。

Description

文件备份方法、恢复方法、更新方法及装置 技术领域
本申请涉及数据处理技术领域,尤其涉及一种文件备份方法、恢复方法、更新方法及装置。
背景技术
由于程序在运行期间可能会因意外,例如设备断电、系统崩溃等而导致程序异常终止,其中,若在程序更新配置文件(以下简称文件)的过程中发生程序异常终止,则会造成文件的损坏,进而有可能导致设备重启后程序无法正常运行。基于此,在一实施例中,可对文件进行备份,得到备文件,以实现在主文件发生损坏的情况下,依然可以利用备文件对主文件进行恢复,从而保障程序运行时的稳定性和可靠性。
在对主文件进行备份时,可以针对单一的主文件分别执行备份过程,并且,在主文件出现损坏时,也是针对单一的主文件分别执行恢复过程,这就将导致在复杂的业务场景下,当多个主文件中仅有部分文件损坏时,仅针对损坏的部分文件进行恢复,将造成该多个主文件中的部分文件属于新版本,其余文件属于旧版本,也即该多个主文件的数据一致性受到破坏,在该种情况下程序很可能仍然无法正常运行。
发明内容
有鉴于此,本申请提供一种文件备份方法、恢复方法及装置,以解决对单一的主文件执行备份和恢复的文件备份方法和文件恢复方法,容易导致多个主文件的数据一致性受到破坏,从而导致程序无法正常运行的问题。
根据本申请实施例的第一方面,提供一种文件恢复方法,所述方法包括:
当校验出主文件集合中的主文件与第一校验值集合中的第一校验值不满足一致性要求,且依据第二校验值集合中的第二校验值和所述主文件集合的备文件集合确定出对所述主文件集合中的主文件进行数据回滚时,将所述主文件集合中的主文件回滚至与所述备文件集合中与该主文件对应相同文件名的备文件一致。
根据本申请实施例的第二方面,提供一种文件备份方法,所述方法包括:
在检测到主文件集合对应的第一校验值集合不存在时,确定所述第一校验值集合,所述第一校验值集合包括所述主文件集合中各主文件对应的第一校验值;
在检测到所述主文件集合对应的备文件集合不存在时,生成所述主文件集合对应的备文件集合并确定所述备文件集合对应的第二校验值集合,所述备文件集合包括所述主文件集合中各主文件的备文件,所述第二校验值集合包括所述备文件集合中各备文件对应的第二校验值。
根据本申请实施例的第三方面,提供一种文件更新方法,所述方法包括:接收文件更新指令,依据所述文件更新指令对主文件集合中的各个主文件进行更新;在完成对所述主文件集合中所有主文件的更新后,重新计算所述主文件集合中各更新后的主文件对应的第一校验值,并利用该重新计算的第一校验值更新第一校验值集合;重新生成所述主文件集合中各更新后的主文件对应的备文件并利用重新生成的备文件更新备文件集合,重新计算所述备文件集合中各备文件对应的第二校验值,利用重新计算的第二校验值更新第二校验值集合。
根据本申请实施例的第四方面,提供一种文件恢复装置,所述装置包括:
校验模块,用于校验主文件集合中的主文件与第一校验值集合中的第一校验值是否满足一致性要求;
确定模块,用于依据第二校验值集合中的第二校验值和所述主文件集合的备文件集合确定是否对所述主文件集合中的主文件进行数据回滚;
文件恢复模块,用于当校验出主文件集合中的主文件与第一校验值集合中的第一校验值不满足一致性要求,且依据第二校验值集合中的第二校验值和所述主文件集合的备文件集合确定出对所述主文件集合中的主文件进行数据回滚时,将所述主文件集合中的主文件回滚至与所述备文件集合中与该主文件对应相同文件名的备文件一致。
根据本申请实施例的第五方面,提供一种文件备份装置,所述装置包括:
第一校验值确定模块,用于在检测到主文件集合对应的第一校验值集合不存在时,确定所述第一校验值集合,所述第一校验值集合包括所述主文件集合中各主文件对应的第一校验值;
文件备份模块,用于在检测到所述主文件集合对应的备文件集合不存在时,生成所述主文件集合对应的备文件集合,所述备文件集合包括所述主文件集合中各主文件的备文件;
第二校验值确定模块,用于确定所述备文件集合对应的第二校验值集合,所述第二校验值集合包括所述备文件集合中各备文件对应的第二校验值。
根据本申请实施例的第六方面,提供一种文件更新装置,包括:文件更新模块,用于接收文件更新指令,依据所述文件更新指令对主文件集合中的各个主文件进行更新;计算模块,用于在所述文件更新模块完成对所述主文件集合中所有主文件的更新后,重新计算所述主文件集合中各更新后的主文件对应的第一校验值,并利用该重新计算的第一校验值更新第一校验值集合;备份模块,用于重新生成所述主文件集合中各更新后的主文件对应的备文件并利用重新生成的备文件更新备文件集合,重新计算所述备文件集合中各备文件对应的第二校验值,利用重新计算的第二校验值更新第二校验值集合。
根据本申请实施例的第七方面,提供一种电子设备,所述设备包括可读存储介质和处理器;
其中,所述可读存储介质,用于存储机器可执行指令;
所述处理器,用于读取所述可读存储介质上的所述机器可执行指令,并执行所述指令以实现本 申请实施例提供的文件恢复方法、文件备份方法或文件更新方法的步骤。
根据本申请实施例的第八方面,提供一种计算机可读存储介质,所述计算机可读存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现本申请实施例提供的文件恢复方法、文件备份方法或文件更新方法的步骤。
根据本申请实施例的第九方面,提供一种计算机程序产品,该计算机程序产品包括计算机指令,所述计算机指令被处理器执行时,能够实现本申请上述示例提供的文件恢复方法、文件备份方法或文件更新方法的步骤。
应用本申请实施例,通过在校验出主文件集合中的主文件与第一校验值集合中的第一校验值不满足一致性要求,且依据第二校验值集合中的第二校验值和主文件集合的备文件集合确定出对主文件集合中的主文件进行数据回滚时,将主文件集合中的主文件回滚至与备文件集合中与该主文件对应相同文件名的备文件一致,实现了以集合为单位对多个文件进行恢复,并可以有效保障恢复后的各文件的数据一致性。
附图说明
图1为本申请根据一示例性实施例示出的一种文件备份方法的流程图;
图2为本申请根据一示例性实施例示出的一种文件更新过程的流程图;
图3为本申请根据一示例性实施例示出的一种文件恢复方法的流程图;
图4为本申请一示例性实施例提供的步骤302的实现流程图;
图5A为本申请根据另一示例性实施例示出的一种文件恢复方法的流程图;
图5B为本申请一示例性实施例提供的步骤502的实现流程图;
图6为本申请一示例性实施例提供的一种文件恢复装置的框图;
图7为本申请一示例性实施例提供的一种文件备份装置的框图;
图8为本申请根据一示例性实施例示出的一种电子设备的硬件结构图。
具体实施方式
首先说明,在本申请提供的文件备份方法和文件恢复方法中,将多个主文件归入同一主文件集合中,将主文件集合看作一个整体对其进行备份、更新、恢复等操作,并且,每一种操作均具有原子性,这里所说的“原子性”体现在:对主文件集合中的每一主文件均执行操作,或者是均不执行操作。
基于此,在本申请提供的文件备份方法中,针对主文件集合中的每一主文件分别生成对应的备文件,并将所有备文件归入同一备文件集合,以及为了实现后续的文件恢复流程,生成主文件集合 的第一校验值集合,该第一校验值集合包括主文件集合中各主文件对应的第一校验值,相应的,生成备文件集合的第二校验值集合,该第二校验值集合包括备文件集合中各备文件对应的第二校验值。
在本申请提供的文件恢复方法中,则可以依据第一校验值集合中的第一校验值检查主文件集合中的各主文件是否具有数据一致性,若检查出主文件集合中的各主文件不具有数据一致性,则可以依据第二校验值集合中的第二校验值检查备文件集合中的各备文件是否具有数据一致性,若检查出备文件集合中的各备文件具有数据一致性,则可以依据备文件集合中的备文件对各主文件进行数据回滚,以将主文件集合中的主文件回滚至与备文件集合中与该主文件对应相同文件名的备文件一致,从而实现主文件的恢复。
作为一个实施例,上述主文件集合中的各主文件之间具有业务关联性。这里所说的“业务关联性”体现在各主文件之间具有依赖关系或调用关系,例如,有main.c和A.c两个具有业务关联性的C文件,假设A.c中包含函数void AAA(),main.c中包含函数extern void AAA(),那么,在运行main.c时,则可以调用A.c。
为了使本申请提供的方法更加清楚,下面结合附图和实施例对本申请提供的文件备份方法和文件恢复方法分别进行描述:
为了便于理解,首先示出图1所示例的流程图介绍本申请提供的文件备份方法,图1所示例的流程图包括如下步骤:
步骤101:在检测到主文件集合对应的第一校验值集合不存在时,确定第一校验值集合,该第一校验值集合包括主文件集合中各主文件对应的第一校验值。
作为一个示例,对主文件集合进行备份时,可以首先检测该主文件集合对应的第一校验值集合是否存在。本领域技术人员可以理解的是,在首次对主文件集合进行备份的情况下,第一校验值集合并不存在,此时,则可以先确定出第一校验值集合。
作为一个示例,第一校验值集合中的第一校验值为主文件校验值。
在一个可选的实现方式下,可以对主文件集合中的每一主文件分别进行MD5运算,得到主文件的MD5值,将该MD5值作为主文件校验值,将计算出的主文件校验值作为第一校验值归入上述第一校验值集合中。假设该主文件集合中包括100个主文件,则第一校验值集合中包括这100个主文件分别对应的第一校验值,也即,第一校验值集合包括100个第一校验值。
步骤102:在检测到主文件集合对应的备文件集合不存在时,生成主文件集合对应的备文件集合并确定备文件集合对应的第二校验值集合,该备文件集合包括主文件集合中各主文件的备文件,该第二校验值集合包括备文件集合中各备文件对应的第二校验值。
作为一个示例,在对主文件集合进行备份时,可以首先检测该主文件集合对应的备文件集合是否存在。本领域技术人员可以理解的是,在首次对主文件集合进行备份的情况下,备文件集合并不存在,此时,则可以生成主文件集合中各主文件的备文件,并将各主文件的备文件归入同一备文件集合中。
生成主文件集合对应的备文件集合之后,还可以确定备文件集合对应的第二校验值集合。
作为一个示例,第二校验值集合中的第二校验值为备文件校验值。
在一个可选的实现方式下,可以对备文件集合中的每一备文件分别进行MD5运算,得到备文件的MD5值,将该MD5值作为备文件校验值,将计算出的备文件校验值作为第二校验值归入上述第二校验值集合中。假设该备文件集合中包括100个备文件,则第二校验值集合中可包括这100个备文件分别对应的备文件校验值,也即,第二校验值集合中可包括100个备文件校验值。
至此,完成图1所示流程的相关描述。
由上述实施例可见,通过以集合为单位对多个主文件进行备份,可以有效地保障主文件集合与备文件集合之间的数据一致性;通过确定主文件集合对应的第一校验值集合,并确定备文件集合对应的第二校验值集合,可以便于后续文件恢复流程的实现,至于后续是如何应用第一校验值集合和第二校验值集合实现文件恢复流程的,下文中通过实施例举例示出,这里暂不赘述。
在实际应用中,还会涉及到文件的更新操作,例如文件升级,在上述图1所示流程图的基础上,示出图2所示例的流程图,对本申请中文件的更新过程进行说明,图2所示例的流程图包括如下步骤:
步骤201:接收文件更新指令,依据文件更新指令对主文件集合中的各个主文件进行更新。
在本申请实施例中,接收到文件更新指令之后,并非仅更新主文件集合中的部分主文件,而是更新主文件集合中的所有主文件。
步骤202:在完成对主文件集合中所有主文件的更新后,重新计算主文件集合中各更新后的主文件对应的第一校验值,并利用该重新计算的第一校验值更新第一校验值集合。
在本申请实施例中,在完成对主文件集合中所有主文件的更新之后,可继续更新该主文件集合对应的第一校验值集合。
与主文件集合的更新过程类似的是,在更新第一校验值集合时,需要重新计算每一更新后的主文件对应的第一校验值。
步骤203:重新生成主文件集合中各更新后的主文件对应的备文件并利用重新生成的备文件更新备文件集合,重新计算备文件集合中各备文件对应的第二校验值,利用重新计算的第二校验值更新第二校验值集合。
由于上述主文件集合已更新,因此,在本步骤中,可以重新生成更新后的主文件集合的备文件集合,并重新确定更新后的备文件集合对应的第二校验值集合。这一过程类似于更新后的主文件集合的备份过程,因而更新后的主文件集合的备份过程可以参见上述步骤102中的相关描述,这里不再赘述。在本申请实施例中,在接收到文件更新指令之前,先执行图1所示的文件备份方法。所述文件备份方法的具体步骤可参见图1所示的示例。当文件备份方法完成后,如果接收到文件更新指令,则按照图2所示的文件更新方法进行文件的更新。
至此,完成图2所示流程图的相关描述。
由上述实施例可见,通过以集合为单位对多个主文件进行更新,可以有效地保障该多个主文件之间的数据一致性,相应地,以集合为单位对更新后的多个主文件进行重新备份,可以有效地保障多个主文件的备文件之间的数据一致性,并保障更新后的主文件集合与重新备份的备文件集合之间的数据一致性;在更新完主文件集合中各主文件之后,继续以集合为单位更新第一校验值集合,在重新备份得到备文件集合后,继续以集合为单位更新第二校验值集合,可以便于后续文件恢复流程的实现。
在本申请实施例中,在文件更新的过程中,可能会发生文件更新的失败。在一实施例中,若在依据所述文件更新指令对所述主文件集合中的各个主文件进行更新的过程中发生程序异常终止,则确定文件更新失败。在另一实施例中,在重新计算所述主文件集合中各更新后的主文件对应的第一校验值的过程中发生程序异常终止,则确定文件更新失败。在再一实施例中,在重新生成所述主文件集合中各更新后的主文件对应的备文件的过程中发生程序异常终止,则确定文件更新失败。
在本申请实施例中,当确定文件更新失败时,可执行下述的文件恢复方法。
下面在上述描述的文件备份方法、文件更新过程的基础上,对本申请提供的文件恢复方法进行说明:
首先说明,由于在实际应用中,在对文件的更新过程中可能会出现以下三种情况之一,在出现下述任一情况时,会导致文件损坏,在文件损坏的情况下,则可以执行本申请提供的文件恢复方法:
(1)在依据文件更新指令对主文件集合中的各个主文件进行更新的过程中发生程序异常终止,即在未完成对主文件集合中所有主文件的更新时即发生程序异常终止;
(2)在重新计算主文件集合中各更新后的主文件对应的第一校验值的过程中发生程序异常终止,即已完成对主文件集合中所有主文件的更新,但未完成第一校验值集合的更新时即发生程序异常终止;
(3)在重新生成主文件集合中各更新后的主文件对应的备文件的过程中发生程序异常终止,即未完成对更新后的主文件集合的备份过程时即发生程序异常终止。
当出现上述情况(1)时,由于主文件集合中的主文件还未完全更新,从而可以认为主文件集合中各主文件的数据一致性已受到破坏,主文件集合损坏。同时,由于还未更新主文件集合对应的第一校验值集合,从而,主文件集合中的主文件与第一校验值集合中的第一校验值将不满足一致性要求。
相应地,由于还未修改备文件集合,从而,备文件集合中各备文件正常(为旧版本)且备文件集合中各备文件满足数据一致性,同时,备文件集合中的备文件与第一校验值集合中的第一校验值满足一致性要求,备文件集合中的备文件与第二校验值集合中的第二校验值也满足一致性要求。
当出现上述情况(2)时,主文件集合中的主文件已完全更新,但是第一校验值集合还未完全更 新,从而主文件集合中的主文件与第一校验值集合中的第一校验值不满足一致性要求。
相应地,由于还未修改备文件集合,从而,备文件集合中各备文件正常(为旧版本)且备文件集合中各备文件满足数据一致性,同时,备文件集合中的备文件与第一校验值集合中的第一校验值不满足一致性要求,备文件集合中的备文件与第二校验值集合中的第二校验值满足一致性要求。
当出现上述情况(3)时,主文件集合已更新完毕,第一校验值集合也更新完毕,从而主文件集合中的主文件与第一校验值集合中的第一校验值满足一致性要求,而备文件集合中各备文件的数据一致性已受到破坏,同时,备文件集合中的备文件与第一校验值集合中的第一校验值不满足一致性要求,备文件集合中的备文件与第二校验值集合中的第二校验值也不满足一致性要求。
如下,示出图3所示例的流程图,对本申请提供的文件恢复方法进行说明,图3所示例的流程图包括如下步骤:
步骤301:校验主文件集合中的主文件与第一校验值集合中的第一校验值是否满足一致性要求。
作为一个示例,第一校验值集合中的第一校验值为主文件校验值。
基于此,可以计算出主文件集合中各主文件的主文件校验值,例如MD5值。之后,针对每一主文件,比较计算出的该主文件的主文件校验值与第一校验值集合中该主文件的主文件校验值是否一致。
若针对每一主文件,均得到一致的比较结果,则可以确定主文件集合中的主文件与第一校验值集合中的主文件校验值满足一致性要求;反之,若针对任意主文件,得到不一致的比较结果,则可以确定主文件集合中的主文件与第一校验值集合中的主文件校验值不满足一致性要求。
步骤302:若不满足,则依据第二校验值集合中的第二校验值和主文件集合的备文件集合确定是否对主文件集合中的主文件进行数据回滚。
在本申请实施例中,若通过执行步骤301,得到主文件集合中的主文件与第一校验值集合中的第一校验值不满足一致性要求的结果,则可以认为主文件集合中各文件的数据一致性受到破坏,即主文件集合损坏。
进一步,为了保障对主文件进行数据回滚的准确性,可以继续检查当前的备文件集合是否完好,在备文件集合完好的情况下,再对主文件集合中的主文件进行数据回滚。
在本步骤302中,可以依据第二校验值集合中的第二校验值和主文件集合的备文件集合确定是否对主文件集合中的主文件进行数据回滚。第二校验值可以为主文件校验值或备文件校验值。在一实施例中,当第二校验值为主文件校验值时,第二校验值集合可以是第一校验值集合,在这种情况下,在步骤302中,校验备文件集合与第一校验值集合中的第一校验值是否满足一致性要求,若满足,则确定对主文件集合中的主文件进行数据回滚。
作为一个示例,第二校验值集合中的第二校验值为主文件校验值。在该示例下,当校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求时,可以进一步校 验备文件集合中的备文件与第二校验值集合中的主文件校验值是否满足一致性要求,若校验出备文件集合中的备文件与第二校验值集合中的主文件校验值满足一致性要求,按照上述描述可知,在文件更新过程中发生上述情况(1),进而,由上述描述可知,当发生上述情况(1)时,备文件集合中的各备文件满足数据一致性,即备文件集合完好,因此,则可以对主文件集合中的主文件进行数据回滚。
作为另一个示例,第二校验值集合中的第二校验值为备文件校验值。在该示例下,当校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求时,可以进一步校验备文件集合中的备文件与第二校验值集合中的备文件校验值是否满足一致性要求,若校验出备文件集合中的备文件与第二校验值集合中的备文件校验值满足一致性要求,按照上述描述可知,在文件更新过程中发生上述情况(1)或(2),进而,由上述描述可知,当发生上述情况(1)或(2)时,备文件集合中的各备文件满足数据一致性,即备文件集合完好,因此,则可以对主文件集合中的主文件进行数据回滚。在校验备文件集合中的备文件与第二校验值集合中的备文件校验值是否满足一致性要求之前,可以进一步校验备文件集合中的备文件与第一校验值集合中的第一校验值是否满足一致性要求。当备文件集合中的备文件与第一校验值集合中的第一校验值不满足一致性要求时,再进一步校验备文件集合中的备文件与第二校验值集合中的备文件校验值是否满足一致性要求。
需要说明的是,以上仅仅是依据第二校验值集合中的第二校验值和主文件集合的备文件集合确定是否对主文件集合中的主文件进行数据回滚的示例性说明,在实际应用中,还可以通过其他方式实现步骤302,例如图4所示实施例,至于图4所示实施例,下文中会有相应描述,这里暂不赘述。
步骤303:在确定出对主文件集合中的主文件进行数据回滚时,将主文件集合中的主文件回滚至与备文件集合中与该主文件对应相同文件名的备文件一致。
至此,完成图3所示流程的相关描述。
由上述实施例可见,通过在校验出主文件集合中的主文件与第一校验值集合中的第一校验值不满足一致性要求,且依据第二校验值集合中的第二校验值和主文件集合的备文件集合确定出对主文件集合中的主文件进行数据回滚时,将主文件集合中的主文件回滚至与备文件集合中与该主文件对应相同文件名的备文件一致,实现了以集合为单位对多个文件进行恢复,并可以有效保障恢复后的各文件的数据一致性。
下面对图4所示实施例进行说明:
请参见图4,为本申请一示例性实施例提供的步骤302的实现流程图。如图4所示,该流程包括以下步骤:
步骤401:校验备文件集合中的备文件与第二校验值集合中的主文件校验值是否满足一致性要求,若满足,则执行步骤403;若不满足,则执行步骤402。
步骤402:校验备文件集合中的备文件与第二校验值集合中的备文件校验值是否满足一致性要求,若满足,则执行步骤403,若不满足,则执行步骤404。
步骤403:确定对主文件集合中的主文件进行数据回滚。
步骤404:确定不对主文件集合中的主文件进行数据回滚。
以下对步骤401至步骤404进行统一说明:
作为一个示例,第二校验值集合中的第二校验值可以包括主文件校验值和备文件校验值。在该示例下,作为一个可选的实现方式,可以首先校验备文件集合中的备文件与第二校验值集合中的主文件校验值是否满足一致性要求,若校验出备文件集合中的备文件与第二校验值集合中的主文件校验值满足一致性要求,按照上述描述可知,此时可以确定对主文件集合中的主文件进行数据回滚。在本申请实施例中,在文件备份过程中,可以在第二校验值集合中复制第一校验值集合中的主文件校验值,以实现第二校验值集合不仅包括备文件校验值,还包括主文件校验值。
若校验出备文件集合中的备文件与第二校验值集合中的主文件校验值不满足一致性要求,继续校验备文件集合中的备文件与第二校验值集合中的备文件校验值是否满足一致性要求。
若校验出备文件集合中的备文件与第二校验值集合中的主文件校验值满足一致性要求,按照上述描述可知,此时可以确定对主文件集合中的主文件进行数据回滚。
若校验出备文件集合中的备文件与第二校验值集合中的主文件校验值不满足一致性要求,按照上述描述可知,在文件更新过程中发生上述情况(3),进而,由上述描述可知,当发生上述情况(3)时,备文件集合中各备文件的数据一致性已受到破坏,即备文件集合发生损坏,在该种情况下,则可以不对主文件集合中的主文件进行数据回滚。
至此,完成图4所示流程的相关描述。
通过图4所示流程,最终实现了依据第二校验值集合中的第二校验值和主文件集合的备文件集合确定是否对主文件集合中的主文件进行数据回滚。
进一步,继续示出图5A所示例的流程图,该图5A所示例的流程参考上述图3所示流程,包括如下步骤:
步骤501:校验主文件集合中的主文件与第一校验值集合中的第一校验值是否满足一致性要求,若满足,则执行步骤505,若不满足,则执行步骤502。
步骤502:依据第二校验值集合中的第二校验值和主文件集合的备文件集合确定是否对主文件集合中的主文件进行数据回滚,若是,则执行步骤503,若否,则结束流程。
步骤503:将主文件集合中的主文件回滚至与备文件集合中与该主文件对应相同文件名的备文件一致。
步骤501至步骤503的描述可以参见上述图3所示流程中步骤301至步骤303的相关描述,这里不再赘述。
步骤504:重新计算主文件集合中各主文件对应的第一校验值,将第一校验值集合中第一 校验值更新为该重新计算的第一校验值;结束流程。
在本步骤中,通过执行完步骤503实现主文件集合中各主文件的恢复之后,可以重新计算恢复后的主文件集合中各主文件对应的第一校验值,并更新第一校验值集合。通过该种处理,可以保障主文件集合与第一校验值集合之间的数据一致性。
步骤505:校验备文件集合中的备文件与第一校验值集合中的第一校验值是否满足一致性要求,若否,则执行步骤506,若是,则结束流程。
步骤506:当校验出备文件集合中的备文件与第一校验值集合中的第一校验值不满足一致性要求时,重新生成主文件集合中各主文件对应的备文件并利用重新生成的备文件更新备文件集合。
在本步骤中,当校验出备文件集合中的备文件与第一校验值集合中的第一校验值不满足一致性要求时,可以确定备文件集合损坏,同时,由于通过执行步骤501校验出主文件集合中的主文件与第一校验值集合中的第一校验值满足一致性要求,即主文件集合完好,在该种情况下,则可以重新对主文件集合进行备份,得到备文件集合。
步骤507:重新计算备文件集合中各备文件对应的第二校验值,将第二校验值集合中第二校验值更新为该重新计算的第二校验值。
与上述步骤504类似,通过执行完步骤506实现备文件集合的恢复之后,可以重新计算恢复后的备文件集合中备文件对应的第二校验值,并更新第二校验值集合。通过该种处理,可以保障备文件集合与第二校验值集合之间的数据一致性。
至此,完成图5所示流程的相关描述。
由上述实施例可见,通过在校验得出主文件集合中的主文件与第一校验值集合中的主文件校验值满足一致性要求,且校验得出备文件集合中的备文件与第一校验值集合中的第一校验值不满足一致性要求时,重新生成主文件集合中各主文件对应的备文件并利用重新生成的备文件更新备文件集合,可以保障主文件集合与备文件集合之间的数据一致性。
请参见图5B,为本申请一示例性实施例提供的步骤502的实现流程图。如图5B所示,该流程包括以下步骤:
步骤5021,校验备文件集合中的备文件与第一校验值集合中的第一校验值是否满足一致性要求,若满足,则执行步骤5023;若不满足,则执行步骤5022。
步骤5022,校验备文件集合中的备文件与第二校验值集合中的备文件校验值是否满足一致性要求,若满足,则执行步骤5023;若不满足,则结束流程。
步骤5023,确定对主文件集合中的主文件进行数据回滚。在确定出对主文件集合中的主文件进行数据回滚时,将主文件集合中的主文件回滚至与备文件集合中与该主文件对应相同文件名的备文件一致。
在本申请实施例中,在文件恢复之后,如果接收到文件更新指令,依据所述文件更新指令 对所述主文件集合中的各个主文件进行更新;在完成对所述主文件集合中所有主文件的更新后,重新计算所述主文件集合中各更新后的主文件对应的第一校验值,并利用该重新计算的第一校验值更新所述第一校验值集合;重新生成所述主文件集合中各更新后的主文件对应的备文件并利用重新生成的备文件更新所述备文件集合,重新计算所述备文件集合中各备文件对应的第二校验值,利用重新计算的第二校验值更新所述第二校验值集合。
在本申请实施例中,在文件更新的过程中,可能会发生文件更新的失败。在一实施例中,若在依据所述文件更新指令对所述主文件集合中的各个主文件进行更新的过程中发生程序异常终止,则确定文件更新失败。在另一实施例中,在重新计算所述主文件集合中各更新后的主文件对应的第一校验值的过程中发生程序异常终止,则确定文件更新失败。在再一实施例中,在重新生成所述主文件集合中各更新后的主文件对应的备文件的过程中发生程序异常终止,则确定文件更新失败。
在本申请实施例中,当确定文件更新失败时,可执行上述文件恢复方法。
与前述文件恢复方法的实施例相对应,本申请还提供了文件恢复装置的实施例。
请参见图6,为本申请一示例性实施例提供的一种文件恢复装置的实施例框图。
如图6所示,该装置可以包括:校验模块61、确定模块62,以及文件恢复模块63。
其中,校验模块61,用于校验主文件集合中的主文件与第一校验值集合中的第一校验值是否满足一致性要求;
确定模块62,用于依据第二校验值集合中的第二校验值和所述主文件集合的备文件集合确定是否对所述主文件集合中的主文件进行数据回滚;
文件恢复模块63,用于当校验出主文件集合中的主文件与第一校验值集合中的第一校验值不满足一致性要求,且依据第二校验值集合中的第二校验值和所述主文件集合的备文件集合确定出对所述主文件集合中的主文件进行数据回滚时,将所述主文件集合中的主文件回滚至与所述备文件集合中与该主文件对应相同文件名的备文件一致。
在一实施例中,所述第二校验值为主文件校验值;当所述校验模块61校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求,所述校验模块61还用于:校验所述备文件集合中的备文件与所述第二校验值集合中的主文件校验值是否满足一致性要求。所述确定模块62用于当校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求且所述备文件集合中的备文件与所述第二校验值集合中的主文件校验值满足一致性要求时,确定对所述主文件集合中的主文件进行数据回滚。
在一实施例中,所述第二校验值为备文件校验值;当所述校验模块61校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求时,所述校验模块61还用于校验所述备文件集合中的备文件与第二校验值集合中的备文件校验值是否满足一致性要求。所述确定模块62用于当校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求且所述备文件集合中的备文件与第二校验值集合中的备文件校验值满足一致性要求时, 确定对所述主文件集合中的主文件进行数据回滚。
在一实施例中,在校验所述备文件集合中的备文件与第二校验值集合中的备文件校验值是否满足一致性要求之前,所述校验模块61还用于校验所述第二校验值集合中的备文件校验值与第一校验值集合中的第一校验值是否满足一致性要求。所述确定模块62用于当校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求,所述备文件集合中的备文件与第一校验值集合中的第一校验值不满足一致性要求,且所述备文件集合中的备文件与第二校验值集合中的备文件校验值满足一致性要求时,确定对所述主文件集合中的主文件进行数据回滚。
在一实施例中,所述第二校验值包括主文件校验值和备文件校验值;若所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求,则所述校验模块61还用于校验所述备文件集合中的备文件与所述第二校验值集合中的主文件校验值是否满足一致性要求;所述确定模块62用于若所述备文件集合中的备文件与所述第二校验值集合中的主文件校验值满足一致性要求,则确定对所述主文件集合中的主文件进行数据回滚;若所述备文件集合中的备文件与所述第二校验值集合中的主文件校验值不满足一致性要求,则所述校验模块61还用于校验所述备文件集合中的备文件与所述第二校验值集合中的备文件校验值是否满足一致性要求;所述确定模块62用于若所述备文件集合中的备文件与所述第二校验值集合中的备文件校验值满足一致性要求,则确定对所述主文件集合中的主文件进行数据回滚。
在一实施例中,所述装置还包括(图6中未示出):
第一计算模块,用于重新计算所述主文件集合中各主文件对应的第一校验值,将所述第一校验值集合中第一校验值更新为该重新计算的第一校验值。
在一实施例中,所述装置还包括(图6中未示出):
第一备份模块,用于当校验出所述备文件集合中的备文件与所述第二校验值集合中的第二校验值不满足一致性要求时,重新生成所述主文件集合中各主文件对应的备文件并利用重新生成的备文件更新所述备文件集合。
在一实施例中,所述装置还包括(图6中未示出):
第二计算模块,用于计算所述备文件集合中各备文件对应的第二校验值,将所述第二校验值集合中第二校验值更新为该重新计算的第二文件校验值。
在一实施例中,所述装置还包括(图6中未示出):
主文件更新模块,用于接收文件更新指令,依据所述文件更新指令对所述主文件集合中的各个主文件进行更新;
第三计算模块,用于在完成对所述主文件集合中所有主文件的更新后,重新计算所述主文件集合中各更新后的主文件对应的第一校验值,并利用该重新计算的第一校验值更新所述第一校验值集合;
第二备份模块,用于重新生成所述主文件集合中各更新后的主文件对应的备文件并利用重新生成的备文件更新所述备文件集合,重新计算所述备文件集合中各备文件对应的第二校验值,利用重新计算的第二校验值更新所述第二校验值集合。
在一实施例中,所述装置还包括(图6中未示出):
更新失败确定模块,用于执行以下任一:若在依据所述文件更新指令对所述主文件集合中的各个主文件进行更新的过程中发生程序异常终止,则确定文件更新失败;在重新计算所述主文件集合中各更新后的主文件对应的第一校验值的过程中发生程序异常终止,则确定文件更新失败;或,在重新生成所述主文件集合中各更新后的主文件对应的备文件的过程中发生程序异常终止,则确定文件更新失败。
在一实施例中,所述主文件集合中的各个主文件具有业务关联性。
与前述文件备份方法的实施例相对应,本申请还提供了文件备份装置的实施例。
请参见图7,为本申请一示例性实施例提供的一种文件备份装置的实施例框图。
如图7所示,该装置包括:第一校验值确定模块71、文件备份模块72,以及第二校验值确定模块73。
其中,第一校验值确定模块71,用于在检测到主文件集合对应的第一校验值集合不存在时,确定所述第一校验值集合,所述第一校验值集合包括所述主文件集合中各主文件对应的第一校验值;
文件备份模块72,用于在检测到所述主文件集合对应的备文件集合不存在时,生成所述主文件集合对应的备文件集合,所述备文件集合包括所述主文件集合中各主文件的备文件;
第二校验值确定模块73,用于确定所述备文件集合对应的第二校验值集合,所述第二校验值集合包括所述备文件集合中各备文件对应的第二校验值。
与前述文件更新方法的实施例相对应,本申请还提供了文件更新装置的实施例。
在本申请实施例中,文件更新装置包括文件更新模块,用于接收文件更新指令,依据所述文件更新指令对主文件集合中的各个主文件进行更新;计算模块,用于在所述文件更新模块完成对所述主文件集合中所有主文件的更新后,重新计算所述主文件集合中各更新后的主文件对应的第一校验值,并利用该重新计算的第一校验值更新第一校验值集合;备份模块,用于重新生成所述主文件集合中各更新后的主文件对应的备文件并利用重新生成的备文件更新备文件集合,重新计算所述备文件集合中各备文件对应的第二校验值,利用重新计算的第二校验值更新第二校验值集合。
在本申请实施例中,所述文件更新装置还包括更新失败确定模块,用于执行以下任一:若在依据所述文件更新指令对所述主文件集合中的各个主文件进行更新的过程中发生程序异常终止,则确定文件更新失败;在重新计算所述主文件集合中各更新后的主文件对应的第一校验值的过程中发生程序异常终止,则确定文件更新失败;或在重新生成所述主文件集合中各更新后的主文件对应的备文件的过程中发生程序异常终止,则确定文件更新失败。
在本申请实施例中,所述文件更新装置还包括文件恢复模块,用于:当校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求,且依据所述第二校验值集合中的第二校验值和所述主文件集合的备文件集合确定出对所述主文件集合中的主文件进行数据回滚时,将所述主文件集合中的主文件回滚至与所述备文件集合中与该主文件对应相同文件名的备文件一致。需要说明的是,所述文件更新装置可进一步包括图6示出的文件恢复装置中的校验模块61和确定模块62,且文件更新装置中包括的文件恢复模块的功能可以与文件恢复装置中的文件恢复模块63的功能相同。
本申请还提供一种电子设备,包括处理器和可读存储介质,其中,可读存储介质用于存储机器可执行指令,处理器用于读取可读存储介质上的机器可执行指令,并执行指令以实现本申请实施例提供的文件恢复方法、文件备份方法或文件更新方法的步骤。
请继续参见图8,本申请还提供一种电子设备,包括处理器801、通信接口802、存储器803,以及通信总线804。该存储器803包括非暂态机器可读存储介质。
其中,处理器801、通信接口802、存储器803通过通信总线804进行相互间的通信;
存储器803,用于存放计算机程序;
处理器801,用于执行存储器803上所存放的计算机程序,处理器801执行所述计算机程序时实现本申请实施例提供的文件恢复方法、文件备份方法或文件更新方法的步骤。
本申请还提供一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现本申请实施例提供的文件恢复方法、文件备份方法或文件更新方法的步骤。该计算机可读存储介质包括非暂态的计算机可读存储介质。
本申请还提供一种计算机程序产品,该计算机程序产品包括计算机指令,所述计算机指令被处理器执行时,能够实现本申请上述示例提供的文件恢复方法、文件备份方法或文件更新方法的步骤。
上述装置中各个单元的功能和作用的实现过程具体详见上述方法中对应步骤的实现过程,在此不再赘述。
对于装置实施例而言,由于其基本对应于方法实施例,所以相关之处参见方法实施例的部分说明即可。以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本申请方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。
本领域技术人员在考虑说明书及实践这里公开的发明后,将容易想到本申请的其它实施方案。本申请旨在涵盖本申请的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本申请的一般性原理并包括本申请未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本申请的真正范围和精神由下面的权利要求指出。
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。
以上所述仅为本申请的较佳实施例而已,并不用以限制本申请,凡在本申请的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本申请保护的范围之内。

Claims (28)

  1. 一种文件恢复方法,包括:
    当校验出主文件集合中的主文件与第一校验值集合中的第一校验值不满足一致性要求,且依据第二校验值集合中的第二校验值和所述主文件集合的备文件集合确定出对所述主文件集合中的主文件进行数据回滚时,将所述主文件集合中的主文件回滚至与所述备文件集合中与该主文件对应相同文件名的备文件一致。
  2. 根据权利要求1所述的方法,其特征在于,所述第二校验值为主文件校验值;
    当校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求,且依据第二校验值集合中的第二校验值和所述主文件集合的备文件集合确定出对所述主文件集合中的主文件进行数据回滚包括:
    当校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求且所述备文件集合中的备文件与所述第二校验值集合中的主文件校验值满足一致性要求时,确定对所述主文件集合中的主文件进行数据回滚。
  3. 根据权利要求1所述的方法,其特征在于,所述第二校验值为备文件校验值;
    当校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求,且依据第二校验值集合中的第二校验值和所述主文件集合的备文件集合确定出对所述主文件集合中的主文件进行数据回滚包括:
    当校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求且所述备文件集合中的备文件与第二校验值集合中的备文件校验值满足一致性要求时,确定对所述主文件集合中的主文件进行数据回滚。
  4. 根据权利要求3所述的方法,其特征在于,当校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求且所述备文件集合中的备文件与第二校验值集合中的备文件校验值满足一致性要求时,确定对所述主文件集合中的主文件进行数据回滚包括:
    当校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求,所述备文件集合中的备文件与第一校验值集合中的第一校验值不满足一致性要求,且所述备文件集合中的备文件与第二校验值集合中的备文件校验值满足一致性要求时,确定对所述主文件集合中的主文件进行数据回滚。
  5. 根据权利要求1所述的方法,其特征在于,所述第二校验值包括主文件校验值和备文件校验值;
    当校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求,且依据第二校验值集合中的第二校验值和所述主文件集合的备文件集合确定出对所述主文件集合中的主文件进行数据回滚包括:
    当校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求,校验所述备文件集合中的备文件与所述第二校验值集合中的主文件校验值是否满足一致性要求;
    若所述备文件集合中的备文件与所述第二校验值集合中的主文件校验值满足一致性要求,则确 定对所述主文件集合中的主文件进行数据回滚;
    若所述备文件集合中的备文件与所述第二校验值集合中的主文件校验值不满足一致性要求,则校验所述备文件集合中的备文件与所述第二校验值集合中的备文件校验值是否满足一致性要求;
    若所述备文件集合中的备文件与所述第二校验值集合中的备文件校验值满足一致性要求,则确定对所述主文件集合中的主文件进行数据回滚。
  6. 根据权利要求1~5任一所述的方法,其特征在于,在将所述主文件集合中的主文件回滚至与所述备文件集合中与该主文件对应相同文件名的备文件一致之后,所述方法还包括:
    重新计算所述主文件集合中各主文件对应的第一校验值,
    将所述第一校验值集合中第一校验值更新为该重新计算的第一校验值。
  7. 根据权利要求1所述的方法,其特征在于,当校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值满足一致性要求时,所述方法还包括:
    当校验出所述备文件集合中的备文件与所述第一校验值集合中的第一校验值不满足一致性要求时,
    重新生成所述主文件集合中各主文件对应的备文件;并
    利用重新生成的备文件更新所述备文件集合。
  8. 根据权利要求7所述的方法,其特征在于,在利用重新生成的备文件更新所述备文件集合之后,所述方法还包括:
    重新计算所述备文件集合中各备文件对应的第二校验值,
    将所述第二校验值集合中第二校验值更新为该重新计算的第二校验值。
  9. 根据权利要求1~8任一项所述的方法,其特征在于,所述主文件集合中的各个主文件具有业务关联性。
  10. 一种文件备份方法,包括:
    在检测到主文件集合对应的第一校验值集合不存在时,确定所述第一校验值集合,所述第一校验值集合包括所述主文件集合中各主文件对应的第一校验值;
    在检测到所述主文件集合对应的备文件集合不存在时,生成所述主文件集合对应的备文件集合并确定所述备文件集合对应的第二校验值集合,所述备文件集合包括所述主文件集合中各主文件的备文件,所述第二校验值集合包括所述备文件集合中各备文件对应的第二校验值。
  11. 一种文件更新方法,包括:
    接收文件更新指令,依据所述文件更新指令对主文件集合中的各个主文件进行更新;
    在完成对所述主文件集合中所有主文件的更新后,重新计算所述主文件集合中各更新后的主文件对应的第一校验值,并利用该重新计算的第一校验值更新第一校验值集合;
    重新生成所述主文件集合中各更新后的主文件对应的备文件并利用重新生成的备文件更新备文件集合,重新计算所述备文件集合中各备文件对应的第二校验值,利用重新计算的第二校验值更新第二校验值集合。
  12. 根据权利要求11所述的方法,其特征在于,当确定文件更新失败时,执行权利要求1~8任 一项所述的文件恢复方法,确定文件更新失败包括以下任一:
    若在依据所述文件更新指令对所述主文件集合中的各个主文件进行更新的过程中发生程序异常终止,则确定文件更新失败;
    在重新计算所述主文件集合中各更新后的主文件对应的第一校验值的过程中发生程序异常终止,则确定文件更新失败;或
    在重新生成所述主文件集合中各更新后的主文件对应的备文件的过程中发生程序异常终止,则确定文件更新失败。
  13. 一种文件恢复装置,包括:
    校验模块,用于校验主文件集合中的主文件与第一校验值集合中的第一校验值是否满足一致性要求;
    确定模块,用于依据第二校验值集合中的第二校验值和所述主文件集合的备文件集合确定是否对所述主文件集合中的主文件进行数据回滚;
    文件恢复模块,用于当校验出主文件集合中的主文件与第一校验值集合中的第一校验值不满足一致性要求,且依据第二校验值集合中的第二校验值和所述主文件集合的备文件集合确定出对所述主文件集合中的主文件进行数据回滚时,将所述主文件集合中的主文件回滚至与所述备文件集合中与该主文件对应相同文件名的备文件一致。
  14. 根据权利要求13所述的装置,其特征在于,所述第二校验值为主文件校验值;
    当所述校验模块校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求时,
    所述校验模块还用于校验所述备文件集合中的备文件与所述第二校验值集合中的主文件校验值是否满足一致性要求;
    所述确定模块用于当校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求且所述备文件集合中的备文件与所述第二校验值集合中的主文件校验值满足一致性要求时,确定对所述主文件集合中的主文件进行数据回滚。
  15. 根据权利要求13所述的装置,其特征在于,所述第二校验值为备文件校验值;
    当所述校验模块校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求时,
    所述校验模块还用于校验所述备文件集合中的备文件与第二校验值集合中的备文件校验值是否满足一致性要求;
    所述确定模块用于当校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求且所述备文件集合中的备文件与第二校验值集合中的备文件校验值满足一致性要求时,确定对所述主文件集合中的主文件进行数据回滚。
  16. 根据权利要求15所述的装置,其特征在于,在校验所述备文件集合中的备文件与第二校验值集合中的备文件校验值是否满足一致性要求之前,所述校验模块还用于校验所述第二校验值集合中的备文件校验值与所述第一校验值集合中的第一校验值是否满足一致性要求;
    所述确定模块用于当校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求,所述备文件集合中的备文件与第一校验值集合中的第一校验值不满足一致性要求,且所述备文件集合中的备文件与第二校验值集合中的备文件校验值满足一致性要求时,确定对所述主文件集合中的主文件进行数据回滚。
  17. 根据权利要求13所述的装置,其特征在于,所述第二校验值包括主文件校验值和备文件校验值;
    若校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求,则所述校验模块还用于校验所述备文件集合中的备文件与所述第二校验值集合中的主文件校验值是否满足一致性要求;
    若所述备文件集合中的备文件与所述第二校验值集合中的主文件校验值满足一致性要求,则所述确定模块用于确定对所述主文件集合中的主文件进行数据回滚;
    若所述备文件集合中的备文件与所述第二校验值集合中的主文件校验值不满足一致性要求,则所述校验模块还用于校验所述备文件集合中的备文件与所述第二校验值集合中的备文件校验值是否满足一致性要求;
    若所述备文件集合中的备文件与所述第二校验值集合中的备文件校验值满足一致性要求,则所述确定模块用于确定对所述主文件集合中的主文件进行数据回滚。
  18. 根据权利要求13~17任一所述的装置,其特征在于,所述装置还包括第一计算模块,用于:
    重新计算所述主文件集合中各主文件对应的第一校验值,
    将所述第一校验值集合中第一校验值更新为该重新计算的第一校验值。
  19. 根据权利要求13所述的装置,其特征在于,所述校验模块还用于校验所述备文件集合中的备文件与所述第一校验值集合中的第一校验值是否满足一致性要求;
    当校验出所述备文件集合中的备文件与所述第一校验值集合中的第一校验值不满足一致性要求时,所述装置还包括第一备份模块,用于:重新生成所述主文件集合中各主文件对应的备文件;并利用重新生成的备文件更新所述备文件集合。
  20. 根据权利要求19所述的装置,其特征在于,所述装置还包括第二计算模块,用于:
    重新计算所述备文件集合中各备文件对应的第二校验值,
    将所述第二校验值集合中第二校验值更新为该重新计算的第二校验值。
  21. 根据权利要求13~20任一项所述的装置,其特征在于,所述主文件集合中的各个主文件具有业务关联性。
  22. 一种文件备份装置,包括:
    第一校验值确定模块,用于在检测到主文件集合对应的第一校验值集合不存在时,确定所述第一校验值集合,所述第一校验值集合包括所述主文件集合中各主文件对应的第一校验值;
    文件备份模块,用于在检测到所述主文件集合对应的备文件集合不存在时,生成所述主文件集合对应的备文件集合,所述备文件集合包括所述主文件集合中各主文件的备文件;
    第二校验值确定模块,用于确定所述备文件集合对应的第二校验值集合,所述第二校验值集合 包括所述备文件集合中各备文件对应的第二校验值。
  23. 一种文件更新装置,包括:
    文件更新模块,用于接收文件更新指令,依据所述文件更新指令对主文件集合中的各个主文件进行更新;
    计算模块,用于在所述文件更新模块完成对所述主文件集合中所有主文件的更新后,重新计算所述主文件集合中各更新后的主文件对应的第一校验值,并利用该重新计算的第一校验值更新第一校验值集合;
    备份模块,用于重新生成所述主文件集合中各更新后的主文件对应的备文件并利用重新生成的备文件更新备文件集合,重新计算所述备文件集合中各备文件对应的第二校验值,利用重新计算的第二校验值更新第二校验值集合。
  24. 根据权利要求23所述的装置,其特征在于,所述装置还包括更新失败确定模块,用于执行以下任一:
    若在依据所述文件更新指令对所述主文件集合中的各个主文件进行更新的过程中发生程序异常终止,则确定文件更新失败;
    在重新计算所述主文件集合中各更新后的主文件对应的第一校验值的过程中发生程序异常终止,则确定文件更新失败;或
    在重新生成所述主文件集合中各更新后的主文件对应的备文件的过程中发生程序异常终止,则确定文件更新失败。
  25. 根据权利要求24所述的装置,其特征在于,当确定文件更新失败时,所述装置还包括文件恢复模块,用于:
    当校验出所述主文件集合中的主文件与所述第一校验值集合中的第一校验值不满足一致性要求,且依据所述第二校验值集合中的第二校验值和所述主文件集合的备文件集合确定出对所述主文件集合中的主文件进行数据回滚时,将所述主文件集合中的主文件回滚至与所述备文件集合中与该主文件对应相同文件名的备文件一致。
  26. 一种电子设备,包括可读存储介质和处理器;
    其中,所述可读存储介质,用于存储机器可执行指令;
    所述处理器,用于读取所述可读存储介质上的所述机器可执行指令,并执行所述指令以实现权利要求1-12任一所述方法的步骤。
  27. 一种计算机可读存储介质,所述计算机可读存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现权利要求1-12任一所述方法的步骤。
  28. 一种计算机程序产品,该计算机程序产品包括计算机指令,所述计算机指令被处理器执行时,能够实现权利要求1-12任一所述方法的步骤。
PCT/CN2020/131216 2019-12-10 2020-11-24 文件备份方法、恢复方法、更新方法及装置 WO2021115117A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911261688.8A CN111427718B (zh) 2019-12-10 2019-12-10 文件备份方法、恢复方法及装置
CN201911261688.8 2019-12-10

Publications (1)

Publication Number Publication Date
WO2021115117A1 true WO2021115117A1 (zh) 2021-06-17

Family

ID=71546899

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/131216 WO2021115117A1 (zh) 2019-12-10 2020-11-24 文件备份方法、恢复方法、更新方法及装置

Country Status (2)

Country Link
CN (1) CN111427718B (zh)
WO (1) WO2021115117A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111427718B (zh) * 2019-12-10 2024-01-23 杭州海康威视数字技术股份有限公司 文件备份方法、恢复方法及装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101436138A (zh) * 2007-11-16 2009-05-20 苏州科达通信技术发展有限公司 一种用于软件升级且动态回滚的控制装置以及控制方法
US20170141922A1 (en) * 2014-06-25 2017-05-18 Uc Mobile Co., Ltd. Incremental upgrade method and system for file
CN108108271A (zh) * 2017-12-25 2018-06-01 飞天诚信科技股份有限公司 一种实现事务与掉电保护统一管理的方法及装置
CN110032428A (zh) * 2019-02-21 2019-07-19 阿里巴巴集团控股有限公司 分布式事务的执行方法和装置
CN111427718A (zh) * 2019-12-10 2020-07-17 杭州海康威视数字技术股份有限公司 文件备份方法、恢复方法及装置

Family Cites Families (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH06236351A (ja) * 1993-02-10 1994-08-23 Hitachi Ltd オンラインシステムのバックアップリストア装置
US7860246B2 (en) * 2006-11-01 2010-12-28 International Business Machines Corporation System and method for protecting data in a secure system
WO2011089864A1 (ja) * 2010-01-21 2011-07-28 日本電気株式会社 ファイル群整合性検証システム、ファイル群整合性検証方法およびファイル群整合性検証用プログラム
CN102932621B (zh) * 2011-08-08 2015-05-20 杭州海康威视数字技术股份有限公司 一种存储数据的方法及装置
CN102662991A (zh) * 2012-03-14 2012-09-12 北京邮电大学 一种基于移动存储设备的文件级同步方法
CN106302953A (zh) * 2015-05-21 2017-01-04 中兴通讯股份有限公司 一种终端的匹配验证方法、装置及设备
CN107153588A (zh) * 2017-05-12 2017-09-12 成都优孚达信息技术有限公司 数据编码存储方法
CN107643882A (zh) * 2017-09-29 2018-01-30 昂纳信息技术(深圳)有限公司 一种数据可靠性的存储及恢复方法、系统及存储装置
CN108573016A (zh) * 2017-12-25 2018-09-25 北京金山云网络技术有限公司 一种数据一致性检查方法、装置、设备和存储介质
CN109871296A (zh) * 2018-12-24 2019-06-11 航天信息股份有限公司 一种数据备份方法及系统、数据恢复方法及系统和移动终端
CN109634645B (zh) * 2018-12-28 2022-03-22 深圳市有方科技股份有限公司 固件升级方法及终端
CN109784058A (zh) * 2019-01-07 2019-05-21 中国银行股份有限公司 版本强一致性校验方法、客户端、服务器及存储介质
CN110413441A (zh) * 2019-06-18 2019-11-05 平安科技(深圳)有限公司 主备存储卷同步数据校验方法、装置、设备及存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101436138A (zh) * 2007-11-16 2009-05-20 苏州科达通信技术发展有限公司 一种用于软件升级且动态回滚的控制装置以及控制方法
US20170141922A1 (en) * 2014-06-25 2017-05-18 Uc Mobile Co., Ltd. Incremental upgrade method and system for file
CN108108271A (zh) * 2017-12-25 2018-06-01 飞天诚信科技股份有限公司 一种实现事务与掉电保护统一管理的方法及装置
CN110032428A (zh) * 2019-02-21 2019-07-19 阿里巴巴集团控股有限公司 分布式事务的执行方法和装置
CN111427718A (zh) * 2019-12-10 2020-07-17 杭州海康威视数字技术股份有限公司 文件备份方法、恢复方法及装置

Also Published As

Publication number Publication date
CN111427718B (zh) 2024-01-23
CN111427718A (zh) 2020-07-17

Similar Documents

Publication Publication Date Title
US8229896B1 (en) Method and apparatus for identifying data blocks required for restoration
US20110099148A1 (en) Verification Of Remote Copies Of Data
CN106775610B (zh) 一种电子设备启动方法及一种电子设备
US20110320794A1 (en) Flash System And Method For Updating The Flash System
CN107301070B (zh) 一种升级方法及终端
US20190227710A1 (en) Incremental data restoration method and apparatus
CN105242990A (zh) 基于云平台的数据备份方法和装置
US11550595B2 (en) Adaptive system for smart boot sequence formation of VMs for disaster recovery
JP5665889B2 (ja) サブバージョンリポジトリをバックアップする方法及び装置
CN105760271A (zh) 一种集群模式下计算节点可信状态监控的方法
CN108255506A (zh) 一种bmc的数据更新方法、装置、设备及可读存储介质
WO2021115117A1 (zh) 文件备份方法、恢复方法、更新方法及装置
CN111857740A (zh) 一种软件升级方法及装置
US11150831B2 (en) Virtual machine synchronization and recovery
US8838545B2 (en) Incremental and prioritized restoration of blocks
US11474707B2 (en) Data loss recovery in a secondary storage controller from a primary storage controller
US9674105B2 (en) Applying a platform code level update to an operational node
CN105893186A (zh) 一种存储容灾数据的验证方法、装置及系统
CN115454711A (zh) 一种分布式存储系统中纠删数据恢复的方法、装置及介质
CN104572350B (zh) 一种元数据处理方法及装置
CN114443356A (zh) 一种容器集群的处理方法及系统
JP6481489B2 (ja) 修正適用情報作成プログラム、修正適用情報作成装置及び修正適用情報作成方法
CN111625840A (zh) 程序校验方法、程序升级方法及装置
CN116244084A (zh) 一种边缘计算装置
CN119739435A (zh) 一种固件配置校验方法、装置、管理控制器和存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20900317

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20900317

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 170523)

122 Ep: pct application non-entry in european phase

Ref document number: 20900317

Country of ref document: EP

Kind code of ref document: A1