A data backup method, electronic equipment, storage medium and chip
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HONOR DEVICE CO LTD
- Filing Date
- 2024-08-09
- Publication Date
- 2026-06-16
AI Technical Summary
During backup, existing data backup methods will upload all the data to be backed up to the cloud server, resulting in a long backup time and large amount of data, which will affect the backup efficiency.
By generating the difference files of the first file list and the second file list, only newly added and modified files are uploaded, avoiding repeated uploads of the same files.
Reduces backup time, improves backup efficiency, and reduces the amount of uploaded data.
Smart Images

Figure CN122228486A_ABST
Abstract
Description
Data backup method, electronic device, storage medium and chip
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on November 23, 2023, with application number 202311582119.X and application name “A data backup method, electronic device, storage medium and chip”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of data backup technology, and in particular to a data backup method, electronic equipment, storage medium, and chip. Background Art
[0003] Data backup is the process of backing up data from an electronic device to another electronic device, other storage media, or a server. Backing up data to a server is also called cloud backup. Due to the larger storage space available on servers, cloud backup is currently the primary method of data backup. Electronic devices can back up data from the same device multiple times. Currently, all data to be backed up in the electronic device is backed up to the cloud server during each backup. This results in large data volumes and long backup times, impacting backup efficiency.
[0004] Summary of the Invention
[0005] The present application provides a data backup method, electronic device, storage medium and chip, which can reduce backup time and improve backup efficiency.
[0006] To achieve the above-mentioned object, the present application provides a data backup method in a first aspect, characterized by comprising:
[0007] The electronic device generates a first file list based on the attribute information of the directory file backed up this time; the electronic device obtains the second file list at the time of the last backup, and the second file list includes the attribute information of the directory file at the time of the last backup; the electronic device obtains the synchronization type of the difference file in the directory file based on the first file list and the second file list, and the synchronization type includes: new addition and / or modification; the electronic device sends the difference file to the cloud server.
[0008] During the current backup, this method obtains the file list of the previous backup, compares the local file list of the previous backup with the local file list of the current backup, finds the new and modified files, and uploads the new and modified files to the cloud server for backup. The same files are no longer uploaded to the cloud server for backup, which reduces the data volume and improves the backup efficiency.
[0009] In combination with the method provided in the first aspect, in some embodiments, the attribute information includes a file type, and the file type includes a large file type; the electronic device obtains the synchronization type of the difference file in the directory file based on the first file list and the second file list, and the method also includes: the electronic device searches for the first large file whose file type is a large file type from the second file list; for each first large file, if the electronic device finds a second large file whose first attribute information is the same as that of the first large file and whose second attribute information is different from that of the first large file from the first file list, the synchronization type of the second large file is determined to be modified; for each first large file, if the electronic device finds a third large file whose first attribute information is the same as that of the first large file and whose second attribute information is the same from the first file list, the synchronization type of the third large file is determined to be identical; the electronic device determines the synchronization type of the fourth large file in the first file list other than the synchronization types of modified and identical as newly added; the difference file modifies the large file and the newly added large file, the modified large file is the large file whose synchronization type is modified, and the newly added large file is the large file whose synchronization type is newly added.
[0010] In combination with the method provided in the first aspect, in some embodiments, the first attribute information includes a file ID and a file path; and the second attribute information includes a hash value.
[0011] In combination with the method provided in the first aspect, in some embodiments, the difference file includes a newly added large file, and the electronic device sends the difference file to the cloud server, including: the electronic device splits the newly added large file to obtain multiple data blocks of the newly added large file; the electronic device sends the multiple data blocks of the newly added large file to the cloud server.
[0012] In combination with the method provided in the first aspect, in some embodiments, the difference file includes a modified large file, and the electronic device sends the difference file to the cloud server, including: the electronic device divides the modified large file to obtain a first set consisting of multiple first data blocks; the electronic device obtains a fifth large file with the same first attribute information as the modified large file from the second file list, and the first large file includes the fifth large file; the electronic device obtains a second set consisting of multiple second data blocks of the fifth large file from the second file list; the electronic device compares the first data block in the first set with the second data block in the second set to obtain the difference data block of the modified large file, and the difference data block includes the modified data block and the newly added data block; the electronic device sends the difference data block of the modified large file to the cloud server.
[0013] In combination with the method provided in the first aspect, in some embodiments, the electronic device segments the modified large file to obtain a first set consisting of multiple first data blocks, including: the electronic device searches for specific characters in the modified large file; the electronic device segments the modified large file from the position corresponding to the specific characters to obtain a first set consisting of multiple first data blocks.
[0014] In combination with the method provided in the first aspect, in some embodiments, the attribute information includes the file type, and the file type includes the small file type; the attribute information also includes the tar package where each small file is located; the electronic device compares the first file list and the second file list to obtain the synchronization type of the difference file in the directory file, including: the electronic device compares the first file list and the second file list to obtain the changed tar package and the first newly added small file; the electronic device calculates the reuse rate of the small files in the changed tar package; for the first changed tar package whose reuse rate is greater than the reuse threshold, the unreused small files in the first changed tar package are used as the second newly added small files; for the second changed tar package whose reuse rate is less than or equal to the reuse threshold, the reused small files and modified small files in the second changed tar package are used as the third newly added small files; the difference files include the first newly added small file, the second newly added small file and the third newly added small file.
[0015] In combination with the method provided in the first aspect, in some embodiments, the electronic device sends a difference file to the cloud server, including: the electronic device packages the first newly added small file, the second newly added small file, and the third newly added small file into at least one new tar package according to the packaging rules; the electronic device sends the new tar package to the cloud server, and the data volume of the new tar package is less than the data volume threshold.
[0016] In combination with the method provided in the first aspect, in some embodiments, the number of small files in the changed tar package in the second file list is the first number; the number of reused small files in the first file list is the second number; and the reuse rate of small files in the changed tar package is the ratio of the second number to the first number.
[0017] In combination with the method provided in the first aspect, in some embodiments, the data amount of the small files in the changed tar package in the second file list is the first data amount; the data amount of the first small files reused in the first file list is the second data amount; and the reuse rate of the small files in the changed tar package is the ratio of the second data amount to the first data amount.
[0018] In combination with the method provided in the first aspect, in some embodiments, the reused first small file is a small file with the same first attribute information and second attribute information; the non-reused small file is a small file with the same first attribute information and different second attribute information, and the first attribute information includes: file name and file path, and the second attribute information includes a hash value.
[0019] In combination with the method provided in the first aspect, in some embodiments, the attribute information includes a file type, and the file type includes an ordinary file type; the electronic device compares the first file list and the second file list to obtain the synchronization type of the difference file in the directory file, including: the electronic device searches for a first ordinary file of an ordinary file type from the second file list; for each first ordinary file, if the electronic device finds a second ordinary file from the first file list that has the same first attribute information as the first ordinary file but different second attribute information, the second ordinary file is determined to be a modified ordinary file; for each first ordinary file, if the electronic device finds a third ordinary file from the first file list that has the same first attribute information and the same second attribute information as the first ordinary file, the third ordinary file is determined to be an identical ordinary file; the electronic device determines the synchronization type of the fourth ordinary file in the first file list other than the synchronization type of modified and identical as newly added; the difference file includes a modified ordinary file and a newly added ordinary file, the modified ordinary file is an ordinary file with a synchronization type of modified, and the newly added ordinary file is an ordinary file with a synchronization type of newly added.
[0020] In combination with the method provided in the first aspect, in some embodiments, the electronic device sending a difference file to the cloud server includes: the electronic device sending a creation request for the first file to the cloud server, the creation request for the first file is used to instruct the cloud server to return a cloud-side unique identifier of the first file if the first file is stored, and return information that there is no first file if the first file is stored, and the first file is a modified ordinary file or a newly added ordinary file; if the electronic device receives information sent by the cloud server that the first file does not exist, the first file is sent to the cloud server; if the electronic device receives a cloud-side unique identifier of the first file sent by the cloud server, the first file is not sent to the cloud server.
[0021] In a second aspect, an electronic device is provided, comprising a processor, wherein the processor is configured to call a computer program stored in a memory to implement any one of the methods of the first aspect of the present application.
[0022] In a third aspect, a chip is provided, comprising a processor, wherein the processor is coupled to a memory, and the processor executes a computer program stored in the memory to implement any method of the first aspect of the present application.
[0023] In a fourth aspect, a computer-readable storage medium is provided, which stores a computer program. When the computer instructions are executed on an electronic device, the electronic device implements any one of the methods of the first aspect of the present application.
[0024] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when running on a device, enables the device to execute any method of the first aspect of the present application.
[0025] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] FIG1 is a schematic diagram of a hardware structure of an electronic device provided in an embodiment of the present application;
[0027] FIG2 is a schematic diagram of an interface of a backup application implementing a cloud backup solution provided in an embodiment of the present application;
[0028] FIG3 is a technical architecture diagram of a cloud backup method provided by an embodiment of the present application;
[0029] FIG4 is a flow chart of a cloud backup method provided in an embodiment of the present application;
[0030] FIG5 illustrates the relationship between application data, application resource files, data snapshots, application metadata, etc. provided in an embodiment of the present application;
[0031] FIG6 is a timing diagram of a backup preparation phase in a cloud backup solution provided by an embodiment of the present application;
[0032] FIG7 is a timing diagram of a data preparation phase in a cloud backup solution provided by an embodiment of the present application;
[0033] FIG8 is a timing diagram of the data cloud migration phase in a cloud backup solution provided by an embodiment of the present application;
[0034] FIG9 is a timing diagram of the backup completion phase in a cloud backup solution provided by an embodiment of the present application;
[0035] FIG10 is a backup method for three types of common files provided by an embodiment of the present application;
[0036] FIG11 is a backup method for three types of large files provided by an embodiment of the present application;
[0037] FIG12 is a backup method for three types of small files provided in an embodiment of the present application;
[0038] FIG13 is a timing diagram of the data preparation phase during secondary backup according to an embodiment of the present application;
[0039] FIG14 is a schematic diagram of a process for determining various types of common files according to an embodiment of the present application;
[0040] FIG15 is a schematic diagram of a large file segmentation method according to an embodiment of the present application;
[0041] FIG16 is a schematic diagram of another large file segmentation method provided by an embodiment of the present application;
[0042] FIG17 is a schematic diagram of a process for determining small file classification according to an embodiment of the present application;
[0043] FIG18 is a schematic diagram of determining small file packaging according to an embodiment of the present application;
[0044] FIG19 is a timing diagram of uploading files to the cloud provided by an embodiment of the present application;
[0045] Figure 20 shows the process of backing up installation package A and installation package B provided in an embodiment of the present application.
[0046] Figure 21 shows the process of restoring the installation package provided in an embodiment of the present application. DETAILED DESCRIPTION
[0047] In the following description, specific details such as specific system structures and technologies are provided for illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details.
[0048] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or collections thereof.
[0049] It should also be understood that in the embodiments of this application, "one or more" refers to one, two, or more than two; "and / or" describes the relationship between associated objects, indicating that three relationships can exist; for example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects are in an "or" relationship.
[0050] In addition, in the description of this application specification and the appended claims, the terms "first", "second", "third", "fourth", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0051] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.
[0052] The present invention provides a data backup method that can be applied to an electronic device to back up data in the electronic device to a cloud server. The electronic device can be a tablet computer, a mobile phone, a wearable device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), or other electronic device. The present invention does not limit the specific type of electronic device.
[0053] Figure 1 shows a schematic diagram of the structure of an electronic device. Electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, antenna 1, antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone jack 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display 194, and a subscriber identification module (SIM) card interface 195. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0054] It should be understood that the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0055] The processor 110 may include one or more processing units, for example: the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units can be independent devices or integrated into one or more processors. For example, the processor 110 is used to execute the cloud backup method in the embodiment of the present application.
[0056] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 110. If processor 110 needs to use the same instruction or data again, it can directly retrieve it from the memory. This avoids duplicate accesses, reduces processor 110 latency, and thus improves system efficiency.
[0057] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes the instructions stored in the internal memory 121 to execute various functional applications and data processing of the electronic device 100. The internal memory 121 can include a program storage area and a data storage area.
[0058] In addition, the internal memory 121 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. Application data, application resource index files, etc. in the embodiments of the present application can be stored in the internal memory.
[0059] The touch sensor 180K is also called a "touch panel". The touch sensor 180K can be set on the display screen 194. The touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, at a different position from the display screen 194. For example, the operations in the cloud backup interface provided in the embodiments of the present application, etc.
[0060] Electronic device 100 implements display functionality through a GPU, display screen 194, and an application processor. A GPU is a microprocessor for image processing that connects display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or modify display information.
[0061] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include one or N display screens 194, where N is a positive integer greater than 1. For example, the interface shown in FIG. 2 in the embodiment of the present application is displayed by a display.
[0062] The embodiments of the present application do not particularly limit the specific structure of the execution subject of a data backup method; as long as the code recording the data backup method of the embodiments of the present application can be executed to communicate according to the data backup method provided by the embodiments of the present application. For example, the execution subject of the data backup method provided by the embodiments of the present application can be a functional module in an electronic device that can call and execute a program, or a communication device used in an electronic device, such as a chip.
[0063] Data backup is the process of backing up data from an electronic device to another electronic device, other storage media, or a server. Backing up data to a server is also called cloud backup. Due to the larger storage space available on servers, cloud backup is currently the primary method of data backup. Electronic devices can back up data from the same device multiple times. Currently, each backup process involves backing up all data to be backed up from the electronic device to a cloud server. This can result in large amounts of data and long backup times, impacting backup efficiency.
[0064] An embodiment of the present application provides a cloud backup solution, which backs up all the data selected by the user to the cloud server when the device is backed up for the first time or when the cloud server does not store the historical backup records of the device (for example, the backup records of the device and the backup data stored in the cloud server are cleared). During subsequent backups, after generating the local file list for this backup, the local file list for this backup and the local file list for the last backup are compared to obtain some difference files, which are files other than the same files. Exemplarily, the difference files include: newly added files, modified files, and deleted files, wherein deleted files in the difference files do not need to be backed up; newly added files in the difference files need to be backed up; modified files in the difference files generally also need to be backed up, but identical files do not need to be backed up, so there is no need to back up a large number of identical files, thereby improving backup efficiency.
[0065] In order to more easily understand the backup process during re-backup provided in the embodiment of the present application, the backup solution provided in the embodiment of the present application is first described.
[0066] 2 is a schematic diagram of an interface of a backup application for implementing a backup solution provided in an embodiment of the present application. Users can back up and restore data through the backup application.
[0067] It should be noted that this interface diagram is only used to illustrate the following: this interface can be used to set the frequency of automatic backups for the electronic device, can be used to select backup data, and can also include an immediate backup control 11. The electronic device can initiate cloud backup after receiving a user click operation corresponding to the immediate backup control 11. In actual applications, different interfaces can be set from Figure 2, or the above content can be displayed through multiple interfaces.
[0068] In specific implementation, the user can open the backup application through the account center in the electronic device to display the interface shown in (a) in Figure 2, or can open the interface shown in (a) in Figure 2 through the application icon of the backup application displayed on the system desktop of the electronic device, or can open the interface shown in (a) in Figure 2 through other methods.
[0069] The electronic device can automatically start data backup, a process that can be called automatic backup. In the interface shown in (a) of Figure 2, the frequency of automatic backup can be set, for example, once every 7 days, once every 3 days, once every day, etc. The user can display multiple backup frequency options through the control 12 in the interface, and the user selects one of the options to set the frequency of automatic backup. For example, Figure 2 sets an automatic backup every 7 days. Of course, in actual application, the user can turn automatic backup on or off through control 13. The state of control 13 shown in the figure is that automatic backup is turned on.
[0070] In the interface shown in (a) of Figure 2 , the user can also select backup data. The user clicks the backup data setting control 14 shown in (a) of Figure 2 to enter the backup data setting interface shown in (b) of Figure 2 .
[0071] The backup data setting interface displays multiple data entries: system data (for example, system settings, alarm settings, input method settings, etc.), desktop layout, gallery, contacts, notes, and instant messaging applications. The user can select specific backup data. For example, turning on the control 15 corresponding to the system data entry indicates that the backup process needs to back up the system data; not turning on the control 16 corresponding to the note entry indicates that the backup process does not need to back up the data of the note application. Referring to Figure 2, the controls corresponding to the system data, desktop layout, gallery, contacts, and instant messaging applications are all turned on, and the controls corresponding to the notes are all turned off. The electronic device can perform data backup on the system data, desktop layout, gallery, contacts, and instant messaging application data, but not on the note application data. In this example, the system data, desktop layout, gallery, contacts, and instant messaging application data can also be referred to as the backup data set by the user. After the user sets the backup data, he can trigger the electronic device to display the interface shown in (a) of Figure 2 through gesture operation.
[0072] In the interface shown in (a) of Figure 2, the user can trigger the electronic device to perform data backup by clicking the backup now control 11. This process can be called manual backup.
[0073] Of course, the electronic device may also automatically trigger the backup data set by the user to be backed up based on the set automatic backup frequency.
[0074] Refer to Figure 3, which is a technical architecture diagram of the backup method provided in an embodiment of the present application. This technical architecture diagram involves a cloud server and an electronic device. The backup server and the file storage server can also be deployed on the same server.
[0075] The cloud server includes a backup server and a file storage server. The backup server and the file storage server can be two independent servers.
[0076] The backup server stores backup records and application metadata for each device. The backup records include the backup ID, backup time, and backup size of each device during cloud backup. A device can perform multiple data backups, so the backup server also records the backup ID, backup time, and backup size of each backup performed by the same device. Application metadata records information about each application in the backup data configured by the user (for details, refer to the description of the following embodiments).
[0077] The file storage server is used to store the actual files of each backed up application, such as the application's database, installation package, audio, video, documents, and pictures.
[0078] In actual applications, the backup server is used to communicate with the electronic device to perform the backup process. The backup server can store the actual files uploaded by the electronic device in the file storage server. The subsequent embodiments of this application uniformly describe the backup process with a cloud server.
[0079] The electronic device includes a backup application and other applications. The backup application is an application used to implement the backup process, and the other applications are applications in the backup data set by the user (for example, the gallery application, contact application and instant messaging application shown in (b) of Figure 2).
[0080] Backup applications include backup services and recovery services, as well as modules that support these services (e.g., data replication and recovery modules, file upload and download modules, and status detection modules).
[0081] Among them, the backup service is used to upload data in the electronic device to the cloud server, and the recovery service is used to download data from the cloud server and restore the data to the electronic device.
[0082] The data copy and recovery module includes a data copy module and a data recovery module; the file upload and download module includes a file upload module and a file download module; the status detection module is used to monitor the network status of the electronic device (for example, whether it is connected to a wireless LAN), storage status (for example, whether the local storage space is sufficient to cache the data to be backed up, whether the cloud server has enough space to back up data), screen status (for example, whether the screen is locked) and charging status (for example, whether the power is sufficient, whether it is connected to an external power supply), etc.
[0083] The backup service includes a data caching module, a data processing module, and a data upload module. The data caching module calls the data replication module to cache the data to be backed up. The data processing module processes the cached data to be backed up, for example, assembling small files or fragmenting large files, and generating data snapshots based on this data to be backed up. The data upload module calls the file upload module to upload the processed data to the cloud server.
[0084] The recovery service includes a data download module, a data processing module, and a recovery execution module. The data download module is used to call the file download module to download data from the cloud server; the data processing module is used to decompress, assemble, and delete the downloaded data; and the recovery execution module is used to restore the processed data to the original directory.
[0085] Of course, the above cloud backup process can back up system data, system applications, and third-party applications. When backing up third-party applications, it is necessary to implement it through the PMS (package manager service) or BMS (backup manager service) of the Framework layer. PMS or BMS can provide the ability to read the data directory generated by the running third-party applications.
[0086] Furthermore, in a specific implementation, the electronic device can store file scanning rules corresponding to each application (excluding backup applications). The file scanning rules for each application record the backup directory and prohibited backup directory corresponding to that application. In actual use, the backup service backs up files in the backup directory to the cloud server, but does not back up files in the prohibited backup directory to the cloud server. For example, it backs up chat history of an instant messaging application but does not back up log files generated during the operation of the instant messaging application.
[0087] 4 , which is a flow chart of a cloud backup method according to an embodiment of the present application.
[0088] The cloud backup method consists of three major phases: backup preparation, backup execution, and backup completion. During the backup preparation phase, the status detection module performs environmental detection. For example, the status of the electronic device is detected to determine whether the device meets the backup requirements. The remaining storage space of the electronic device and the remaining storage space of the personal account on the cloud server are also detected to determine whether the remaining storage space of the electronic device is sufficient to cache backup data, and whether the remaining storage space of the personal account on the cloud server is sufficient to back up data. If the device status detection meets the backup requirements and there is sufficient storage space, a backup ID for the current cloud backup of the electronic device is requested from the cloud server.
[0089] The backup execution phase includes the data preparation phase and the data cloud migration phase. The data cloud migration phase includes the application data (such as the directory file mentioned above) upload phase, the application resource file upload phase, and the backup completion phase (for uploading metadata data).
[0090] First, you need to cache the application data during the data preparation phase, generate a data snapshot (i.e., data preparation), and then upload the application data to the cloud server (i.e., data on the cloud). In actual applications, if the data being backed up includes data from multiple applications (for example, application A, application B, and application C), you need to first prepare data for one application and upload that application's data to the cloud server; after uploading the previous application's data to the cloud server, prepare data for the next application and upload the next application's data to the cloud server; and repeat this process until all data from multiple applications has been uploaded to the cloud server. Of course, in actual applications, you can also complete the data preparation for multiple applications and then upload the data for each application to the cloud server in turn.
[0091] In the embodiment of the present application, one of the applications A is used as an example to describe the data preparation process and the data cloud upload process. The electronic device reads the directory of the application selected by the user for backup through PMS or BMS, and caches the application data (for example, chat records, pictures, videos, audio, documents, etc.) read from the application directory in a temporary storage space; then the cached application data is processed to generate a data snapshot (see the explanation below for details). After generating the data snapshot of application A, the electronic device can upload the application data of application A to the cloud server (i.e., the application data upload phase). After uploading the application data, the electronic device also needs to upload the application resource files (for example, the data snapshot, installation package and icon of application A, etc.) to the cloud server (i.e., the application resource file upload phase). After the application resource files of application A are uploaded, the electronic device can upload the metadata (meta) of application A to the cloud server (i.e., the meta data upload phase, which is the backup completion phase). The metadata of application A includes: relevant information about the data snapshot of application A, relevant information about the application installation package, relevant information about the application icon, etc. In actual applications, some application resource files can be uploaded, and accordingly, the metadata can also be relevant information about some application resource files.
[0092] In the backup completion phase: after confirming that the backup of all applications (for example, application A, application B, and application C) is complete, the overall backup is complete.
[0093] To facilitate understanding of the professional terms in the above backup execution phase, referring to FIG. 5 , the relationship between application data, application resource files, data snapshots, application metadata, etc. is described.
[0094] Application data includes files to be backed up obtained by scanning the application directory. Taking an instant messaging application as an example, the data of the instant messaging application includes chat records, pictures, videos, audio, documents and other data.
[0095] Data snapshots are generated from application data and record some information about these application data (see Tables 1 and 2 for details). Application A's data snapshot is constructed from two tables, one of which is a list of local files (see Table 1) and the other is a list of cloud files (see Table 2).
[0096] The local file list is used to record information about files in application data (e.g., application ID, file size, hash value, modification time, whether there are changes, file type, etc.), as well as some information about these files in the electronic device (e.g., local file path, local unique identifier of the file, etc.).
[0097] Table 1 is the local file list app_data_detail provided in the embodiment of this application
[0098] The cloud file list is used to record the information of the files in the application data (for example, application ID, file size, hash value, etc.), as well as some information of these files in the cloud server (for example, download path on the cloud side, unique identifier on the cloud side).
[0099] Table 2 is the upload_app_data_detail list of files uploaded to the cloud provided in the embodiment of the present application
[0100] Application resource files include: data snapshots, application installation packages, application icons, and application backup instructions. Application backup instructions include: application installation package version, electronic device system version at the time of backup, and other information.
[0101] The application metadata records: information related to data snapshots, information related to the application installation package, information related to the application icon, information related to the application backup instructions, etc.
[0102] As an example of applying metadata.
[0103] It can be understood that the application metadata includes snapshot (data snapshot) related information, apk (application installation package) related information, info.xml (application backup description) related information, and icon (application icon) related information.
[0104] After describing the above professional terms, the cloud backup solution provided by the embodiment of the present application is described in detail below.
[0105] As shown in FIG4 , the cloud backup solution includes: a backup preparation phase, a data preparation phase, a data cloud upload phase (including an application data upload phase and an application resource file upload phase), and a backup completion phase.
[0106] The cloud backup solution described above is described below using Figures 6 to 11. Figure 6 is a timing diagram of the backup preparation phase of the cloud backup solution. Figures 7 and 8 illustrate specific implementations of environmental status detection during the backup preparation phase shown in Figure 6. Figure 9 is a timing diagram of the data preparation phase of the cloud backup solution. Figure 10 is a timing diagram of the data cloud upload phase of the cloud backup solution. Figure 11 is a timing diagram of the backup completion phase of the cloud backup solution.
[0107] First, the sequence diagram of the backup preparation phase shown in FIG. 6 will be described.
[0108] As shown in Figure 2, the frequency of automatic cloud backup can be set through the backup application, and the data of the applications that need to be backed up can be set. The backup application can generate an application list (excluding the note ID) according to the interface shown in (b) in Figure 2. Therefore, the cloud backup frequency and application list are recorded in the backup application, and the application ID of this backup is recorded in the application list. When the time corresponding to the cloud backup frequency is reached, the electronic device will execute the subsequent cloud backup process; similarly, when the electronic device receives a click operation on the control 11, the electronic device will also execute the subsequent cloud backup process. The embodiment of the present application describes the above-mentioned cloud backup solution by taking the data backup of application A as an example. In the specific implementation, after the backup of application A is completed, the next application is backed up.
[0109] S101: When the backup service reaches the automatic backup time point or receives a manual backup operation, the backup service sends an environment status acquisition request to the status detection module.
[0110] In the embodiments of the present application, backup conditions are set for both manual and automatic backup. The backup conditions include various states of the electronic device, such as network status (access to a wireless LAN), battery status (the battery level of the electronic device is greater than 10%), storage space status (for example, the remaining storage space of the electronic device is greater than 5G), etc. Of course, in actual applications, in order to prevent the backup process from being interrupted, more backup conditions can be set, for example, the remaining storage space of the personal space in the cloud server can be greater than 5G, etc.
[0111] It should be noted that the figures such as 10% and 5G are only used as examples and do not limit the present application in any way. The subsequent embodiments of the present application will respectively describe in detail the backup conditions of automatic backup and manual backup, and each state in the above backup conditions can be obtained by the state detection module.
[0112] S102: After receiving the device status acquisition request, the status detection module detects the device status.
[0113] The environmental status is related to pre-set backup conditions, such as the power status, screen status, remaining storage space and network status of the electronic device.
[0114] In actual applications, during automatic backup, the status detection module detects multiple environmental states related to the backup conditions of automatic backup; during manual backup, the status detection module detects multiple environmental states related to the backup conditions of manual backup. For details, please refer to the description of subsequent embodiments.
[0115] S103: The status detection module sends the detected environment status to the backup service.
[0116] Exemplarily, the device status is: connected to a wireless LAN, connected to an external power supply, the remaining storage space of the electronic device is greater than 5G (it can also be the remaining storage space of a specific electronic device), and the screen is locked.
[0117] S104: After receiving the environment status sent by the status detection module, the backup service determines that the environment status meets the backup condition.
[0118] Exemplarily, the conditions for automatic cloud backup include: access to a wireless local area network, connection to an external power source, local remaining storage space being greater than a threshold, and screen lock. It can be determined that the device status received in S103 meets the automatic cloud backup conditions.
[0119] In actual applications, the backup service can send an environmental status acquisition request to the status detection module to instruct the status detection module to detect the environmental status. In actual applications, the backup service can also send multiple different environmental status detection instructions to the status detection module. Different environmental status detection instructions correspond to different detection contents. For example, the power status detection instruction is used to detect the power status; the screen status detection instruction is used to detect the screen status.
[0120] S105: When the device status meets the backup conditions, the backup service sends a backup ID application request to the cloud server.
[0121] As mentioned above, different devices have different backup IDs. Therefore, each time you apply for a backup ID, you need to carry the unique identifier of the device. For example, the MAC address of the device can be used as the unique identifier.
[0122] S106: After receiving the backup ID application request, the cloud server generates a backup ID for this cloud backup according to the device unique identifier.
[0123] In actual applications, when generating a backup ID, the backup ID and historical backup ID of the same device each time a backup is performed are different. Therefore, other parameters may also be combined when generating the backup ID, such as the time of the current backup.
[0124] S107, the cloud server sends the generated backup ID to the backup service.
[0125] S108 , when the backup service determines that the device status meets the backup conditions, the backup service may also send an environment monitoring request to the status detection module.
[0126] Only when the current status meets the requirements for automatic backup will the device status monitoring instruction be sent to the status detection module to instruct the status detection module to continue monitoring the device status. Similarly, the backup service can send one monitoring request to the status detection module, or it can send multiple device status monitoring requests to the status detection module. Different environmental monitoring requests correspond to different monitoring contents.
[0127] S109: After receiving the device status monitoring request, the status detection module starts monitoring the device status.
[0128] In the embodiment of the present application, the status detection module detects the device status to obtain the device status at that time; the status detection module monitors the device status to detect the device status in real time according to a certain time period.
[0129] S110: The backup service receives monitoring start information sent by the status detection module.
[0130] In the above embodiment, there is no strict order between the backup service executing step S105 and executing step S108. The backup service may also execute step S108 first and then execute step S105.
[0131] S111 , after receiving the backup ID, the backup service establishes a correspondence between the application list and the backup ID.
[0132] S112: The backup service updates the backup phase of each application in the backup data table to an initial state.
[0133] The cloud backup solution provided by the embodiment of the present application performs backup from the application dimension. The backup service backs up the applications in the backup list in sequence, that is, the backup of one application will not be backed up until the next application is backed up. The embodiment of the present application sets up a backup data table for each application, and the backup data table records the backup stage of the application; therefore, in the event of a backup interruption, the backup service can check the backup data table of each application in the backup list to determine which applications have been backed up (for example, the backup stage is backup completed) and which applications have not yet been backed up (for example, the backup stage is initial state).
[0134] Furthermore, in real-world applications, a backup of an application may be interrupted during the backup process. To resume the interrupted application backup, the backup execution process for a single application can be divided into several more detailed backup phases: data preparation phase, application data upload phase, application resource file upload phase, and application backup completion phase. Corresponding status identifiers are set for each backup phase. For example, data preparation phase completion is marked as 10; application data upload completion is marked as 20; application resource file upload completion is marked as 30; and backup completion is marked as 200. Of course, before backing up an application, the backup phase must be initialized to its initial state, which can be represented by the character "0."
[0135] After each backup phase is completed, the status indicator is updated in the application's backup data table. If a backup is interrupted, the status indicator recorded in the application's backup data table can be used to determine which phases of the current application backup process have been completed and from which phase the subsequent backup process should be continued. The application's backup data table can be shown in Table 3.
[0136] Table 3 Application backup data table cbk_backup_app_info
[0137] After step S111, the backup data table records the state identifier corresponding to the initial state in the stage of each application. Subsequently, the backup service can back up the data related to each application to the cloud server in sequence according to the recorded application list.
[0138] In actual applications, a backup data table may be set for each application, or information of multiple applications may be recorded in the form of entries in one backup data table.
[0139] In the example shown in Figure 6, during the backup preparation phase, the backup service needs to determine whether the backup conditions are currently met through the status detection module. Similarly, during the backup process, the backup service also needs to monitor the device status through the status detection module to interrupt the backup if the device status is not suitable for continuing the backup.
[0140] The embodiment of the present application sets the backup conditions that the device status needs to meet during automatic backup; it also sets the backup conditions that the device status needs to meet during manual backup.
[0141] For example, conditions for automatic cloud backup include: connecting to an external power source, locking the screen, connecting to a wireless LAN, remaining local storage space exceeding a threshold, or remaining storage space in the personal account exceeding a threshold. Conditions for manual backup include: connecting to a wireless LAN, battery level exceeding 10%, remaining local storage space exceeding a threshold, or remaining storage space in the personal account exceeding a threshold. Of course, the above examples are merely illustrative.
[0142] As shown in Figure 6, after the backup preparation phase, the backup phase for each application in the data table returns to its initial state. The backup service will subsequently back up each application's data to the cloud server based on the application list for this backup. The following describes the data preparation phase of backing up one application (for example, Application A).
[0143] 7 , which is a timing diagram of the data preparation phase of the data backup process of application A provided in an embodiment of the present application.
[0144] S401: The backup service reads the file scanning rule of application A.
[0145] In an embodiment of the present application, the configuration file (json file) can record file scanning rules for one or more applications, wherein the file scanning rules record the backup directory and the prohibited backup directory of the application. The backup service can upload files in the backup directory to the cloud server, but will not upload files in the prohibited backup directory to the cloud server.
[0146] In actual applications, different file scanning rules can be set for different applications, the same file scanning rules can be set for the same type of applications, or the same file scanning rules can be set for all applications.
[0147] S402: The backup service sends a scanning instruction for the directory files of application A to the data replication and recovery module. The scanning instruction carries a file scanning rule of application A.
[0148] An exemplary scanning instruction may carry a backup directory and a prohibited backup directory of application A.
[0149] During specific implementation, the backup service may call the data replication module in the data replication recovery module to scan the directory of application A through the data replication module.
[0150] As an example, sdcard / picture / xxx.xxx.xxx / is the backup directory, and / data / data / xxx.xxx.xxx / file / b3d74ae13647da4b7f8b259c376834 / attachment / .ref / d / eda84554-7892-4124-8f1d-7f69d38fcebd is the prohibited backup directory.
[0151] S403: After receiving the scanning instruction of the directory file of application A, the data copy recovery module obtains the number of files and file information in the backup directory of application A according to the file scanning rule of application A.
[0152] As an example of file information, the file information includes: file path, file name, file size, and file hash value.
[0153] sdcard / picture / xxx.xxx.xxx, mmexport1699003060871.mp4, 15.32MB, ngreht8dhge47tgdtgh;
[0154] / android / data / xxx.xxx.xxx / file / e2b13889818aa6a711935f5481405139 / music, piecebc16b1ac66e102953d7397dccd0002e2, 3.35MB, ithdbght246bgdg.
[0155] In this process, the data replication module in the data replication recovery module traverses the backup directory of application A through the BMS or PMS, thereby copying all files in the backup directory of application A. These are obtained through the backup directory and can also be recorded as directory files.
[0156] S404: The data replication recovery module obtains the application A file information.
[0157] S405: The data replication recovery module sends the file information to the backup service.
[0158] S406: After receiving the file information, the backup service records the file information of application A in the local file list of the data snapshot of application A. In this step, the scanned information related to the application data of application A is recorded in the local file list of the data snapshot.
[0159] As an example of a local file list (application ID, number of files, file path, file name, file size, file hash value):
[0160] dsgrbgfd,1,sdcard / picture / xxx.xxx.xxx,mmexport1699003060871.mp4,15.32MB,ngreht8dhge47tgdtgh;
[0161] dsgrbgfd,1, / android / data / xxx.xxx.xxx / file / e2b13889818aa6a711935f5481405139 / music,piecebc16b1ac66e102953d7397dccd0002e2,3.35MB,ithdbght246bgdg.
[0162] S407: The backup service sends an acquisition instruction to the data replication and recovery module. The acquisition instruction carries relevant information of each file.
[0163] The relevant information may be information used to find the file, such as a file path.
[0164] S408: After receiving the acquisition instruction, the data replication recovery module acquires the file from the directory of application A according to the file information.
[0165] Among them, copying is only one way of obtaining, and in actual application, it can also be cut. For example, in order to save storage space, some files in the gallery application can be cut and uploaded to the cloud server. S409, the data copy recovery module obtains the file from application A.
[0166] S410: The data replication recovery module sends the files of application A to the backup service.
[0167] S411: After receiving the file from application A, the backup service processes the file of application A to obtain one or more cloud-uploaded files of application A.
[0168] As an example of processing, a file with a large amount of data can be divided into small data blocks, and the small data blocks are used as cloud-uploaded files; or multiple files with small data amounts can be packaged, and the packaged files are used as cloud-uploaded files.
[0169] In actual applications, the data copy recovery module can also be used to directly package or split these files when copying them. The embodiment of the present application does not limit the specific modules for implementing packaging and splitting.
[0170] S412: The backup service updates some basic information in the cloud file list of the data snapshot according to each cloud file.
[0171] For example, write the application ID, local unique identifier, number of files, file size, hash value, etc.
[0172] S413: The backup service updates the backup data table of application A and indicates that the backup phase is data preparation completed.
[0173] For example, the backup data table records in sequence: backup ID, application ID, backup stage; fenegfhhgdg, 5ffd64w9, 10; wherein fenegfhhgdg is the backup ID, 5ffd64w9 is the application ID, and 10 indicates that the data preparation stage is completed.
[0174] 8 , which is a timing diagram of the data cloud upload phase during the backup process of application A provided in an embodiment of the present application, the data cloud upload phase includes an application data upload phase, an application resource file upload phase, and a backup completion phase.
[0175] In the embodiment of the present application, the basic information of the generated cloud-uploaded files is already stored in the cloud-uploaded file list. After any cloud-uploaded file is backed up to the cloud server, the cloud server will return relevant information about the cloud-uploaded file on the cloud server, such as the cloud-side unique identifier of the cloud-uploaded file. The electronic device writes the cloud-side unique identifier of the cloud-uploaded file into the cloud-uploaded file list. Therefore, by traversing the cloud-uploaded file list, cloud-uploaded files without cloud-side unique identifiers can be obtained, thereby uploading each cloud-uploaded file in the cloud-uploaded file list to the cloud server.
[0176] S501, after the backup service updates the backup data table of data A and the backup phase is completed, it traverses the cloud file list in the data snapshot of application A to obtain the file ID of the cloud file without the cloud-side unique identifier.
[0177] S502: The backup service sends a file upload instruction to the file upload and download module. The file upload instruction carries a file in the cloud file list that does not have a unique cloud-side identifier, or a cache address of a file in the cloud file list that does not have a unique cloud-side identifier. The file upload instruction may also carry the file ID of the file.
[0178] Alternatively, the file upload instruction may carry the file ID of the file to be uploaded to the cloud, instead of the file itself.
[0179] The backup service can obtain the cloud file from the cache space based on the file ID and send it to the file upload and download module.
[0180] This process can call the file upload module in the file upload and download module.
[0181] S503: After receiving the file upload instruction, the file upload and download module uploads the cloud files without the cloud-side unique identifier in the cloud file list to the cloud server.
[0182] S504: After receiving the cloud-uploaded file, the cloud server generates cloud-uploaded information.
[0183] The cloud upload information is used to update various information in the cloud upload file list, such as the unique identifier of the cloud server and / or the storage path of the cloud server.
[0184] S505: The cloud server sends cloud upload information to the file upload and download module.
[0185] S506: After receiving the cloud upload information, the file upload and download module sends the cloud upload information to the backup service.
[0186] S507: After receiving the cloud upload information, the backup service writes the cloud upload information (including the cloud-side unique identifier) of the uploaded file into the cloud upload file list.
[0187] In this step, you also need to write the cloud-side unique identifier in the cloud information into the reference of the local file list.
[0188] The process of step S501 to step S507 is repeated until each cloud-uploaded file of application A recorded in the cloud-uploaded file list is uploaded to the cloud server. After each cloud-uploaded file of application A recorded in the cloud-uploaded file list is uploaded to the cloud server, each cloud-uploaded file of application A in the cloud-uploaded file list has a unique identifier on the cloud side.
[0189] S508: After the backup service determines that all the cloud-uploaded files in the cloud-uploaded file list have cloud-side unique identifiers, it updates the backup phase in the backup data table of application A to indicate that the application data upload is complete.
[0190] Exemplarily, the information of application A recorded in the backup data table is: xxx(backup ID).xxx(application ID).20.
[0191] S601 , the backup service reads the application resource file of application A after the backup phase in the backup data table of application A is updated to indicate that the application data upload is completed.
[0192] In the embodiment of the present application, the application resource file of application A includes a data snapshot, an installation package, an icon, and an application backup description.
[0193] In the specific implementation, it is also necessary to upload one application resource file before uploading the next application resource file.
[0194] S602: The backup service sends a file upload instruction to the file upload and download module. The file upload instruction carries an application resource file or a storage address of an application resource file.
[0195] S603: After receiving the file upload instruction, the file upload and download module sends the application resource file to the cloud server.
[0196] S604: After receiving the application resource file, the cloud server generates cloud migration information based on the application resource file. The cloud migration information also includes a unique identifier for the application resource file.
[0197] S605: The cloud server sends the cloud upload information of the application resource file to the file upload and download module.
[0198] S606: After receiving the cloud upload information, the file upload and download module sends the cloud upload information to the backup service.
[0199] The process from step S601 to step S606 is performed in a loop until each application resource file is uploaded to the cloud server.
[0200] S607 , after confirming that the backup service has received the cloud-side unique identifier of each application resource file, it updates the backup phase in the backup data table of application A to indicate that the application resource file upload is complete.
[0201] In this embodiment of the present application, the number of application resource files is relatively small. Even if the cloud server does not receive an application resource file, it will still send the cloud-side unique identifier of the application resource file to the backup service. Therefore, the backup service can determine which application resource files have been uploaded and which have not been uploaded based on the received cloud-side unique identifier, and thus upload each application resource file to the cloud server.
[0202] S701 , after the backup service updates the backup data table of application A and the application resource file upload is completed, metadata of application A is generated according to the cloud information of the application resource file of application A.
[0203] S702 , the backup service sends a backup completion confirmation request of application A to the cloud server, where the request carries metadata of application A.
[0204] S703: After receiving the request, the cloud server compares the stored application resource files and metadata of application A and determines that the backup of application A is complete.
[0205] S704: The cloud server sends information indicating that the backup of application A is complete to the backup service.
[0206] S705 , after receiving the backup completion information of application A from the cloud server, the backup service updates the backup stage in the backup data table of application A to backup completion.
[0207] After step S705, the backup of application A in the application list is completed, and the data of other applications in the application list can be backed up according to the data backup process of application A. For example, the process shown in Figures 9 and 10 is executed to continue to back up the data of application B. If this backup process also includes more applications, Figures 9 and 10 are executed cyclically to back up other applications to the cloud server. This embodiment of the present application will not be repeated.
[0208] After backing up each application in the application list, it is necessary to execute the timing diagram of the backup completion phase shown in FIG9 .
[0209] S801: The backup service checks that the backup phase in the data table of each application in the application list is complete.
[0210] S802: The backup service sends a request to the cloud server to confirm the completion of the overall backup. The request carries an application list.
[0211] S803: After receiving the overall backup completion confirmation request, the cloud server compares the received application list with the stored application metadata to confirm that the overall backup is complete.
[0212] S804: The cloud server sends information indicating that the overall backup is complete to the backup service.
[0213] S805: The backup service deletes the cached data.
[0214] The cached data deleted by the backup service can be the application data of each cached application. In actual applications, the cached data of each application can be deleted after the backup is completed, thereby saving cache space; or all cached data can be deleted after the backup is completed for all applications. The embodiments of this application do not limit the specific implementation method.
[0215] S806: Generate a backup completion mark. After S806, the backup process ends.
[0216] In the above backup process, the backed up application data can be divided into three categories according to file size: ordinary files, small files and large files.
[0217] Ordinary files are data with a file size between 2 and 500 MB, such as database files of system applications, recordings, videos, etc.
[0218] Small files are data with a file size less than 2M, for example, some data generated during the operation of communication applications are large in quantity.
[0219] An oversized file is a file larger than 500MB, such as the database file of an instant messaging application.
[0220] Of course, the above division method is only used as an example. In actual applications, other data sizes can be selected as the basis for distinguishing different types of files. For example, 5M and 1G are used to distinguish small files, ordinary files and large files.
[0221] There are some differences in the backup methods for different types of files. The following describes the backup methods for common files, small files, and large files respectively.
[0222] 10 shows a common file backup method provided by an embodiment of the present application.
[0223] For common files, by comparing the files in the local file list of the current backup with the files in the local file list of the previous backup, the files in the local file list of the current backup can be classified as identical common files, identical common files, and identical common files. Different types of files have different backup policies.
[0224] Identical files: The information recorded in the local file list during the previous backup is consistent with the information recorded in the local file list during the current backup. For example, the file path, file size, file modification time, hash value, etc. are all the same. These identical files do not need to be backed up this time.
[0225] Newly added common files: Common files that did not exist in the local file list during the previous backup but exist in the local file list during the current backup.
[0226] Modifying ordinary files: The information recorded in the local file list during the previous backup and the information recorded in the local file list during the current backup is partially consistent (for example, the application ID, file path, and file name are consistent), but some information is inconsistent (for example, the file modification time, file size, and file hash value are inconsistent).
[0227] In actual applications, newly added ordinary files and modified ordinary files may also exist on the cloud server. For example, file A during the second backup is determined to be a newly added ordinary file. During the second backup, file A is uploaded to the cloud server. Then, the user deletes the local file A. During the third backup, file A is determined to be a deleted ordinary file and is not uploaded. Then, the user writes file A to the electronic device again. During the fourth backup, file A is determined to be a newly added ordinary file. However, during the fourth backup, file A may no longer be backed up, but may be reused through the cloud server.
[0228] 11 , which shows a method for backing up large files according to an embodiment of the present application.
[0229] For large files, by comparing the files in the local file list of this backup with the files in the local file list of the previous backup, the files in the local file list of this backup can be divided into the same large files, modified large files, and newly added large files. Different types of files have different backup policies.
[0230] Identical large files: The information recorded in the local file list during the previous backup is consistent with the information recorded in the local file list during the current backup. For example, the file path, file size, file modification time, hash value, etc. are all the same. These identical large files do not need to be backed up this time.
[0231] Newly added large files: Large files that did not exist in the local file list during the previous backup but exist in the local file list during the current backup.
[0232] Modified large files: The local file list recorded in the last backup and the local file list recorded in the current backup have some consistent information (for example, the application ID, file path, and file name), but some inconsistent information (for example, the file modification time, file size, and file hash value).
[0233] The above process of distinguishing the same large files, adding new large files and modifying large files can refer to the process of distinguishing the same ordinary files, adding new ordinary files and modifying ordinary files described in the above embodiment, and this application will not repeat them.
[0234] For large files, it is relatively rare to add new large files or modify large files that are already stored on the cloud server, so whether the cloud server already exists is no longer a consideration. However, the data volume of a single large file is large, and the cloud upload process consumes a lot of network bandwidth and has low backup efficiency. If an interruption occurs, it will need to be uploaded again. Therefore, the embodiment of the present application divides the large file into multiple data blocks and uploads the multiple data blocks obtained by segmentation to the cloud server separately.
[0235] For a newly increased file in a large file, it can be split into multiple data blocks, and then the multiple data blocks are backed up.
[0236] For modified large files, they can also be split into multiple data blocks. For the same large file, the multiple data blocks split during the last backup are compared with the multiple data blocks split during the current backup. The data blocks that have not changed are not backed up and reused, and the data blocks that have changed are backed up, thereby improving backup efficiency.
[0237] When comparing these segmented data blocks, the relevant information of these data blocks can be compared. For example, the reference in the local file list of the large file records the relationship between multiple data blocks corresponding to a large file; wherein each data block also has a local file list, and the node_taye in the local file list of each data block records whether the file type is a DB shard file (i.e., a data block); since the data blocks also have their own corresponding local file lists, the method for comparing whether the data blocks are exactly the same can also refer to the method for determining whether ordinary files are exactly the same as described in the above embodiment. This application will not go into details.
[0238] Referring to Figure 12, for small files, they are backed up in the form of tarballs. Therefore, it is necessary to determine whether they are the same tarballs, modified tarballs, and newly added small files in the form of tarballs. The tarballs and files in the local file list of this backup and the local file list of the previous backup have the following relationship:
[0239] Same tarball: Small files in the tarball from the previous backup exist and remain unchanged during this backup. These tarballs have already been backed up to the cloud server during the previous backup and therefore do not need to be backed up this time.
[0240] Changed tarball: Small files in the tarball during the last backup exist in the current backup but have been modified, or small files in the tarball during the last backup partially exist in the current backup.
[0241] Newly added small files: Small files that did not exist in the local file list during the previous backup but exist in the local file list during the current backup.
[0242] The same tarball has already been backed up to the cloud server during the last backup, so there is no need to back it up again this time.
[0243] For modified tarballs, you can view the reuse rate of the modified tarball. Modified tarballs involve three types of small files: identical small files, deleted small files (no need to back up), and modified small files.
[0244] The reuse rate is the percentage (number percentage or data volume percentage) of small files in the tarball from the previous backup that still exist during the current backup.
[0245] If the reuse rate is greater than 90%, identical small files will not be backed up, and the tarball from the last backup will be reused. Modified small files will be handled the same way as newly added small files.
[0246] If the reuse rate is less than or equal to 90%, the same small files and modified small files in the tar file will be processed as newly added small files.
[0247] Newly added small files are packaged into a new tarball according to the packaging limit and backed up.
[0248] After describing how to process various types of files, this article describes the backup process in detail.
[0249] 13 , which is a timing diagram of the data preparation phase during the second backup based on the data preparation phase during the first backup shown in FIG. 7 .
[0250] When it is not the first backup, after the scanned file information is recorded in the local file list of the data snapshot of application A in S406, the local file list in the data snapshot corresponding to the current backup ID can be obtained.
[0251] S415, after the backup service obtains the local file list in the data snapshot corresponding to the current ID, it sends a request to the cloud server for obtaining the last backup record of the device. The request may carry the unique identifier of the device.
[0252] S416: After receiving the acquisition request, the cloud server sends the last backup record of the device to the backup service. The backup record records the data snapshot at the time of the last backup.
[0253] For ordinary files, execute S417 to S421 to obtain the cloud-uploaded file. For large files, execute S417 to S422 to obtain the cloud-uploaded file. For small files, execute S417 to S422 to obtain the cloud-uploaded file.
[0254] In actual applications, you can first target a type of file (for example, ordinary files) and obtain the cloud-uploaded files for that type of file; then target the next type of file (for example, large files) and obtain the cloud-uploaded files for the next type of file, until you obtain the cloud-uploaded files for ordinary files, large files, and small files.
[0255] Taking the cloud files of a certain type of files as an example: S417 , compare the last local file list with the current local file list to obtain difference files (eg, newly added, modified, etc.).
[0256] In this embodiment, the files in the application data are divided into common files, large files, and small files according to their sizes. Different files are processed in different ways, so it is necessary to determine how to process difference files. Refer to the block process shown in Figure 15 and the packaging process shown in Figure 18 respectively.
[0257] S418, the backup service sends an acquisition instruction (carrying information of the differential file) to the file copy recovery module.
[0258] S419, after receiving the acquisition instruction, the file copy and recovery module acquires the file according to the difference file information.
[0259] S420: The file copy recovery module obtains a difference file from a third-party application.
[0260] S421: The file copy recovery module sends the differential file to the backup service.
[0261] S422: The backup service repackages and fragments the files based on the file type and the different difference file processing methods to obtain the cloud-based files.
[0262] The subsequent steps are similar, and can be referred to in detail in the description of FIG7 , which will not be repeated here.
[0263] 14 , which is a flowchart corresponding to step 417 when obtaining a cloud-uploaded file of a common file in FIG13 .
[0264] S901: The backup service obtains a common file entry from the local file list of the last backup according to the identifier of the common file.
[0265] The backup service searches the local file list from the last backup for files with a node_type of 6, thereby filtering out common file entries.
[0266] S902, the backup service filters out file entries (file entries of common files backed up this time) with the same file path and file ID from the local file list during this backup based on the obtained file path and file ID of the common file entry;
[0267] S903, the backup service obtains the hash values and file sizes of the filtered files in the local file list of the last backup; and obtains the hash values and file sizes of the filtered files in the local file list of the current backup.
[0268] S905: Determine whether the hash values are consistent and whether the file sizes are consistent.
[0269] S906, if they are all consistent, then they are determined to be the same common file;
[0270] S907: If one of the hash value and the file size is inconsistent, it is determined that a common file is modified.
[0271] In actual applications, after S902, the following steps are also included:
[0272] S904: The backup service determines that the files that are not selected from the files in the local file list of this backup and whose file types are common files are newly added as common files.
[0273] As mentioned above, for newly added common files and modified common files, if they have been backed up to the cloud server in an earlier historical backup process, the electronic device does not need to back them up again, thereby reducing the situation of repeated backup.
[0274] To make the backup process of common files clearer, the following describes the backup process of common files through a specific example.
[0275] Refer to Table 4, which is an example of a multiple backup process for common files provided in an embodiment of the present application.
[0276] Table 4 Multiple backup processes for common files
[0277] When the device is backed up for the first time or the cloud server does not store the historical backup record of the device, the backup is performed according to the backup process shown in Figures 6 to 11. In step S407, the processing method obtained is no processing (ie, no splitting, no packaging).
[0278] During the first backup, the backup ID is backup_record_01. This backup ID records local file list 1 as A1, B1, and C1, and the corresponding cloud file list 1 as A1, B1, and C1. In fact, the files actually transferred from the electronic device to the cloud server are A1, B1, and C1. It can be understood that the files in the local file list, the cloud file list, and the transferred file list during the first backup are consistent.
[0279] During the second backup, the backup ID is backup_record_02. The local file list 2 generated during the second backup is B1, C2, and D1. Comparing local file list 1 and local file list 2, the difference files are A1, C2, and D1.
[0280] Among them, A1 is the deleted file and does not need to be backed up and uploaded this time;
[0281] C2 is the modified file, which needs to be backed up and uploaded again;
[0282] D1 is a newly added file, which needs to be backed up and uploaded this time.
[0283] Therefore, during the second backup, the cloud file list 2 is C2 and D1. Therefore, the local file list 2 recorded by the backup ID of the second backup is B1, C2, D1, but the cloud file list 2 recorded is C2, D1, and the transferred file list is: C2, D1.
[0284] During the third backup, the backup ID is backup_record_03. The local file list 3 generated during the third backup is A1, B1, D1, and E1. Comparing local file list 3 with local file list 2, the difference files are A1, C2, and E1.
[0285] Among them, A1 is a newly added file. A1 is in the historical cloud file list, so it does not need to be backed up. Instead, it can be transferred instantly or reused.
[0286] C2 is the deleted file, which does not need to be backed up and uploaded this time;
[0287] E1 is a newly added file. It is not in the historical cloud file list, so it needs to be backed up and uploaded.
[0288] Therefore, during the third backup, the uploaded file list 3 is A1 and E1, but the actual transferred file list is E1. Therefore, the local file list 3 recorded by the backup ID for the third backup is A1, B1, D1, and E1, but the recorded uploaded file list 3 is A1 and E1, and the actual transferred file list is E1.
[0289] The above process is only one implementation method of ordinary file backup. In actual application, there may be other implementation methods.
[0290] For example: the local file list of the current backup is no longer compared with the local file list of the previous backup; during each backup, before each common file in the local file list is uploaded to the cloud, a file pre-creation request is first sent to the cloud server to solve the problem of repeated upload of the same common file to the cloud through the instant upload capability (or reuse). There is no need to obtain the local file list corresponding to the previous backup record; there is no need to compare the local file list; the cloud server will not delete files by mistake when cleaning files; however, many invalid file pre-creation requests will be generated, which will put a lot of pressure on the cloud server; the cloud server uses the instant upload capability to generate a large number of cloud-side unique identifiers.
[0291] You can also compare the local file list of the current backup with the local file lists of all previous backups to confirm that the uploaded file is E1. This method is more accurate in identifying duplicate files, but requires obtaining the local file list corresponding to each backup record. Comparing local file lists is complex and inefficient.
[0292] 15 , which shows a method for splitting a large file according to an embodiment of the present application.
[0293] In order to ensure that there are more identical data blocks in the two splits, the file can be split according to the characteristics of the file content itself. For example, specific content in the large file can be used as the end of each data block. After traversing from the file header of the large file, after traversing to the specific content, the specific content is used as the end of the previous data block for splitting, thereby splitting the large file into multiple data blocks. As an example of specific content, four consecutive 0 bytes can be used as specific content. That is, after traversing to "0000", "0000" is used as the end of the previous data block for splitting, and the next byte after "0000" is used as the beginning of the next data block, and the traversal continues backward.
[0294] If the newly added content falls within a data block and the newly added content does not contain specific content, the start and end of the data block remain unchanged, the content and size of the data block change, and other data blocks remain unchanged;
[0295] If the newly added content falls within a certain data block and the newly added content contains specific content, the data block is cut off from the specific content, and other data blocks remain unchanged.
[0296] If the deleted content is within a data block, the start and end of the data block remain unchanged, the content and size of the data block change, and other data blocks remain unchanged;
[0297] If the deleted content covers the position where two data blocks are split, the two data blocks are merged into one data block, and the other data blocks remain unchanged.
[0298] During the first backup, the files are divided into the following data blocks according to their contents: C1, C2, C3, C4, C5, C6, and C7.
[0299] During the second backup, new content is added to the file. This new content falls within data block C4 and does not contain specific characters. Therefore, data block C4 is enlarged and marked as C8. The other data blocks remain unchanged. The second method is used to continue the division into blocks C1, C2, C3, C8 (larger than the original C4), C5, C6, and C7.
[0300] During the third backup, new content is added to the file. This new content is in C5 and contains specific characters. Therefore, the original C5 is split into two data blocks, C9 and C10, while the other data blocks remain unchanged. The second method is used to split the file into the following blocks: C1, C2, C3, C8, C5 (the new content containing the specific characters is split into C9 and C10), C6, and C7.
[0301] During the fourth backup, content is deleted from the file, and the deleted content covers the position where the two data blocks (C2 and C3) are split. Then the two data blocks (C2 and C3) are merged into one data block (C11), and the other data blocks remain unchanged; the blocks continue to be divided into: C1, C11 (part of the original content in C2 and part of the original content in C3 are merged), C8, C9, C10, C6, C7, and the other data blocks remain unchanged.
[0302] During the fifth backup, content is deleted from the file. The deleted content is within data block C1, so data block C1 becomes smaller and is recorded as C12. The other data blocks remain unchanged. According to the second method, the blocks are further divided into: C12 (smaller than C1), C11, C8, C9, C10, C6, and C7.
[0303] Of course, after each split, data blocks that are the same as those in the last backup do not need to be backed up; data blocks that are different from those in the last backup need to be backed up.
[0304] Referring to Figure 16, another method of splitting large files is provided for an embodiment of the present application. A large file can be split into multiple data blocks according to a fixed length. For example, a 1G video is split into multiple data blocks at a length of 200M each: B1, B2, B3, B4 and B5, and the multiple data blocks obtained by the split are uploaded to the cloud server. However, this method is more suitable for situations where there is no data insertion and deletion. Referring to the second backup, when there is data insertion and deletion, the data will be offset from the modified position as a whole. Therefore, if the split is continued according to the length of 200M, the multiple data blocks obtained by this split may be: B6, B7, B8, B9, B10 and B11. Since the position of the inserted data is relatively forward, although the data blocks of this split are the same size as the data blocks of the last switch, the content is completely different. Therefore, during the second backup, the multiple data blocks of the second split still need to be uploaded to the cloud server.
[0305] Refer to Figure 17, which shows the backup process of small files provided in an embodiment of the present application.
[0306] S1001: The backup service obtains a common file entry from the local file list of the last backup according to the identifier of the common file.
[0307] S1002: The backup service determines a set of small files for each tarball based on the references of these small files in the local file list during the last backup.
[0308] S1003: The backup service searches the local file list of the current backup for the same small files in the small file set in each tar package as in the last backup.
[0309] S1004: The backup service determines whether the number of identical small files in the small file set is greater than 90%.
[0310] S1005: When the number of identical small files in the tar package is greater than 90%, the identical small files are reused in the old tar package without being backed up; and the modified small files and the newly added small files are packaged into a new tar package.
[0311] S1006: When the number of small files still existing in the tar package is less than or equal to 90%, these small files still existing and the newly added small files are packaged into a new tar package.
[0312] Referring to FIG. 18 , the small file packaging process provided in an embodiment of the present application is shown.
[0313] During the first backup, the small files in the local file list include: a, b, c1, d. You can package multiple small files into a tarball, for example, a, b, c1, d into tarball 1. In actual applications, you can set an upper limit for each tarball, for example, 100M, 150M, 200M, etc.
[0314] During the second backup, the small files in the local file list include a, b, c2 (the file after modifying c1), d, e, f, and g. Check the reuse rate of tarball 1 from the previous backup. If the reuse rate is greater than 90%, tarball 1 will be reused. This means that the current backup is identical to the previous backup and will not be backed up again. However, the second backup contains redundant file c1 compared to the small files in the local file list. C2 in tarball 1 needs to be packaged with the newly added small files e, f, and g into tarball 2, which needs to be backed up to the cloud server. The reuse rate of tarball 1 is: T2 / T1, where T1 is the number (or data size) of a, b, c1, and d in tarball 1 from the previous backup; T2 is the number (or data size) of a, b, c1, and d in tarball 1 from the previous backup that are still in the local file list. It should be noted that in this example, the number of small files of tar package 1 in the last backup is 4 and the number of small files in the current backup is 3 is only for illustration and does not mean that this relationship is greater than the reuse rate of 90%. Of course, the reuse rate of 90% is also only for illustration.
[0315] During the second backup, tarball 1 was reused, but the small files associated with tarball 1 in the local file list during the second backup were a, b, and d. The small files in tarball 1 on the cloud server are a, b, c1, and d. Therefore, when downloading the second backup data from the cloud server after the second backup to restore the data to the time point corresponding to the second backup, the downloaded tarball 1 includes a, b, c1, and d. However, the small files associated with tarball 1 in the local file list during the second backup were a, b, and d. In this case, during data recovery, the local file list can be compared and the downloaded file c1 can be deleted.
[0316] During the third backup, the small files include a, b, h, i, c2, e, f, and g. Check the reuse rate of the last backed-up tarball 1. If the reuse rate of tarball 1 is less than 90%, repackage a and b from tarball 1 with the newly added h and i into a new tarball 3. Upload tarball 3 for backup. If the reuse rate of the last backed-up tarball 2 is greater than 90% (actually 100%), continue reusing tarball 2 and do not back it up again.
[0317] Referring to Figure 19, this is a process for the cloud server to reuse such common files that already exist on the cloud server. The implementation of this process requires that the cloud server has the ability to transfer files in seconds (i.e., it has a pre-created interface for files) and the files are common files.
[0318] This sequence diagram adds a step of pre-creating cloud files during the cyclic execution of steps S501 to S507 during the application data cloud migration phase shown in Figure 8. The cloud file in this step can be D1 during the second backup in the example of the ordinary file mentioned above. After traversing the data snapshot in S501 and obtaining the cloud files in the cloud file list without the cloud-side unique identifier, it also includes:
[0319] S1001, the backup service sends a pre-creation request for a cloud file to the cloud server. The request carries the file ID, file size, local file path and hash value of the cloud file.
[0320] S1002: After receiving the pre-creation request for a file to be uploaded to the cloud, the cloud server compares the received information with the information of the stored files and determines that the file to be uploaded to the cloud does not exist.
[0321] S1003: The backup server sends a response to the backup service indicating that the file does not exist.
[0322] S502: If the backup service determines that the cloud server does not have the cloud file, it executes subsequent steps S502 to S507.
[0323] As another example, the cloud server may store another cloud-uploaded file. The cloud-uploaded file in this step may be A1 in the third backup in the above example of a common file. As a loop execution step, after traversing the data snapshots in S5011 and obtaining the cloud-uploaded file in the cloud-uploaded file list without the cloud-side unique identifier, the following steps are further included:
[0324] S1004, the backup service sends a pre-creation request for the cloud file to the cloud server. The request carries the file ID, file size, local file path and hash value of the cloud file.
[0325] S1005, after receiving the pre-creation request for the cloud file, the cloud server compares the received information with the information of the stored file, determines that the cloud file already exists, and generates a new cloud-side unique identifier for the cloud file.
[0326] S1006: The backup server sends a response to the backup service indicating that the file exists. The response carries a new cloud-side unique identifier.
[0327] When the backup service determines that the cloud server has the file to be uploaded to the cloud, it will no longer execute the file upload step, but will execute S5071 and subsequent steps.
[0328] In actual applications, the cloud server may not have the ability to transfer files in seconds (i.e., it does not have a pre-created interface for files). In this case, the backup service needs to send a multiplexing file request to the cloud server. The other steps are similar to Figure 14 and will not be repeated here.
[0329] From the above description, it can be understood that the embodiment of the present application splits large files into multiple data blocks and packages small files into tar packages, which can reduce the number of requests between the cloud server; the files (including data blocks and tar packages) that are backed up twice are no longer backed up, which can improve the backup efficiency.
[0330] When backing up an application installation package, multiple electronic devices may back up the same application installation package, and the same electronic device may also back up the same application installation package when backing up multiple times. In order to avoid wasting storage space in the cloud server and improve backup efficiency and recovery efficiency, it is no longer necessary to back up the installation package that already exists in the application market or cloud server.
[0331] 20 , which shows the process of backing up installation package A and installation package B.
[0332] When backing up application A, the backup service sends an application market query request for application installation package A to the cloud server. The query request carries the signature, package name, and version number.
[0333] After receiving the query request, the cloud server sends an application market query request for application installation package A to the application server. The query request carries the signature, package name, and version number.
[0334] After receiving the query request, the application server checks whether the cloud server has an installation package with the same signature and package name, and the cloud-side version number is not lower than the version number in the request;
[0335] The application server sends information about the existence of application installation package A to the cloud server.
[0336] After receiving the information that the application installation package A exists, the cloud server sends the information that the application installation package A exists to the backup service.
[0337] After the backup service receives the information that the application installation package A exists in the application market, it no longer backs up the application installation package A.
[0338] As another example, when backing up application B, the backup service executes step S** and sends an application market query request for application installation package B to the cloud server. The query request carries the signature, package name, and version number.
[0339] After receiving the query request, the cloud server sends an application market query request for application installation package B to the application server. The query request carries the signature, package name, and version number.
[0340] After receiving the query request, the application server checks whether the cloud server has an installation package with the same signature and package name, and the cloud-side version number is not lower than the version number in the request;
[0341] The application server sends a message to the cloud server that the application installation package B does not exist.
[0342] After receiving the information that the application installation package B does not exist, the cloud server sends the information that the application installation package B does not exist to the backup service.
[0343] After receiving the information that the application installation package B does not exist in the application market, the backup service sends a pre-creation request for the application installation package B to the cloud server.
[0344] After receiving the pre-creation request for application installation package B, the backup service searches for installation packages with the same signature, package name, and version number.
[0345] The cloud server sends information about the existence of application installation package B to the backup service. This information carries the cloud-side address of application installation package B.
[0346] 21 , the recovery process will be described below using the application market of application installation package A as an example.
[0347] When restoring application A, the recovery service finds that the backed-up application resource files do not include the installation package, and then sends an application market download request (signature, package name, and version number) for application installation package A to the cloud server.
[0348] After receiving the application market download request (signature, package name and version number) for application installation package A, the cloud server sends the application market download request (signature, package name and version number) for application installation package A to the application server. After receiving the download request, the application server sends the download address of application installation package A to the cloud server;
[0349] After receiving the download address of application installation package A, the cloud server sends the download address of application installation package A to the recovery service.
[0350] The recovery service sends a download request for application installation package A to the application server based on the download address.
[0351] Based on the download request, the application server sends the installation package of application A to the backup service.
[0352] During the recovery phase, if the application resource files are backed up to the cloud server including the installation package, each application resource file (including the application installation package) will be downloaded from the cloud server in sequence when the installation package is restored. Therefore, this application will not be described in detail, and please refer to the previous description for details.
[0353] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0354] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is run on an electronic device, it can implement the steps in the above-mentioned various method embodiments.
[0355] The embodiments of the present application further provide a computer program product. When the computer program product is run on an electronic device or a wireless router, the electronic device can implement the steps in the above-mentioned various method embodiments.
[0356] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by the processor, it can implement the steps of the above-mentioned various method embodiments. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include at least: any entity or device capable of carrying the computer program code to the first device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electric carrier signal, a telecommunication signal and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0357] The present application also provides a chip comprising a processor coupled to a memory, wherein the processor invokes a computer program stored in the memory to implement the steps of any method embodiment of the present application. The chip may be a single chip or a chip module composed of multiple chips.
[0358] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0359] Those skilled in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0360] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.
Claims
1. A data backup method, characterized in that: include: The electronic device generates a first file list according to the attribute information of the directory file backed up this time; The electronic device obtains a second file list at the time of the last backup, where the second file list includes attribute information of the directory file at the time of the last backup; The electronic device obtains, according to the first file list and the second file list, a synchronization type of the difference files in the directory file, the synchronization type including: adding and / or modifying; The electronic device sends the difference file to the cloud server.
2. The method according to claim 1, characterized in that The attribute information includes a file type, and the file type includes a large file type; the electronic device obtains the synchronization type of the difference file in the directory file according to the first file list and the second file list, including: The electronic device searches the second file list for a first large file whose file type is a large file type; For each first large file, if the electronic device finds a second large file from the first file list that has the same first attribute information as the first large file and different second attribute information, the synchronization type of the second large file is determined as modification; For each first large file, if the electronic device finds a third large file from the first file list that has the same first attribute information and the same second attribute information as the first large file, the synchronization type of the third large file is determined to be the same; The electronic device determines the synchronization type of the fourth largest file in the first file list other than the synchronization types of modification and same as new addition; the difference file includes a modified large file and a newly added large file, the modified large file is a large file with a synchronization type of modified, and the newly added large file is a large file with a synchronization type of new addition.
3. The method according to claim 2, characterized in that The first attribute information includes a file ID and a file path; the second attribute information includes a hash value.
4. The method according to claim 2, characterized in that The difference file includes a newly added large file, and the electronic device sending the difference file to the cloud server includes: The electronic device performs segmentation processing on the newly added large file to obtain multiple data blocks of the newly added large file; The electronic device sends multiple data blocks of the newly added large file to the cloud server.
5. The method according to any one of claims 2 to 4, characterized in that: The difference file includes modifying the large file, and the electronic device sending the difference file to the cloud server includes: The electronic device performs segmentation processing on the modified large file to obtain a first set consisting of a plurality of first data blocks; The electronic device obtains a fifth large file having the same first attribute information as the modified large file from the second file list, and the first large file includes the fifth large file; The electronic device obtains a second set consisting of a plurality of second data blocks of the fifth largest file from the second file list; The electronic device compares the first data block in the first set with the second data block in the second set to obtain the difference data block for modifying the large file, wherein the difference data block includes a modified data block and a newly added data block; The electronic device sends the difference data block of the modified large file to the cloud server.
6. The method according to claim 5, characterized in that The electronic device performs segmentation processing on the modified large file to obtain a first set consisting of a plurality of first data blocks, including: The electronic device searches for specific characters in the modified large file; The electronic device divides the modified large file from the position corresponding to the specific character to obtain a first set consisting of a plurality of first data blocks.
7. The method according to any one of claims 1 to 6, characterized in that: The attribute information includes a file type, and the file type includes a small file type; the attribute information also includes a tar package where each small file is located; The electronic device compares the first file list and the second file list to obtain the synchronization type of the difference file in the directory file, including: The electronic device compares the first file list with the second file list to obtain a changed tar package and a first newly added small file; The electronic device calculates the reuse rate of the small files in the changed tar package; For a first changed tar package whose reuse rate is greater than a reuse threshold, use the unreused small files in the first changed tar package as the second newly added small files; For the second changed tar package whose reuse rate is less than or equal to the reuse threshold, the reused small files and modified small files in the second changed tar package are used as the third newly added small files; The difference files include the first newly added small file, the second newly added small file and the third newly added small file.
8. The method according to claim 7, characterized in that The electronic device sending the difference file to the cloud server includes: The electronic device packages the first newly added small file, the second newly added small file, and the third newly added small file into at least one new tar package according to a packaging rule; The electronic device sends the new tar package to the cloud server, and the data volume of the new tar package is less than the data volume threshold.
9. The method according to claim 7, characterized in that The number of small files in the changed tar package in the second file list is the first number; the number of reused small files in the first file list is the second number; The reuse rate of the small files in the changed tar package is the ratio of the second number to the first number.
10. The method according to claim 7, characterized in that The data volume of the small files in the changed tar package in the second file list is the first data volume; the data volume of the first small files reused in the first file list is the second data volume; The reuse rate of the small files in the changed tar package is the ratio of the second data volume to the first data volume.
11. The method according to claim 9 or 10, characterized in that The reused first small file is a small file with the same first attribute information and second attribute information; the non-reused small file is a small file with the same first attribute information and different second attribute information, the first attribute information includes: file name and file path, and the second attribute information includes hash value.
12. The method according to any one of claims 1 to 11, characterized in that The attribute information includes a file type, and the file type includes a common file type; the electronic device compares the first file list and the second file list to obtain a synchronization type of a difference file in the directory file, including: The electronic device searches the second file list for a first common file whose file type is a common file type. Item; For each first common file, if the electronic device finds a second common file from the first file list that has the same first attribute information as the first common file but different second attribute information, the second common file is determined as a modified common file; For each first common file, if the electronic device finds a third common file having the same first attribute information and the same second attribute information as the first common file from the first file list, the third common file is determined as the same common file; The electronic device determines the synchronization type of the fourth ordinary file in the first file list other than the modification and same synchronization types as new addition; the difference file includes a modified ordinary file and a newly added ordinary file, the modified ordinary file is an ordinary file with a synchronization type of modified, and the newly added ordinary file is an ordinary file with a synchronization type of new addition.
13. The method according to claim 12, characterized in that The electronic device sending the difference file to the cloud server includes: The electronic device sends a request to create a first file to the cloud server, the request to create the first file is used to instruct the cloud server to return a cloud-side unique identifier of the first file if the first file is stored, or to return information that the first file does not exist if the first file is stored, and the first file is the modified common file or the newly added common file; If the electronic device receives the information sent by the cloud server that the first file does not exist, sending the first file to the cloud server; If the electronic device receives the cloud-side unique identifier of the first file sent by the cloud server, the first file is not sent to the cloud server.
14. An electronic device, characterized in that: The electronic device comprises a processor, and the processor is used to call a computer program in a memory to execute the method according to any one of claims 1 to 13.
15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 13.
16. A chip, characterized in that: The chip comprises a processor, and the processor is used to call a computer program in a memory to execute the method according to any one of claims 1-13.