File backup methods, devices, computer equipment, and readable storage media

By generating parallel backup tasks and a checkpoint file recovery mechanism, the problem of low file backup efficiency is solved, achieving efficient and fast backup and recovery, ensuring data integrity and resource utilization.

CN120086060BActive Publication Date: 2026-04-03GUANGZHOU DINGJIA COMPUTER TECHNOLOGY CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-08
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

With the increase in the amount of unstructured data, file backup efficiency is low, backup time is extended, and the probability of anomalies during backup is increased, resulting in a large waste of resources after backup failure. After a backup failure, repeated backups are required, which is inefficient.

Method used

By generating multiple backup tasks and backing up in parallel according to the file and directory identifiers, and generating a backup set checkpoint file at checkpoint time, uploading it to the server, and recording backup progress information and fragment information, the backup progress can be quickly restored in the event of a backup interruption.

Benefits of technology

It improves the efficiency of file backup, avoids duplicate backups after backup interruption, ensures data consistency and integrity, reduces resource waste, and improves the recovery efficiency of backup tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120086060B_ABST
    Figure CN120086060B_ABST
Patent Text Reader

Abstract

This application relates to a file backup method, apparatus, computer device, and readable storage medium. The method includes: obtaining a directory to be backed up; generating multiple backup tasks for each file in the directory; the backup tasks back up each file to a server according to file identifier order and directory identifier order, and generating backup set fragments corresponding to the backup tasks; each backup task is associated with context information; the context information includes backup progress information and backup set fragment information; the backup set fragment information includes the amount of data already written to files in the backup set fragments; running multiple backup tasks in parallel, periodically generating corresponding backup set checkpoint files at checkpoint times based on the context information of the backup tasks, and uploading the backup set checkpoint files to the server; the backup set checkpoint files are used to restore the backup progress of backup tasks in the event of interruption. This method can improve the efficiency of file backup.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer data storage technology, and in particular to a file backup method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Technology

[0002] Data backup is a critical measure to ensure data security and business continuity. In the face of unpredictable risks such as hardware failures, software errors, virus attacks, human error, or natural disasters, backups can prevent data loss and ensure the integrity and availability of critical information. Through regular backups, businesses can quickly restore to normal operations, reducing potential financial losses and reputational damage.

[0003] Files are the basic form of unstructured data storage, and file backup is an important subdomain of data backup. With the development of information technology, the total amount of unstructured data has also shown an explosive growth trend. At the same time, with the widespread application of various new storage methods such as distributed storage and object storage, the efficiency and performance of file backup, especially the backup of massive amounts of files and massive amounts of small files, have become the main challenges facing file backup functions.

[0004] As the amount of backup data continues to grow, the time required to complete the backup also increases. The longer the backup time, the greater the probability of backup failure due to network, hardware, software, or human error. Once the backup process is aborted, the completed backup data often has to be deleted as junk data, waiting for the next backup attempt. This wastes a lot of backup time and resources, resulting in low file backup efficiency. Summary of the Invention

[0005] Therefore, it is necessary to provide a file backup method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can improve the efficiency of file backup in order to address the above-mentioned technical problems.

[0006] In a first aspect, this application provides a file backup method, the method comprising:

[0007] Obtain the directory to be backed up; the directory to be backed up includes files sorted by file identifier and files in subdirectories sorted by directory identifier.

[0008] For each file in the directory to be backed up, multiple backup tasks are generated. Each backup task backs up the files to the server according to the file identifier order and the directory identifier order, and generates a backup set fragment corresponding to the backup task. The backup set fragment is used to write data to the files. Each backup task is associated with context information, including backup progress information and backup set fragment information. The backup set fragment information includes the amount of data already written to the files in the backup set fragment.

[0009] The multiple backup tasks are run in parallel. At regular intervals, a corresponding backup set checkpoint file is generated at checkpoint times based on the context information of the backup tasks, and the backup set checkpoint file is uploaded to the server. The backup set checkpoint file is used to restore the backup progress of the backup tasks in the event of an interruption.

[0010] In one embodiment, the method further includes:

[0011] The method further includes:

[0012] In the event that the backup task is interrupted, the backup set checkpoint file corresponding to the backup task is retrieved from the server.

[0013] Based on the backup set checkpoint file, determine the checkpoint file identifier and checkpoint directory identifier recorded at the latest checkpoint time; the checkpoint file identifier is the file identifier corresponding to the last backed-up file recorded at the latest checkpoint time; the checkpoint directory identifier is the directory identifier corresponding to the directory being backed up at the latest checkpoint time.

[0014] Iterate through the directories containing each file in the directory to be backed up, compare the directory identifiers corresponding to each file in the directory to be backed up with the checkpoint directory identifier, skip the backed-up directories, and locate the target directory that matches the checkpoint directory identifier.

[0015] Traverse each file in the target directory, compare the file identifier of each file in the target directory with the checkpoint file identifier, skip backed-up files, locate the backup interruption position in the directory to be backed up, and resume the backup task at the backup interruption position; the backup interruption position is the file position that matches both the checkpoint directory identifier and the checkpoint file identifier.

[0016] In one embodiment, comparing the file identifiers of each file in the target directory with the checkpoint file identifier, skipping backed-up files, and locating the backup interruption point in the directory to be backed up includes:

[0017] The file identifiers of each file in the target directory are compared with the checkpoint file identifier. Files whose file identifiers are less than or equal to the checkpoint file identifier are identified as backed-up files. These backed-up files are skipped, and the backup interruption position in the directory to be backed up is located.

[0018] In one embodiment, the step of traversing the directories containing each file in the directory to be backed up, comparing the directory identifiers corresponding to each file in the directory to be backed up with the checkpoint directory identifier, skipping backed-up directories, and locating the target directory matching the checkpoint directory identifier includes:

[0019] Iterate through the directories containing each file in the directory to be backed up;

[0020] If the target identifier of the currently traversed directory is the parent directory identifier of the checkpoint directory identifier, then the files under the directory corresponding to the parent directory identifier are determined to be backed up files, the directory corresponding to the parent directory identifier is skipped, and the target directory matching the checkpoint directory identifier is determined from the subdirectories contained in the directory corresponding to the parent directory identifier.

[0021] In one embodiment, the method further includes:

[0022] In the event that the backup task is interrupted, the backup set checkpoint file corresponding to the backup task is retrieved from the server.

[0023] Based on the backup set checkpoint file, determine the backup set fragment information recorded at the latest checkpoint time, discard the target data in the backup set fragment corresponding to the backup task, and obtain the truncated backup set fragment; the target data is the data written to the backup set fragment after the checkpoint time.

[0024] Based on the backup set checkpoint file, restore the context information of the backup task to the context information corresponding to the latest checkpoint moment;

[0025] Based on the context information corresponding to the latest checkpoint time, the backup interruption position in the directory to be backed up is located, and the backup task is resumed at the backup interruption position to write the unbacked-up files to the backup set fragments after the truncation operation.

[0026] In one embodiment, the method further includes:

[0027] Obtain the backup set checkpoint file corresponding to the backup task from the server;

[0028] Based on the backup set fragment information corresponding to the checkpoint time recorded in the backup set checkpoint file, the target data in the backup set fragment corresponding to the backup task is discarded to obtain the truncated backup set fragment; the target data is the data written to the backup set fragment after the checkpoint time.

[0029] Write format data matching the target storage format into the backup set fragments to generate a valid storage format file corresponding to the backup set fragments; the target storage format is the storage format of the backup set composed of backup set fragments generated according to each backup task; the valid storage format file is used to retrieve the files that have been backed up to the server at the checkpoint time in the event that the backup task is interrupted.

[0030] Secondly, this application also provides a file backup device, comprising:

[0031] The file acquisition module is used to acquire the directory to be backed up; the directory to be backed up includes files sorted in order of file identifier and files in subdirectories sorted in order of directory identifier.

[0032] The task generation module is used to generate multiple backup tasks for each file in the directory to be backed up. Each backup task backs up the files to the server according to the file identifier order and the directory identifier order, and generates a backup set fragment corresponding to the backup task. The backup set fragment is used to write data to the files. Each backup task is associated with context information, including backup progress information and backup set fragment information. The backup set fragment information includes the amount of data already written to the files in the backup set fragment.

[0033] The running module is used to run the multiple backup tasks in parallel, periodically generate corresponding backup set checkpoint files at checkpoint times based on the context information of the backup tasks, and upload the backup set checkpoint files to the server; the backup set checkpoint files are used to restore the backup progress of the backup tasks in the event of an interruption.

[0034] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described method.

[0035] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method.

[0036] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the above-described method.

[0037] The aforementioned file backup method, apparatus, computer equipment, computer-readable storage medium, and computer program product acquire a directory to be backed up, which includes files sorted by file identifier and files in subdirectories sorted by directory identifier. Based on the files in the directory to be backed up, multiple backup tasks are generated. These backup tasks back up each file to a server according to its file identifier and directory identifier, and generate backup set fragments corresponding to each backup task. These backup set fragments are used to write data to the files. Each backup task is associated with context information, including backup progress information and backup set fragment information, which includes the amount of data already written to the files in the backup set fragments. Multiple backup tasks are run in parallel. At regular intervals, based on the context information of the backup tasks, corresponding backup set checkpoint files are generated at checkpoint times, and these checkpoint files are uploaded to the server. These backup set checkpoint files are used to restore the backup progress of backup tasks in the event of interruption. By sorting the files and subdirectories in the directory to be backed up and backing up each file sequentially, it facilitates rapid recovery of the backup task. Generating multiple backup tasks running in parallel improves file backup efficiency. Furthermore, associating backup tasks with context information containing backup progress and backup set fragment information allows for real-time tracking of the backup task's execution status. This enables the backup task to be accurately restored to its state before the backup was interrupted, based on the context information. Additionally, a backup set checkpoint file is generated periodically at checkpoint times based on this context information and uploaded to the server. In the event of a backup interruption, the backup progress can be restored using this backup set checkpoint file, avoiding repeated backup operations after an interruption. This improves the recovery efficiency of backup tasks when file backups are interrupted, thereby enhancing overall file backup efficiency. Attached Figure Description

[0038] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0039] Figure 1 This is a diagram illustrating the application environment of a file backup method in one embodiment.

[0040] Figure 2This is a flowchart illustrating a file backup method in one embodiment;

[0041] Figure 3 This is a logic diagram of a file backup method in one embodiment;

[0042] Figure 4 This is a logic diagram of another file backup method in one embodiment;

[0043] Figure 5 This is a logic diagram of a method for restoring backup progress from a backup checkpoint in one embodiment;

[0044] Figure 6 This is a logic diagram of a method for restoring backup progress in one embodiment;

[0045] Figure 7 This is a flowchart illustrating another file backup method in one embodiment;

[0046] Figure 8 This is a structural block diagram of a file backup device in one embodiment;

[0047] Figure 9 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0048] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0049] The file backup method provided in this application embodiment can be applied to, for example, Figure 1In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or placed on a cloud or other network server. Terminal 102 obtains a directory to be backed up; the directory includes files sorted by file identifier and files in subdirectories sorted by directory identifier; terminal 102 generates multiple backup tasks for each file in the directory to be backed up; the backup tasks are used to back up each file to the server according to file identifier and directory identifier order, and generate backup set fragments corresponding to the backup tasks; backup set fragments are used to write data to the files; backup tasks are associated with context information; the context information includes backup progress information and backup set fragment information; the backup set fragment information includes the amount of data already written to the files in the backup set fragments; terminal 102 runs multiple backup tasks in parallel, periodically generating corresponding backup set checkpoint files at checkpoint times based on the context information of the backup tasks, and uploading the backup set checkpoint files to the server; the backup set checkpoint files are used to restore the backup progress of backup tasks in the event of an interruption. The terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle systems, and projection devices. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted displays. Head-mounted displays can be virtual reality (VR) devices, augmented reality (AR) devices, and smart glasses. The server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.

[0050] In one exemplary embodiment, such as Figure 2 As shown, a file backup method is provided, which can be applied to... Figure 1 Taking terminal 102 as an example, the explanation includes:

[0051] Step S202: Obtain the directory to be backed up.

[0052] The directory to be backed up can include files within the directory itself, as well as files in its subdirectories. For example, "c:\path\to\current" is a four-level directory structure, where "c:" is the first level, "c:\path" is the second level, "c:\path\to" is the third level, and "c:\path\to\current" is the fourth level. Assuming the directory to be backed up is "c:", the files within it can include files within the "c:" directory, as well as files in the subdirectories "c:\path", "c:\path\to", and "c:\path\to\current".

[0053] The terminal can generate a list of files to be backed up based on the files in these directories. Each file in the list has metadata, such as file size, modification time, and permissions. The terminal can use these files and their corresponding metadata as input for one or more backup tasks.

[0054] The directory to be backed up includes files sorted by file identifier and files in subdirectories sorted by directory identifier.

[0055] In one embodiment, the file identification order can be the alphabetical order of filenames, and the target identification order can be the alphabetical order of directory names. The terminal can sort files according to the alphabetical order of filenames and sort subdirectories according to the alphabetical order of directory names. Here, alphabetical order refers to the way a computer sorts strings according to the order in a dictionary, based on the ASCII code values ​​of the strings one by one. Using filenames (paths) as strings, sorting them alphabetically, and distributing them to various backup tasks allows file backups to be sorted according to the alphabetical order of filenames. This greatly simplifies the context information maintained by backup tasks, thereby improving the speed of subsequently generating backup set checkpoint files and reducing the storage space occupied by backup set checkpoint files.

[0056] Step S204: Generate multiple backup tasks for each file in the directory to be backed up.

[0057] The backup task is used to back up each file to the server according to the file identifier order and directory identifier order, and generate a backup set fragment corresponding to the backup task; the backup set fragment is used to write data to the file; the backup task is associated with context information; the context information includes the backup progress information of the backup task and the backup set fragment information; the backup set fragment information includes the amount of data that has been written to the file in the backup set fragment.

[0058] A backup task can generate a backup set by taking the files in the directory to be backed up and their corresponding metadata and other key information in a specific format (such as tar, mtf, etc.), and a backup set fragment can be a data block (fragment) in the backup set.

[0059] Backup set fragments can be files or special file structures generated according to the backup storage format. Optionally, a backup set fragment can be a compressed archive in RAR or ZIP format. Therefore, backing up files to a server can be a process of writing files to a compressed archive. Each backup task can generate one or more compressed archives, which are equivalent to backup set fragments. The backup set fragments generated by various backup tasks can collectively form a complete backup set, which may include the data of all files in the directory to be backed up, as well as the corresponding metadata.

[0060] In practice, multiple backup tasks are generated for the files in the directory to be backed up. This can be done by distributing the files in the directory to be backed up to multiple backup tasks running in parallel according to certain rules. Each backup task independently completes the backup of a portion of the files and generates corresponding backup set fragments. The backup set fragments generated by all backup tasks together constitute a complete backup set, which contains the backup of the data and metadata of all files in the directory to be backed up.

[0061] In practice, multiple backup tasks run concurrently. Each backup task maintains context information to store its backup progress and the resulting backup set fragment information. After each complete file backup, the backup task refreshes its context information. This context information is real-time information maintained for each backup task during the backup process to track the task's execution progress and status.

[0062] In one example, context information may include the backup task ID, the current backup directory, the last file that has been backed up, and the size of the currently generated backup set fragment. Backup progress information may include the current backup directory, the last file that has been backed up, and the percentage of backup progress. Backup set fragment information may include the size of the currently generated backup set fragment, i.e., the amount of data already written to files in the backup set fragment, such as 10 gigabytes (GB) or 20 GB.

[0063] For the convenience of those skilled in the art, Figure 3 An exemplary logic diagram of a file backup method is provided. Figure 1 Terminal 102 can be Figure 3 Backup host, Figure 1 Terminal 104 can be Figure 3The backup storage server consists of two parts: a backup host, which is the host containing the backup files or a terminal that can access the complete files to be backed up; and a backup storage server, a dedicated server that provides storage for backup operations. The backup host and backup storage server communicate via a backup network to transfer backup data. This backup network includes, but is not limited to, network architectures based on different transmission protocols such as Internet Protocol (IP) networks and Storage Area Networks (SAN) networks. The backup host obtains the files in the directory to be backed up (the files to be backed up) and distributes them to different backup tasks. Each backup task independently completes the backup of a portion of the files, generating corresponding backup set fragments. All backup set fragments generated by the backup tasks together constitute a complete backup set, which contains the backup of all the data and metadata of the files to be backed up.

[0064] Step S206: Run multiple backup tasks in parallel, and periodically generate corresponding backup set checkpoint files at checkpoint times based on the context information of the backup tasks, and upload the backup set checkpoint files to the server.

[0065] The backup set checkpoint file is used to restore the backup progress of a backup task in the event of an interruption.

[0066] In practice, during the parallel execution of multiple backup tasks, a backup set checkpoint file can be generated periodically. Generating the backup set checkpoint file may include the following steps: locking the context information of each backup task, generating the corresponding backup set checkpoint file based on the context information of each backup task, and uploading it to the storage server for storage.

[0067] The checkpoint time is the time at which the backup set checkpoint file is generated on a scheduled basis. In one example, the time for generating the backup set checkpoint file can be a fixed time or one of the configuration options for running the backup task. The format of the backup set checkpoint file is not restricted.

[0068] In practice, the backup set checkpoint file is a file that is periodically generated based on context information. It is used to restore the backup state to the time when the checkpoint was generated after the backup is interrupted. The backup set checkpoint file can include the backup progress information at each checkpoint and the correspondence between the backup set fragment information. Uploading the backup set checkpoint file to the server allows the latest backup set checkpoint file to be obtained from the server to restore the backup progress of the backup task in the event of a backup task interruption. This avoids discarding previously backed-up data and restarting the backup of all files after the backup job is interrupted.

[0069] For the convenience of those skilled in the art, Figure 4An exemplary logical diagram of another file backup method is provided. As can be seen, the files in the list directory, i.e., the files in the directory to be backed up, are sorted by filename and then assigned to multiple backup tasks. Each backup task can generate a corresponding backup set fragment, and each backup task maintains context information, i.e., the task context in the diagram. Then, backup checkpoints, i.e., backup checkpoint files, are generated periodically based on the task context.

[0070] The aforementioned file backup method, apparatus, computer equipment, computer-readable storage medium, and computer program product acquire a directory to be backed up, which includes files sorted by file identifier and files in subdirectories sorted by directory identifier. Based on the files in the directory to be backed up, multiple backup tasks are generated. These backup tasks back up each file to a server according to its file identifier and directory identifier, and generate backup set fragments corresponding to each backup task. These backup set fragments are used to write data to the files. Each backup task is associated with context information, including backup progress information and backup set fragment information, which includes the amount of data already written to the files in the backup set fragments. Multiple backup tasks are run in parallel. At regular intervals, based on the context information of the backup tasks, corresponding backup set checkpoint files are generated at checkpoint times, and these checkpoint files are uploaded to the server. These backup set checkpoint files are used to restore the backup progress of backup tasks in the event of interruption. By sorting the files and subdirectories in the directory to be backed up and backing up each file sequentially, it facilitates rapid recovery of the backup task. Generating multiple backup tasks running in parallel improves file backup efficiency. Furthermore, associating backup tasks with context information containing backup progress and backup set fragment information allows for real-time tracking of the backup task's execution status. This enables the backup task to be accurately restored to its state before the backup was interrupted, based on the context information. Additionally, a backup set checkpoint file is generated periodically at checkpoint times based on this context information and uploaded to the server. In the event of a backup interruption, the backup progress can be restored using this backup set checkpoint file, avoiding repeated backup operations after an interruption. This improves the recovery efficiency of backup tasks when file backups are interrupted, thereby enhancing overall file backup efficiency.

[0071] In another embodiment, the method further includes: in the event that the backup task is interrupted, obtaining the backup set checkpoint file corresponding to the backup task from the server; determining the backup set fragment information recorded at the latest checkpoint time based on the backup set checkpoint file, discarding the target data in the backup set fragment corresponding to the backup task, and obtaining the truncated backup set fragment; the target data is the data written to the backup set fragment after the checkpoint time; restoring the context information of the backup task to the context information corresponding to the latest checkpoint time based on the backup set checkpoint file; locating the backup interruption position in the directory to be backed up based on the context information corresponding to the latest checkpoint time, and resuming the backup task at the backup interruption position to write the unbacked-up files to the truncated backup set fragment.

[0072] In one example, the backup task may be interrupted for the following reasons: network failure, hardware failure, software operation, human error, insufficient storage space, power outage, etc.

[0073] In practice, after the backup task is interrupted, the cause of the interruption is handled and each backup task can be restarted. At this time, the backup set checkpoint file corresponding to each backup task can be obtained from the server to restore the backup progress. For example, the latest backup set checkpoint file generated by the backup task when the last operation was interrupted can be obtained, that is, the backup set checkpoint file generated at the latest checkpoint moment.

[0074] In practice, the backup set checkpoint file for each backup task can record the backup set fragment information corresponding to the checkpoint moment, i.e., the size of the backup set fragment. This backup set fragment information can be used to perform a truncation operation on the backup set fragments of the backup task, discarding data written to the backup set fragments after the checkpoint moment. The backup set checkpoint file for each backup task can also be used to restore the context information of each backup task to the context information recorded at the checkpoint moment. The context information recorded in the backup set checkpoint file for each backup task may include the current backup directory and the last file that has been backed up. Based on this context information, the backup of files in the directory to be backed up can be restored, thus allowing backup of files that were not backed up to the server before the checkpoint moment to continue.

[0075] For the convenience of those skilled in the art, Figure 5 An exemplary logical diagram of a method for restoring backup progress from a backup checkpoint is provided. It can be seen that the context information and backup progress of the backup task can be restored using the backup set checkpoint file.

[0076] The technical solution of this embodiment obtains the backup set checkpoint file from the server and truncates the data written to the backup set fragments after the checkpoint time based on the backup set fragment information recorded at the latest checkpoint time. This avoids re-backing up all files, only discarding some incomplete fragments, minimizing the waste of time and storage resources caused by repeated backups. After the backup task is interrupted, the backup set checkpoint file can be used to quickly restore the context information of the backup task, allowing the backup progress to continue from the interruption point, avoiding starting the backup from the beginning and improving the efficiency of backup task recovery. By accurately locating and discarding invalid data written after the checkpoint time, data consistency can be ensured, preventing data chaos, loss, duplication, and inconsistency caused by interruption. By utilizing the recovery mechanism of backup set checkpoints and context information, it is ensured that all file data is completely backed up to the server, achieving efficient recovery of the backup task after interruption, improving the fault tolerance, recovery efficiency, and resource utilization of file backup, thereby improving the efficiency of file backup.

[0077] In another embodiment, if the backup task is interrupted, the backup set checkpoint file corresponding to the backup task is obtained from the server; based on the backup set checkpoint file, the checkpoint file identifier and checkpoint directory identifier recorded at the latest checkpoint time are determined; the checkpoint file identifier is the file identifier corresponding to the last backed-up file recorded at the latest checkpoint time; the checkpoint directory identifier is the directory identifier corresponding to the directory being backed up at the latest checkpoint time; the directories containing each file in the directory to be backed up are traversed, and the directory identifiers corresponding to each file in the directory to be backed up are compared with the checkpoint directory identifiers, skipping backed-up directories and locating the target directory that matches the checkpoint directory identifier; the files in the target directory are traversed, and the file identifiers of each file in the target directory are compared with the checkpoint file identifiers, skipping backed-up files and locating the backup interruption position in the directory to be backed up, and the backup task is resumed at the backup interruption position; the backup interruption position is the file position that matches both the checkpoint directory identifier and the checkpoint file identifier.

[0078] The context information recorded by the backup task at the checkpoint can include the checkpoint file identifier and checkpoint directory identifier corresponding to the checkpoint. This context information can be used to record the precise progress of the backup process.

[0079] The checkpoint file identifier can be a unique identifier of the last successfully backed-up file recorded at the checkpoint moment, such as the file path, file name, or file metadata. This checkpoint file identifier can be used to determine which file was backed up to before the backup was interrupted.

[0080] The checkpoint directory identifier can be a unique identifier of the directory currently being processed when the backup was interrupted. It is usually a directory path or a unique directory number. This identifier can be used to locate the directory level at which the backup was interrupted.

[0081] In the specific implementation, the process involves traversing the directories containing each file in the directory to be backed up. This can involve scanning the root directory (i.e., the directory to be backed up) and all its subdirectories, skipping directories that do not match the checkpoint directory identifier, and searching for directories that match the checkpoint directory identifier. This process can recursively delve into multiple subdirectories until a target directory that matches the checkpoint directory identifier is found.

[0082] The target directory is the directory that was being processed when the backup was interrupted, and all backup progress recovery operations can continue in this directory.

[0083] After locating the target directory, the file identifiers of each file in the target directory are compared with the checkpoint file identifier. Files that do not match the checkpoint file identifier are skipped, and files that match the checkpoint file identifier are searched. The checkpoint file identifier includes the file identifier of the last file that has been successfully backed up. This allows the system to locate the backup interruption point in the directory to be backed up within the target directory. Files after the backup interruption point are files that have not yet been backed up. These unbacked-up files are those that failed to be successfully written to the backup set fragment at the checkpoint. For example, if the file identified by the checkpoint file identifier is the 10th file in the directory, the backup will continue from the 11th file.

[0084] Once the location of the backup interruption is determined, the backup task can be restarted, and the data of those files will be written to the previous backup set fragments. When the recovery backup task runs, it will not only ensure that unbacked-up files are continued to be written to the previous backup set fragments, but it will also maintain the sequential backup of new files until the entire target directory is backed up.

[0085] The technical solution of this embodiment can quickly identify and skip backed-up directories and files by comparing file identifiers and directory identifiers, locate the backup interruption position, greatly reduce repeated traversal and redundant backup operations, and only need to start from the precise position where it was interrupted, without having to back up the already processed files or directories again, which can quickly restore the progress of the backup task and improve the efficiency of file backup.

[0086] In another embodiment, comparing the file identifiers of each file in the target directory with the checkpoint file identifier, skipping backed-up files, and locating the backup interruption position in the directory to be backed up includes: comparing the file identifiers of each file in the target directory with the checkpoint file identifier, identifying files whose file identifiers are less than or equal to the checkpoint file identifier as backed-up files, skipping backed-up files, and locating the backup interruption position in the directory to be backed up.

[0087] Each file has a unique file identifier (file ID). Optionally, the file identifier can be the file name, the file path, or a unique value generated from metadata (such as creation time, modification time, etc.). This file identifier is used to determine the order of the files.

[0088] In practice, the backup task will back up the files to the server sequentially, starting with the file with the smallest file identifier, according to the sorting results. During the backup process, corresponding backup set fragments will be generated. This ordered backup method can ensure that each file is processed in a predetermined order, making it easy to accurately locate the backup progress after an interruption.

[0089] In practice, within the target directory, all files are sorted in ascending order based on their file identifiers. This sorting follows the computer's alphabetical order, meaning the order is determined by comparing the ASCII values ​​of characters in the filename or identifier; smaller identifiers appear first, and larger identifiers appear later. This lexicographical or alphabetical sorting method ensures that files are processed sequentially, guaranteeing the orderliness and consistency of the backup.

[0090] After sorting the files in the target directory by file identifier, the file identifiers of each file in the target directory can be compared with the checkpoint file identifier. Files with file identifiers less than or equal to the checkpoint file identifier are already backed up and can be skipped; files with file identifiers greater than the checkpoint file identifier are not yet backed up, thus identifying the files that need to be backed up. For example, assuming the checkpoint file identifier is "file_003", and the files in the target directory are "file_001", "file_002", "file_003", "file_004", and "file_005", then "file_004" and "file_005" will be identified as unbacked up files, and the backup can begin with "file_004".

[0091] The technical solution in this embodiment ensures the sequentiality and efficient recovery of backup tasks by sorting file identifiers and comparing checkpoint file identifiers. It can quickly locate and recover incomplete backup tasks, thereby improving the efficiency and reliability of file backup.

[0092] In another embodiment, traversing the directories containing each file in the directory to be backed up, comparing the directory identifiers corresponding to each file in the directory to be backed up with the checkpoint directory identifier, skipping the already backed-up directories, and locating the target directory that matches the checkpoint directory identifier includes: traversing the directories containing each file in the directory to be backed up; if the target identifier of the currently traversed directory is the parent directory identifier of the checkpoint directory identifier, then determining that the files under the directory corresponding to the parent directory identifier are already backed up files, skipping the directory corresponding to the parent directory identifier, and determining the target directory that matches the checkpoint directory identifier from the subdirectories contained in the directory corresponding to the parent directory identifier.

[0093] Specifically, if the directory corresponding to the checkpoint directory identifier is the target directory, then the parent directory identifier of the checkpoint directory identifier can refer to the directory identifier of the parent directory of the target directory. For example, if the directory corresponding to the checkpoint target identifier is A, and the parent directory of A is B, then the parent directory identifier of the checkpoint directory identifier refers to the directory identifier of B.

[0094] For example, "c:\path\to\current" is a four-level directory, where "c:" is the first-level directory, "c:\path" is the second-level directory, "c:\path\to" is the third-level directory, and "c:\path\to\current" is the fourth-level directory. Since file backups are performed hierarchically, files in the "c:\path" directory will only be processed after files in the "c:\path\to" directory have been backed up. Assuming the target identifier of the directory being processed at the checkpoint is "c:\path\to\current," meaning the checkpoint directory identifier is "c:\path\to\current," then the files under the parent directory identifier "c:\path\to" of this checkpoint directory identifier have already been backed up and can be skipped. It should be noted that "c:" can be the directory to be backed up, i.e., the root directory. The root directory can refer to the highest-level directory in the file system, which is the starting point for all files and subdirectories; other level directories are subdirectories of the root directory; and the parent directory refers to the directory one level above the current directory.

[0095] For the convenience of those skilled in the art, Figure 6 An exemplary logic diagram of a method for restoring backup progress is provided.

[0096] In specific implementation, the steps may include: S1, the terminal traverses the files under the directory to be backed up (root directory) and the subdirectories within the directory to be backed up; S2, if the currently traversed directory is the target directory that matches the checkpoint directory identifier, then a sorting operation is performed on the files in the target directory, files whose file identifiers are less than or equal to the checkpoint file identifier are identified as backed up and skipped, files whose file identifiers are greater than the checkpoint file identifier are identified as unbacked up, and then the file with the next file identifier corresponding to the checkpoint file identifier in the sorting order is used as the file to start the backup process during the backup progress recovery; S3, if the currently traversed directory is the parent directory of the target directory, then execute... The steps are as follows: S31. Determine that the files in the parent directory have been backed up and skip them; S32. Sort the subdirectories in the parent directory according to their directory identifiers, and determine that the files in the subdirectories with directory identifiers less than or equal to the checkpoint directory identifiers are backed up and skip them. Determine that the files in the subdirectories with directory identifiers greater than the checkpoint directory identifiers are not backed up, thereby finding the files that have started to be backed up during the backup progress recovery process; S33. If the target directory is still not found in the subdirectories of the parent directory, a traversal operation can be performed on the deeper level of the parent directory of the target directory, and return to steps S2 and S3 above to search for unbacked-up files again. For example, if the target directory is "c:\path\to\current" and the parent directory at the previous level is "c:\path\to", then the deeper level of the parent directory is "c:\path".

[0097] For example, the directory "path" has three subdirectories: a, b, and c. If the target directory is "path\c\file1" (the directory of a certain file), when traversing "path", it is found that "path" is the parent directory of "path\c\file1". Therefore, it is necessary to delve deeper into the "path" directory and continue traversing the files and subdirectories within "path". Since the file "file1" under "path\c" is already being backed up, the files under "path", as well as those under "path\a" and "path\b", can be skipped directly, and the traversal of the "path\c" subdirectories can continue. If "path\c" is the directory where the current backup file is located, i.e., the target directory, then the files under "path\c" need to be processed. By comparing filenames, files before "file1" are skipped, and the backup begins from files after "file1".

[0098] At this point, the backup set fragmentation, context information restoration, and backup progress restoration have been completed based on the backup set checkpoint file, restoring the backup progress to the state at the checkpoint. Subsequent backups can be completed according to the normal backup process.

[0099] In another embodiment, the method further includes: obtaining the backup set checkpoint file corresponding to the backup task from the server; discarding the target data in the backup set fragment corresponding to the checkpoint time recorded in the backup set checkpoint file to obtain the truncated backup set fragment; the target data is the data written to the backup set fragment after the checkpoint time; writing format data matching the target storage format into the backup set fragment to generate a valid storage format file corresponding to the backup set fragment; the target storage format is the storage format of the backup set composed of backup set fragments generated by each backup task; the valid storage format file is used to obtain the files that have been backed up to the server at the checkpoint time in the event of a backup task interruption.

[0100] The backup set fragment can be truncated to the size of the backup set fragment at the checkpoint time, ensuring that the backup set fragment contains only the data that has been successfully backed up and is complete at the checkpoint time. Then, data in a format that matches the target storage format can be written into the backup set fragment.

[0101] The target storage format refers to the format used by the final backup set composed of fragments generated by multiple backup tasks, such as tar, mtf, zip, etc. The backup set fragments generated by the backup tasks need to conform to a certain storage format so that the system can recognize, manage, and restore the data. Writing format data matching the target storage format to the backup set fragments restores the backup set fragments already backed up to the server into valid storage format files, which can be viewed as individual backup sets conforming to the target storage format. These files can be directly used for subsequent data recovery or continued backup, ensuring data consistency and integrity. Optionally, necessary format data can be added to the end of the backup set fragments. This format data could be an end marker matching the target storage format or metadata, ensuring that the backup set fragments meet the requirements of the target storage format. Thus, by performing specific processing on the backup set fragments, the backed-up data can be used to generate a valid backup set for data recovery.

[0102] The technical solution in this embodiment, by writing data in a specific storage format, ensures that the backup data generated by a failed backup job can be fully utilized when necessary. In some extreme cases, it is possible to restore from incomplete backup data to the most recent checkpoint, ensuring that the effectiveness of the backup operation is maximized. The generated valid storage format file not only improves the fault tolerance of the backup task but also significantly enhances the efficiency of data recovery, avoids redundant operations, optimizes resource utilization, and further improves the efficiency of file backup.

[0103] In another embodiment, such as Figure 7 As shown, a file backup method is provided, which can be applied to... Figure 1Taking terminal 102 as an example, the explanation includes the following steps:

[0104] S702, obtain the directory to be backed up.

[0105] The directory to be backed up includes files sorted by file identifier and files in subdirectories sorted by directory identifier.

[0106] S704 generates multiple backup tasks for each file in the directory to be backed up.

[0107] The backup task is used to back up each file to the server according to the file identifier order and directory identifier order, and generate a backup set fragment corresponding to the backup task; the backup set fragment is used to write data to the file; the backup task is associated with context information; the context information includes the backup progress information of the backup task and the backup set fragment information; the backup set fragment information includes the amount of data that has been written to the file in the backup set fragment.

[0108] The S706 runs multiple backup tasks in parallel, periodically generates corresponding backup set checkpoint files at checkpoint times based on the context information of the backup tasks, and uploads the backup set checkpoint files to the server.

[0109] Backup set checkpoint files are used to restore the backup progress of a backup task in the event of an interruption.

[0110] S708 retrieves the backup set checkpoint file corresponding to the backup task from the server when the backup task is interrupted.

[0111] S710 determines the checkpoint file identifier and checkpoint directory identifier recorded at the latest checkpoint time based on the backup set checkpoint file.

[0112] The checkpoint file identifier is the file identifier corresponding to the last backed-up file recorded at the latest checkpoint time; the checkpoint directory identifier is the directory identifier corresponding to the directory being backed up at the latest checkpoint time.

[0113] S712, traverse the directories where each file in the directory to be backed up is located, compare the directory identifier corresponding to each file in the directory to be backed up with the checkpoint directory identifier, skip the backed-up directories, and locate the target directory that matches the checkpoint directory identifier.

[0114] S714 traverses each file in the target directory, compares the file identifier of each file in the target directory with the checkpoint file identifier, skips backed-up files, locates the backup interruption point in the directory to be backed up, and resumes the backup task at the backup interruption point.

[0115] The backup interruption location is a file location that matches both the checkpoint directory identifier and the checkpoint file identifier.

[0116] In one embodiment, comparing the file identifiers of each file in the target directory with the checkpoint file identifier, skipping backed-up files, and locating the backup interruption position in the directory to be backed up includes: comparing the file identifiers of each file in the target directory with the checkpoint file identifier, identifying files whose file identifiers are less than or equal to the checkpoint file identifier as backed-up files, skipping backed-up files, and locating the backup interruption position in the directory to be backed up.

[0117] In one embodiment, the process involves traversing the directories containing each file in the directory to be backed up, comparing the directory identifiers corresponding to each file in the directory to be backed up with the checkpoint directory identifiers, skipping backed-up directories, and locating the target directory that matches the checkpoint directory identifier. This includes: traversing the directories containing each file in the directory to be backed up; if the target identifier of the currently traversed directory is the parent directory identifier of the checkpoint directory identifier, then determining that the files under the directory corresponding to the parent directory identifier are backed-up files, skipping the directory corresponding to the parent directory identifier, and determining the target directory that matches the checkpoint directory identifier from the subdirectories contained in the directory corresponding to the parent directory identifier.

[0118] In one embodiment, the method further includes: in the event that the backup task is interrupted, obtaining the backup set checkpoint file corresponding to the backup task from the server; determining the backup set fragment information recorded at the latest checkpoint time based on the backup set checkpoint file, discarding the target data in the backup set fragment corresponding to the backup task, and obtaining the truncated backup set fragment; the target data is the data written to the backup set fragment after the checkpoint time; restoring the context information of the backup task to the context information corresponding to the latest checkpoint time based on the backup set checkpoint file; locating the backup interruption position in the directory to be backed up based on the context information corresponding to the latest checkpoint time, and resuming the backup task at the backup interruption position to write the unbacked-up files to the truncated backup set fragment.

[0119] In one embodiment, the method further includes: obtaining a backup set checkpoint file corresponding to the backup task from the server; discarding target data in the backup set fragments corresponding to the checkpoint time recorded in the backup set checkpoint file to obtain truncated backup set fragments; the target data is data written to the backup set fragments after the checkpoint time; writing format data matching the target storage format into the backup set fragments to generate a valid storage format file corresponding to the backup set fragments; the target storage format is the storage format of the backup set composed of backup set fragments generated by each backup task; the valid storage format file is used to obtain files that have been backed up to the server at the checkpoint time in the event of a backup task interruption.

[0120] As can be seen, the above file backup method can resume interrupted file backup jobs with very low storage and computational consumption, saving backup time and storage resources, which is particularly beneficial for massive file backups. By periodically creating backup checkpoints during the backup process, the interrupted file backup job can be restored to the backup state of the most recent backup checkpoint after the fault is recovered, and the previous backup progress can be resumed in this state until the backup is complete. Compared with the traditional strategy of repeated backups, it saves backup time. After the fault is recovered, the backup data completed before the fault occurred can be continued. Subsequent backups only need to be performed on files that were not previously backed up, saving time and bandwidth and improving the efficiency of file backup. It also maintains the integrity of the backup plan, enabling the previous backup progress to be restored as soon as the fault is recovered, avoiding missing the backup time window and ensuring the integrity of the backup plan.

[0121] It should be noted that the specific limitations of the above steps can be found in the specific limitations of a file backup method described above.

[0122] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0123] Based on the same inventive concept, this application also provides a file backup apparatus for implementing the file backup method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more file backup apparatus embodiments provided below can be found in the limitations of the file backup method described above, and will not be repeated here.

[0124] In one exemplary embodiment, such as Figure 8 As shown, a file backup device is provided, comprising:

[0125] The file acquisition module 810 is used to acquire the directory to be backed up; the directory to be backed up includes files sorted in file identifier order and files in subdirectories sorted in directory identifier order.

[0126] The task generation module 820 is used to generate multiple backup tasks for each file in the directory to be backed up; the backup tasks are used to back up each file to the server according to the file identifier order and directory identifier order, and generate backup set fragments corresponding to the backup tasks; the backup set fragments are used to write data to the files; the backup tasks are associated with context information; the context information includes the backup progress information of the backup tasks and the backup set fragment information; the backup set fragment information includes the amount of data already written to the files in the backup set fragments.

[0127] The running module 830 is used to run the multiple backup tasks in parallel, periodically generate corresponding backup set checkpoint files at checkpoint times based on the context information of the backup tasks, and upload the backup set checkpoint files to the server; the backup set checkpoint files are used to restore the backup progress of the backup tasks in the event of an interruption.

[0128] In one embodiment, the running module 830 is specifically configured to, in the event of an interruption in the backup task, obtain the backup set checkpoint file corresponding to the backup task from the server; determine, based on the backup set checkpoint file, the checkpoint file identifier and checkpoint directory identifier recorded at the latest checkpoint time; the checkpoint file identifier is the file identifier corresponding to the last backed-up file recorded at the latest checkpoint time; the checkpoint directory identifier is the directory identifier corresponding to the directory being backed up at the latest checkpoint time; traverse the directories containing each file in the directory to be backed up, compare the directory identifiers corresponding to each file in the directory to be backed up with the checkpoint directory identifier, skip backed-up directories, and locate the target directory that matches the checkpoint directory identifier; traverse the files in the target directory, compare the file identifiers of each file in the target directory with the checkpoint file identifier, skip backed-up files, locate the backup interruption position in the directory to be backed up, and resume the backup task at the backup interruption position; the backup interruption position is the file position that matches both the checkpoint directory identifier and the checkpoint file identifier.

[0129] In one embodiment, the running module 830 is specifically used to compare the file identifiers of each file in the target directory with the checkpoint file identifier, determine the file whose file identifier is less than or equal to the checkpoint file identifier as the backed-up file, skip the backed-up file, and locate the backup interruption position in the directory to be backed up.

[0130] In one embodiment, the running module 830 is specifically used to traverse the directories where each file in the directory to be backed up is located; if the target identifier of the currently traversed directory is the parent directory identifier of the checkpoint directory identifier, then the files under the directory corresponding to the parent directory identifier are determined to be backed up files, the directory corresponding to the parent directory identifier is skipped, and the target directory matching the checkpoint directory identifier is determined from the subdirectories contained in the directory corresponding to the parent directory identifier.

[0131] In one embodiment, the running module 830 is specifically configured to: obtain the backup set checkpoint file corresponding to the backup task from the server when the backup task is interrupted; determine the backup set fragment information recorded at the latest checkpoint time based on the backup set checkpoint file; discard the target data in the backup set fragment corresponding to the backup task to obtain the truncated backup set fragment; the target data is the data written to the backup set fragment after the checkpoint time; restore the context information of the backup task to the context information corresponding to the latest checkpoint time based on the backup set checkpoint file; locate the backup interruption position in the directory to be backed up based on the context information corresponding to the latest checkpoint time; and resume the backup task at the backup interruption position to write the unbacked-up files to the truncated backup set fragment.

[0132] In one embodiment, the file acquisition module 810 is specifically used to acquire the backup set checkpoint file corresponding to the backup task from the server; according to the backup set fragment information corresponding to the checkpoint time recorded in the backup set checkpoint file, the target data in the backup set fragment corresponding to the backup task is discarded to obtain the truncated backup set fragment; the target data is the data written to the backup set fragment after the checkpoint time; format data matching the target storage format is written into the backup set fragment to generate a valid storage format file corresponding to the backup set fragment; the target storage format is the storage format of the backup set composed of backup set fragments generated by each backup task; the valid storage format file is used to acquire the files that have been backed up to the server at the checkpoint time in the event that the backup task is interrupted.

[0133] The modules in the aforementioned file backup device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0134] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 9As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When executed by the processor, the computer program implements a file backup method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0135] Those skilled in the art will understand that Figure 9 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0136] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.

[0137] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.

[0138] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0139] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0140] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0141] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0142] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A file backup method, characterized in that, The method includes: Obtain the directory to be backed up; the directory to be backed up includes files sorted by file identifier and files in subdirectories sorted by directory identifier. For each file in the directory to be backed up, multiple backup tasks are generated. Each backup task backs up the files to the server according to the file identifier order and the directory identifier order, and generates a backup set fragment corresponding to the backup task. The backup set fragment is used to write data to the files. Each backup task is associated with context information, including backup progress information and backup set fragment information. The backup set fragment information includes the amount of data already written to the files in the backup set fragment. The multiple backup tasks are run in parallel. At regular intervals, a corresponding backup set checkpoint file is generated at checkpoint times based on the context information of the backup tasks, and the backup set checkpoint file is uploaded to the server. The backup set checkpoint file is used to restore the backup progress of the backup tasks in the event of an interruption. In the event that the backup task is interrupted, the backup set checkpoint file corresponding to the backup task is retrieved from the server. Based on the backup set checkpoint file, determine the backup set fragment information recorded at the latest checkpoint time, discard the target data in the backup set fragment corresponding to the backup task, and obtain the truncated backup set fragment; the target data is the data written to the backup set fragment after the latest checkpoint time; the latest checkpoint time is the time when the backup set checkpoint file is generated for the last time before the backup task is interrupted. Based on the backup set checkpoint file, restore the context information of the backup task to the context information corresponding to the latest checkpoint moment; Based on the context information corresponding to the latest checkpoint time, the backup interruption position in the directory to be backed up is located, and the backup task is resumed at the backup interruption position to write the unbacked-up files to the backup set fragments after the truncation operation.

2. The method according to claim 1, characterized in that, The method further includes: In the event that the backup task is interrupted, the backup set checkpoint file corresponding to the backup task is retrieved from the server. Based on the backup set checkpoint file, determine the checkpoint file identifier and checkpoint directory identifier recorded at the latest checkpoint time; the checkpoint file identifier is the file identifier corresponding to the last backed-up file recorded at the latest checkpoint time; the checkpoint directory identifier is the directory identifier corresponding to the directory being backed up at the latest checkpoint time. Iterate through the directories containing each file in the directory to be backed up, compare the directory identifiers corresponding to each file in the directory to be backed up with the checkpoint directory identifier, skip the backed-up directories, and locate the target directory that matches the checkpoint directory identifier. Traverse each file in the target directory, compare the file identifier of each file in the target directory with the checkpoint file identifier, skip backed-up files, locate the backup interruption position in the directory to be backed up, and resume the backup task at the backup interruption position; the backup interruption position is the file position that matches both the checkpoint directory identifier and the checkpoint file identifier.

3. The method according to claim 2, characterized in that, The step of comparing the file identifiers of each file in the target directory with the checkpoint file identifier, skipping backed-up files, and locating the backup interruption point in the directory to be backed up includes: The file identifiers of each file in the target directory are compared with the checkpoint file identifier. Files whose file identifiers are less than or equal to the checkpoint file identifier are identified as backed-up files. These backed-up files are skipped, and the backup interruption position in the directory to be backed up is located.

4. The method according to claim 2, characterized in that, The step of traversing the directories containing each file in the directory to be backed up, comparing the directory identifiers corresponding to each file in the directory to be backed up with the checkpoint directory identifier, skipping backed-up directories, and locating the target directory matching the checkpoint directory identifier includes: Iterate through the directories containing each file in the directory to be backed up; If the target identifier of the currently traversed directory is the parent directory identifier of the checkpoint directory identifier, then the files under the directory corresponding to the parent directory identifier are determined to be backed up files, the directory corresponding to the parent directory identifier is skipped, and the target directory matching the checkpoint directory identifier is determined from the subdirectories contained in the directory corresponding to the parent directory identifier.

5. The method according to claim 1, characterized in that, The method further includes: Obtain the backup set checkpoint file corresponding to the backup task from the server; Based on the backup set fragment information corresponding to the checkpoint time recorded in the backup set checkpoint file, the target data in the backup set fragment corresponding to the backup task is discarded to obtain the truncated backup set fragment; the target data is the data written to the backup set fragment after the checkpoint time. Write format data matching the target storage format into the backup set fragments to generate a valid storage format file corresponding to the backup set fragments; the target storage format is the storage format of the backup set composed of backup set fragments generated according to each backup task; the valid storage format file is used to retrieve the files that have been backed up to the server at the checkpoint time in the event that the backup task is interrupted.

6. A file backup device, characterized in that, The device includes: The file acquisition module is used to acquire files in the directory to be backed up; The task generation module is used to generate multiple backup tasks for the files in the directory to be backed up; the backup tasks are used to back up the files to the server and generate backup set fragments corresponding to the backup tasks; the backup set fragments are used to write data to the files; the backup tasks are associated with context information; the context information includes the backup progress information of the backup tasks and the backup set fragment information; the backup set fragment information includes the amount of data that has been written to the files in the backup set fragments; The execution module is used to run the multiple backup tasks in parallel, periodically generate corresponding backup set checkpoint files at checkpoint times based on the context information of the backup tasks, and upload the backup set checkpoint files to the server. The backup set checkpoint files are used to restore the backup progress of the backup tasks in the event of an interruption. In the event of an interruption, the module retrieves the backup set checkpoint file corresponding to the backup task from the server. Based on the backup set checkpoint file, the module determines the backup set fragment information recorded at the latest checkpoint time, discards the target data in the backup set fragment corresponding to the backup task, and obtains the truncated backup set fragment. The target data is the data written to the backup set fragment after the latest checkpoint time. The latest checkpoint time is the time when the backup set checkpoint file is last generated periodically before the backup task is interrupted. Based on the backup set checkpoint file, the module restores the context information of the backup tasks to the context information corresponding to the latest checkpoint time. Based on the context information corresponding to the latest checkpoint time, the backup interruption position in the directory to be backed up is located, and the backup task is resumed at the backup interruption position to write the unbacked-up files to the backup set fragments after the truncation operation.

7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.

9. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Data processing method and device and storage medium

    CN114296999A

  • Business processing method and device, computer equipment and storage medium

    CN115439257A

  • Mirror image backup method, device, equipment and system of virtual machine and storage medium

    CN117170932A