Data backup method and electronic device
By comparing snapshot files to determine data block updates, the problem of long backup times and device lag in existing technologies is solved, achieving a more efficient backup process.
Patent Information
- Application Number
- PCT/CN2025/101109
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-06-20
- Filing Date
- 2025-06-16
- Publication Date
- 2025-12-26
AI Technical Summary
Existing technologies require calculating whether the fingerprints of each block in the data have changed when performing differential or incremental backups. This results in long calculation times, consumes system resources, causes electronic devices to lag, and reduces the user experience.
By obtaining the snapshot file generated during the last backup and the snapshot file generated during the current backup, the snapshot files are compared to determine the update status of data blocks, avoiding fingerprint calculation for each data block and directly generating a backup package.
It saves backup time, prevents electronic devices from lagging, and improves the user experience.
Smart Images

Figure CN2025101109_26122025_PF_FP_ABST
Abstract
Description
A method for backing up data and an electronic device
[0001] This application claims priority to Chinese Patent Application No. 202410798943.7, filed on June 20, 2024, entitled “A method for backing up data and an electronic device”, the entire contents of which are incorporated herein by reference. Technical Field
[0002] This application relates to the field of electronic devices, and more specifically, to a method for backing up data and an electronic device. Background Technology
[0003] Electronic devices can back up data in response to user actions, or they can back up data automatically. When backing up data for the first time, electronic devices perform a full backup. Subsequent backups can use differential or incremental backups. Currently, when performing differential or incremental backups, electronic devices need to calculate whether the fingerprints of each data block have changed. When the data is large, this calculation takes a long time, leading to a degraded user experience. Furthermore, calculating the fingerprints of each data block consumes significant system resources, potentially causing the device to lag and further reducing the user experience. Therefore, improving the efficiency of data backup has become a pressing technical problem. Summary of the Invention
[0004] This application provides a method for backing up data and an electronic device that can obtain a snapshot file generated during the last data backup and generate a snapshot file corresponding to the current backup. By comparing the two snapshot files, the data storage address corresponding to the data block that has been updated can be determined. This eliminates the need to perform fingerprint calculations on each data block, saving data backup time and preventing electronic device lag, thus improving the user experience.
[0005] In a first aspect, a method for backing up data is provided. The method includes: during the M-th backup of first data, acquiring a first snapshot file and generating a second snapshot file, wherein the first snapshot file is a snapshot file generated during the (M-1)-th backup of the first data, the first snapshot file includes the data block storage addresses of data blocks of the first data during the (M-1)-th backup of the first data, and the second snapshot file includes the data block storage addresses of data blocks of the first data during the M-th backup of the first data, where M ≥ 2 and is an integer; determining a first data block storage address set based on the first snapshot file and the second snapshot file, the first data block storage address set including the data block storage addresses corresponding to data blocks of the first data that have been updated after the (M-1)-th backup of the first data; determining a first backup package based on the first data block storage address set; and sending the first backup package to a cloud server.
[0006] In this embodiment, when an electronic device performs a backup of the first data that is not the first time, it can obtain the first snapshot file generated during the last backup of the first data and generate a second snapshot file. By comparing the first snapshot file and the second snapshot file, the storage address of the data block corresponding to the data block that was updated remotely and / or the storage address of the newly added data block and / or the storage address of the deleted data block can be determined. Then, the backup package can be determined based on the storage address of the data block corresponding to the data block that was updated remotely and / or the storage address of the newly added data block and / or the storage address of the deleted data block. This eliminates the need to perform fingerprint calculations on each data block of the first data, saves backup time, and does not cause the electronic device to lag, thus improving the user experience.
[0007] In conjunction with the first aspect, in some implementations of the first aspect, determining the first data block storage address set based on the first snapshot file and the second snapshot file includes: determining a first node set based on the first snapshot file and the second snapshot file, the first node set including nodes where the first data has been updated after the (M-1)th backup of the first data, each node in the first node set corresponding to one or more data block storage addresses; and determining the data block storage address corresponding to the first node set as the first data block storage address set.
[0008] In this embodiment of the application, when the electronic device compares the first snapshot file and the second snapshot file, it can use nodes as the comparison granularity. Since the amount of data corresponding to a node is large, the node that has been updated can be quickly determined, which helps to improve the speed of data backup.
[0009] In conjunction with the first aspect, in certain implementations of the first aspect, determining the first data block storage address set based on the first snapshot file and the second snapshot file includes: determining a first node set based on the first snapshot file and the second snapshot file, the first node set including nodes where the first data has been updated after the (M-1)th backup of the first data, each node in the first node set corresponding to one or more data block storage addresses; determining the updated data block storage addresses in each node of the first node set based on the first snapshot file, the second snapshot file, and the first node set, wherein the updated data block storage addresses in each node of the first node set include data block storage addresses corresponding to remotely updated data blocks and / or data block storage addresses corresponding to deleted data blocks and / or newly added data block storage addresses; and determining the first data block storage address set based on the updated data block storage addresses in each node of the first node set.
[0010] In this embodiment of the application, when the electronic device compares the first snapshot file and the second snapshot file, it can first compare at the node level to determine the set of updated nodes. Since the amount of data corresponding to the node is large, the updated nodes can be quickly determined, which helps to improve the speed of data backup. Then, the electronic device uses the data block storage address as the comparison granularity to find the updated data block storage address from the set of updated nodes, which can improve the accuracy of data backup.
[0011] In conjunction with the first aspect, in some implementations of the first aspect, the nodes where the first data is updated include the nodes corresponding to the data blocks updated remotely and / or the deleted nodes and / or the newly added nodes.
[0012] In conjunction with the first aspect, in some implementations of the first aspect, before generating the second snapshot file, the method further includes: determining that the size of the first data is greater than or equal to a first threshold.
[0013] In conjunction with the first aspect, in some implementations of the first aspect, before generating the second snapshot file, the method further includes: determining that the first data matches the first snapshot file.
[0014] In conjunction with the first aspect, in some implementations of the first aspect, determining that the first data matches the first snapshot file includes: determining that the first data matches the first snapshot file when the node information of the first data matches the node information stored in the first snapshot file.
[0015] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes, before generating the second snapshot file, determining that the first snapshot file is a complete snapshot file.
[0016] In conjunction with the first aspect, in some implementations of the first aspect, before determining the first data block storage address set based on the first snapshot file and the second snapshot file, the method further includes: determining that the version number of the first snapshot file is the same as the version number of the second snapshot file.
[0017] In a second aspect, an electronic device is provided, comprising one or more processors; one or more memories; the one or more memories storing one or more computer programs, the one or more computer programs including instructions that, when executed by the one or more processors, cause the foregoing aspects or any possible implementation thereof to be performed.
[0018] Thirdly, a computer-readable storage medium is provided, comprising a computer program or instructions that, when executed on a computer, cause the first aspect and any possible implementation of the first aspect to be performed.
[0019] Fourthly, a computer program product is provided, comprising a computer program or instructions that, when executed on a computer, cause the first aspect and any possible implementation of the method of the first aspect to be performed.
[0020] Fifthly, a computer program is provided that, when run on a computer, causes the methods described in the first aspect and any possible implementation thereof to be executed.
[0021] Sixthly, an electronic device according to an embodiment of this application includes modules / units for performing the above aspects or any possible design of the above aspects; these modules / units can be implemented in hardware or implemented by hardware executing corresponding software.
[0022] For the beneficial effects of aspects two through six, please refer to the beneficial effects of aspect one, which will not be repeated here. Attached Figure Description
[0023] Figure 1 is a schematic diagram of the structure of the electronic device provided in an embodiment of this application.
[0024] Figure 2 is a software structure block diagram of the electronic device provided in an embodiment of this application.
[0025] Figure 3 is a schematic flowchart of the data backup method provided in an embodiment of this application.
[0026] Figure 4 is a schematic diagram of a snapshot file provided in an embodiment of this application.
[0027] Figure 5 is a schematic flowchart of the data backup method provided in the embodiments of this application.
[0028] Figure 6 is a schematic flowchart of the method for comparing snapshot files provided in an embodiment of this application.
[0029] Figure 7 is a schematic flowchart of the method for comparing snapshot files provided in an embodiment of this application.
[0030] Figure 8 is a schematic flowchart of a method for backing up data provided in an embodiment of this application. Detailed Implementation
[0031] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.
[0032] The terminology used in the following embodiments is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification and appended claims of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to also include expressions such as “one or more,” unless the context clearly indicates otherwise. It should also be understood that in the following embodiments of this application, “at least one” and “one or more” refer to one, two, or more than two. The term “and / or” is used to describe the relationship between related objects, indicating that three relationships may exist; for example, A and / or B can indicate: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character “ / ” generally indicates that the preceding and following related objects are in an “or” relationship.
[0033] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of 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 "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0034] The following describes an electronic device and embodiments for using such an electronic device. In some embodiments, the electronic device may be a portable electronic device that also includes other functions such as a personal digital assistant and / or music player, such as a mobile phone, tablet computer, wearable electronic device with wireless communication capabilities (such as a smartwatch), etc. Exemplary embodiments of the portable electronic device include, but are not limited to, carrying... Alternatively, it can be a portable electronic device with another operating system. The aforementioned portable electronic device can also be other portable electronic devices, such as laptops. It should also be understood that in some other embodiments, the aforementioned electronic device may not be a portable electronic device, but rather a desktop computer. In some embodiments, the electronic device can be a component of a smart driving device.
[0035] For example, Figure 1 shows a schematic diagram of the structure of an electronic device 100. The 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, an antenna 1, an 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, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity 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.
[0036] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0037] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0038] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to the instruction opcode and timing signals to complete the control of fetching and executing instructions.
[0039] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0040] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0041] The wireless communication function of electronic device 100 can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.
[0042] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with tuning switches.
[0043] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1. In some embodiments, at least some functional modules of the mobile communication module 150 may be housed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 may be housed in the same device.
[0044] The modem processor may include a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After processing by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs sound signals through an audio device (not limited to speaker 170A, receiver 170B, etc.) or displays images or videos through the display screen 194. In some embodiments, the modem processor may be a separate device. In other embodiments, the modem processor may be independent of the processor 110 and may be housed in the same device as the mobile communication module 150 or other functional modules.
[0045] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signals, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.
[0046] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, enabling electronic device 100 to communicate with networks and other devices via wireless communication technology. The wireless communication technology may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time-Division Code Division Multiple Access (TD-CDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technologies, etc. The GNSS may include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the BeiDou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS), and / or satellite-based augmentation systems (SBAS).
[0047] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0048] 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 (AMOLED), a flexible light-emitting diode (FLED), a Miniled LED, a MicroLED, a 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.
[0049] Electronic device 100 can perform shooting functions through ISP, camera 193, video codec, GPU, display 194 and application processor.
[0050] Internal memory 121 can be used to store computer executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of electronic device 100 by running the instructions stored in internal memory 121. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data, phonebook, etc.). Furthermore, internal memory 121 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
[0051] Electronic device 100 can implement audio functions, such as music playback and recording, through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.
[0052] The audio module 170 is used to convert digital audio information into analog audio signals for output, and also to convert analog audio input into digital audio signals. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 may be located in the processor 110, or some functional modules of the audio module 170 may be located in the processor 110.
[0053] The speaker 170A, also known as a "loudspeaker," is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music or make hands-free calls through the speaker 170A.
[0054] The receiver 170B, also known as the "earpiece," is used to convert audio electrical signals into sound signals. When the electronic device 100 answers a telephone call or voice message, the receiver 170B can be brought close to the ear to listen to the voice.
[0055] Microphone 170C, also known as a "microphone" or "voice transducer," is used to convert sound signals into electrical signals. When making a phone call or sending a voice message, the user can speak by bringing their mouth close to microphone 170C, inputting the sound signal into microphone 170C. Electronic device 100 may have at least one microphone 170C. In some embodiments, electronic device 100 may have two microphones 170C, which, in addition to collecting sound signals, can also perform noise reduction. In other embodiments, electronic device 100 may also have three, four, or more microphones 170C, which can collect sound signals, reduce noise, identify the sound source, and perform directional recording, etc.
[0056] Figure 2 is a software structure block diagram of an electronic device 100 according to an embodiment of this application. The layered architecture divides the software into several layers, each with a clear role and division of labor. Layers communicate with each other through software interfaces. In some embodiments, the operating system is divided into four layers, from top to bottom: the application layer, the application framework layer, the runtime and system libraries, and the kernel layer. The application layer may include a series of application packages.
[0057] As shown in Figure 2, the application layer can include camera, settings, third-party applications, etc. Third-party applications can include gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, SMS, etc.
[0058] The application framework layer provides application programming interfaces (APIs) and programming frameworks for applications in the application layer. The application framework layer may include some predefined functions.
[0059] As shown in Figure 2, the application framework layer may include a window manager, content provider, view system, phone manager, resource manager, notification manager, etc.
[0060] The window manager is used to manage windowed applications. It can obtain the screen size, determine if a status bar is present, lock the screen, and capture screenshots. The content provider stores and retrieves data, making this data accessible to applications. This data may include videos, images, audio, made and received phone calls, browsing history and bookmarks, phone books, etc.
[0061] The view system includes visual controls, such as controls for displaying text, controls for displaying images, and such as the indicator information for displaying the virtual shutter button in the embodiments of this application. The view system can be used to build applications. The display interface can consist of one or more views. For example, a display interface including a text message notification icon can include a view for displaying text and a view for displaying images.
[0062] The phone manager is used to provide communication functions for electronic device 100. For example, it manages call status (including connection and disconnection).
[0063] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.
[0064] The notification manager allows applications to display notifications in the status bar. These notifications can be used to deliver informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager can be used to notify users of download completion or message alerts. The notification manager can also display notifications as icons or scrolling text in the top status bar, such as notifications from background applications, or as dialog boxes on the screen. Examples include displaying text messages in the status bar, emitting sounds, vibrating electronic devices, and flashing indicator lights.
[0065] Runtime consists of core libraries and a virtual machine. Runtime is responsible for the scheduling and management of the operating system.
[0066] The core library consists of two parts: one part is the functionalities that the Java language needs to call, and the other part is the core library of the operating system.
[0067] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0068] System libraries can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.
[0069] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.
[0070] The media library supports playback and recording of various common audio and video formats, as well as still image files. It supports multiple audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.
[0071] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0072] A 2D graphics engine is a graphics engine for 2D drawing.
[0073] In addition, the system library may also include status monitoring service modules, such as a physical status recognition module for analyzing and recognizing user gestures; and a sensor service module for monitoring sensor data uploaded by various sensors at the hardware layer to determine the physical status of the electronic device 100.
[0074] The kernel layer is the layer between hardware and software. The kernel layer contains at least the display driver, camera driver, audio driver, and sensor driver.
[0075] The hardware layer may include various types of sensors, such as the various sensors shown in Figure 1, including accelerometers, gyroscopes, and touch sensors involved in the embodiments of this application.
[0076] It should be noted that Figure 2 only illustrates one way of dividing the system framework and should not be construed as a specific limitation on the embodiments of this application. In the embodiments of this application, when the electronic device is equipped with different operating systems, different frameworks can be used for different operating systems. It is understood that when different frameworks are adopted, the way the framework layers are divided, the specific naming, and the specific layer in which each of the above modules is located can be different.
[0077] Before introducing the embodiments of this application, we will first introduce several concepts that may be involved in the embodiments of this application.
[0078] Full backup: Also known as a complete backup, a backup method that performs a complete copy of the data.
[0079] Incremental backup is a backup method that backs up data that has changed since the last backup. The last backup can be any of the following: full backup, differential backup, or incremental backup.
[0080] For example, an electronic device stores data #1, which corresponds to chat data from a social application. Data #1 is 1GB in size. When the electronic device first backs up data #1, it performs a full backup, storing the data to a cloud server. As the user interacts with the device, the size of data #1 may increase. If, during the second backup, data #1 is 3GB, the electronic device can simply back up the additional 2GB of data added between the first and second backups.
[0081] Differential backup: Differential backup, also known as differential backup, is a backup method that backs up data that has changed since the last full backup. The last backup can be a full backup.
[0082] It is understandable that when the previous backup was a full backup, incremental backup and differential backup can be considered to be the same backup method when performing this backup.
[0083] A file system (FS) is an essential component of the operating system of electronic devices, servers, or virtual machines (VMs). It is an abstract data type that implements operations such as data storage, hierarchical organization, access, and retrieval. The file system provides a standard system call interface for applications installed on electronic devices. By calling this standard system call interface, applications can perform operations such as creating, deleting, reading, and writing data on the storage device.
[0084] For example, in some scenarios, electronic devices can be mobile phones, computers, etc. Storage devices can be flash-based storage devices such as solid-state disks (SSDs), universal flash storage (UFS), and embedded multimedia cards (eMMC). The file system can be a flash-friendly file system (F2FS), a harmony file system (HMFS), or other file systems.
[0085] It should be noted that the type of file system is not specifically limited in this application embodiment. The file system in this application embodiment can be any file system that supports off-site updates.
[0086] In-situ update: This is a method of updating data at the original data storage location. When an electronic device updates data, it finds the storage location of the data and then performs the update operation at that storage location, which can overwrite the original data.
[0087] Offsite update: This is an update method where data is written to a different storage location. When an electronic device updates data, it redirects the update operation to another idle block. The original block containing the old data is not erased temporarily but is set to an invalid state, awaiting erasure during the next garbage collection (GC). A block can be understood as a unit of storage on a storage device; for example, a block corresponds to a storage size of 4KB.
[0088] For example, an electronic device writes data to blocks #0-#5, with the data written sequentially as data blocks #1, #2, #3, #4, #5, and #6. After a period of time, data blocks #1, #3, and #5 are modified, and the electronic device writes the modified data blocks #1, #3, and #5 to blocks #6-#8. Therefore, data blocks #1 in block #0, #3 in block #2, and #5 in block #4 become invalid. During the next garbage collection (GC) cycle, the electronic device can erase the data in blocks #0, #2, and #4.
[0089] For example, the size of a block in a storage device can be 4KB.
[0090] In summary, when data is updated remotely, the storage address of the data block will change.
[0091] A hash value, also known as a hash table or hash, is a value that transforms data of arbitrary length into a fixed-length output using a hash algorithm. Hash values can be viewed using various hash algorithms, such as Message-Digest Algorithm 5 (MD5) and Secure Hash Algorithm 1 (SHA-1). A hash value can also be referred to as a fingerprint of the data.
[0092] Currently, electronic devices can back up data in response to user actions, or they can back up data automatically. When backing up data for the first time, an electronic device will perform a full backup. When backing up data for the first time, the electronic device can use differential or incremental backups. When performing differential or incremental backups, the electronic device needs to identify the differences between the data and the previous backup. Several methods for determining data changes will be introduced below.
[0093] Comparison of modification time (modifytime, mtime):
[0094] Electronic devices can divide data into multiple data blocks and record the last modification time of each data block. It's important to note that if a data block is newly added, its last modification time can be the time it was added. When backing up the data, the electronic device can check the modification time of each data block and compare it with the timestamp of the last backup. If the modification time of a data block is later than the last backup time, it indicates that the data block has changed or that it is a newly added data block.
[0095] For example, data #1 includes data block #1 and data block #2. The last time the electronic device backed up data #1 was May 1, 2024. When the electronic device backs up data #1 again on May 8, 2024, it determines that the last modification time of data block #1 is May 7, 2024, and the last modification time of data block #2 is January 1, 2024. Therefore, the electronic device can determine that data block #1 is the data that needs to be backed up.
[0096] Hash value comparison:
[0097] Electronic devices can divide data into multiple data blocks, and perform hash calculations on each data block to generate a unique hash value. When performing a data backup, the electronic device stores the hash value of each data block. When performing differential or incremental backups, the electronic device can recalculate the hash value of each data block and compare it with the previously stored hash value. If the hash values are different, it indicates that the data block has changed or that the data block is newly added.
[0098] Currently, when electronic devices perform differential or incremental backups, they simultaneously compare modification times and hash values to more accurately identify changed and newly added data blocks.
[0099] In summary, when electronic devices perform differential or incremental backups, they need to determine the last modification time and whether the fingerprints of each data block have changed. When the data is large, it will be divided into many blocks. Determining the modification time of each data block and calculating the hash value of each block individually will consume a significant amount of time, leading to a degraded user experience. Furthermore, calculating the fingerprints of each data block consumes substantial system resources, potentially causing lag and further reducing the user experience. Therefore, improving the efficiency of data backup has become a pressing technical problem.
[0100] In this embodiment of the application, when the electronic device performs a backup of data that is not the first time, it can obtain the snapshot file generated during the last backup and generate the latest snapshot file. By comparing the two snapshot files, it can determine the updated content of the data, and thus determine the backup package. Since the electronic device can compare snapshot files very quickly, it saves the time of backing up data compared to fingerprint calculation of the data, and does not cause the electronic device to lag, which helps to improve the user experience. The following will be described in detail with reference to Figure 3.
[0101] Figure 3 shows a schematic flowchart of a data backup method provided in an embodiment of this application. This method can be executed by an electronic device or by the processor shown in Figure 1. The following description uses an electronic device as an example. As shown in Figure 3, the method 300 includes:
[0102] S301, when performing the Mth backup of the first data, obtain the first snapshot file, which is generated when performing the (M-1)th backup of the first data, where M≥2 and is an integer.
[0103] In this embodiment of the application, when the electronic device backs up the first data, it acquires a first snapshot file. This first snapshot file can indicate the storage address corresponding to each data block when the first data is backed up for the (M-1)th time. The format of the snapshot file will be described below.
[0104] Figure 4 shows a schematic diagram of the format of the snapshot file provided in an embodiment of this application.
[0105] As shown in Figure 4, a snapshot file includes a snapshot file header and snapshot content. The snapshot file header includes information such as the snapshot version number, the number of nodes, and the file checksum.
[0106] It should be noted that the content of the snapshot file header shown in Figure 4 is only an example, and the snapshot file header may include more or less information.
[0107] In this embodiment, the file checksum can be used for integrity verification, i.e., to verify whether the snapshot file is complete. In this embodiment, the type of file checksum is not specifically limited. For example, the file checksum can be a secure hash algorithm (SHA) value, such as SHA256, or a message digest algorithm (MD) value, such as MD5.
[0108] The snapshot content stores information about the nodes. In this embodiment, a node may include an index node (inode) and a direct node (dnode). An inode is a data structure used to store metadata of the data. A dnode is also a data structure used to store the storage address of one or more data blocks, i.e., the data block storage address. In other words, one dnode can correspond to one or more data blocks.
[0109] In some embodiments, an inode is also used to store the storage addresses of one or more data blocks.
[0110] In some embodiments, the storage address of the data block stored in the node is the address of the block in the storage device.
[0111] It is understandable that when a data block corresponding to a node is updated through off-site updates, the storage address of the data block stored on that node will also be updated accordingly.
[0112] For example, taking node dnode as an example, dnode#1 stores the storage addresses of data blocks #1, #2, and #3. The storage address corresponding to data block #1 is storage address #1, data block #2 is storage address #2, and data block #3 is storage address #3. When data block #1 is updated remotely, its storage address is updated to storage address #4. Therefore, storage address #1 in dnode#1 will also be updated to storage address #4.
[0113] In some embodiments, the node information stored in the snapshot content includes the node's metadata, which includes the metadata of the inode and the dnode.
[0114] Referring to Figure 4, the `ntt_enery` field can be used to represent node metadata. It's understandable that the number of `ntt_enery` fields is the same as the number of nodes.
[0115] For example, if there are N dnodes and 1 inode, then the snapshot content stores N+1 ntt_enery fields.
[0116] Referring to Figure 4, the ntt_enery field includes three fields: node version number, node ino number, and node storage address. The version number, ino number, and storage address are associated with the node.
[0117] It should be noted that the node number can be understood as the identifier of the node, and the node numbers of each node in a snapshot file are different.
[0118] It should also be noted that the node index and node storage address in the ntt_enery field can form a node address table (NAT). For example, Table 1 shows an exemplary node address table. As shown in Table 1, there are four nodes in the snapshot file. The storage address of the node with index 0 is node storage address #1, the storage address of the node with index 1 is node storage address #2, the storage address of the node with index 2 is node storage address #3, and the storage address of the node with index 3 is node storage address #4. The node with index 0 can be an inode, and the nodes with indexes 1-3 can be dnodes.
[0119] Table 1. A node address table
[0120] In some embodiments, node updates can also be performed using a remote update method.
[0121] Understandably, when a node's corresponding data block is updated via a cross-site update, the storage address of that node's data block will also be updated. Since the storage address of the data block stored in that node has been updated, meaning the node itself has been updated, according to the principle of cross-site updates, this node can be updated to the storage address of other nodes; that is, the node storage address in the ntt_enery field will also be updated accordingly.
[0122] For example, node#1 stores the storage addresses of data blocks #1, #2, and #3. The storage address corresponding to data block #1 is storage address #1, data block #2 is storage address #2, and data block #3 is storage address #3. The storage address of node#1 stored in the ntt_enery field is node storage address #1. When data block #1 is updated remotely, its storage address is updated to data block storage address #4. Therefore, the storage address of data block #1 in node#1 will also be updated to data block storage address #4. Since node#1 has also been updated, it will be updated to node storage address #2. Therefore, the storage address of node #1 stored in the ntt_enery field will also be updated to node storage address #2.
[0123] For example, node#1 stores the storage addresses of data blocks #1, #2, and #3. The storage address corresponding to data block #1 is storage address #1, data block #2 is storage address #2, and data block #3 is storage address #3. The ntt_enery field stores the storage address of node#1 as node storage address #1. When data block #1 is deleted, node#1 no longer records its storage address, and node#1 is updated to node storage address #2. Therefore, the node storage address #1 stored in the ntt_enery field will also be updated to node storage address #2.
[0124] In addition to the examples above, when a new storage address is written to a node, the node's storage address will also change.
[0125] For example, at time point #1, node#1 stores the storage addresses of data blocks #1, #2, and #3, where the storage address of node#1 is node storage address 1. At time point #2, the storage address of data block #4 is written to node#1. Since node#1 has also been updated, it will be updated to node storage path #2. Therefore, the node storage address #1 stored in the ntt_enery field will also be updated to node storage address #2.
[0126] It should be noted that when a node is updated remotely, the storage address of the corresponding node is updated, but the node's sequence number can remain unchanged.
[0127] In some embodiments, the metadata of the data stored in the inode includes, but is not limited to, modification time, data size, number of data blocks, data block storage address of the data block corresponding to the inode, inode label, file descriptor (FD) of the data corresponding to the snapshot file, and file name of the data corresponding to the snapshot file. The modification time refers to the latest modification time of the data corresponding to the snapshot file, and the size refers to the size of the data corresponding to the snapshot file.
[0128] Referring to Figure 4, information such as modification time, data size, and storage address of the data block corresponding to the inode can be stored in the inode field.
[0129] In some embodiments, the metadata stored in the inode also includes the checkpoint (cp) version number, which can be denoted as cp_ver. Each time a cp is written to the inode, the version number increments; a larger version number indicates newer data.
[0130] It is understandable that the version number of the checkpoint stored in the inode corresponds to the inode.
[0131] Referring again to Figure 4, the version number of the checkpoint can be stored in the inode field at the node_footer position.
[0132] A snapshot can include one or more dnodes. In addition to storing the data block storage addresses of one or more data blocks, a dnode can also store the version number of the checkpoint corresponding to that dnode.
[0133] It's understandable that the version number of the checkpoint stored in the dnode corresponds to itself. Similarly, each time a copy operation is performed on the dnode, the version number increments; a larger version number indicates newer data.
[0134] Referring again to Figure 4, the version number of the dnode checkpoint can be stored in the footer of the dnode.
[0135] In some embodiments, a dnode can store one or more data block storage addresses, each of which can correspond to a block in a storage device.
[0136] In this embodiment of the application, the number of data block storage addresses in a dnode is not specifically limited. For example, the number of data block storage addresses in a dnode can be 128, 256, 512, 1024, etc.
[0137] For example, if data #1 is 20 gigabytes (GB) in size, and assuming a single dnode contains 1024 data block storage addresses, with each data block being 4KB in size, then the data size corresponding to one dnode is 4KB * 1024 = 4MB. Therefore, the snapshot file for data #1 can include 20 * 1024 / 4 = 5120 dnodes, meaning it stores the storage addresses of 5120 * 1024 data blocks.
[0138] It should be noted that the above example assumes each dnode stores 1024 data block storage addresses. However, in some cases, some dnodes may store fewer than 1024 data block storage addresses. In these cases, the snapshot file for data #1 may contain more than 5120 dnodes. Similarly, in some cases, some dnodes may store more than 1024 data block storage addresses. In these cases, the snapshot file for data #1 may contain fewer than 5120 dnodes.
[0139] As described above, the number of dnodes in a snapshot file is related to the size of the data corresponding to the snapshot file. As the size of the data increases, the number of dnodes in the snapshot file corresponding to that data will also increase.
[0140] For example, if data #1 is 20GB at time point #1, its snapshot file can contain 5120 dnodes, each corresponding to 4MB of data. If data #1 increases to 40GB at time point #2, its snapshot file can contain 10240 dnodes, each corresponding to 4MB of data.
[0141] In some embodiments, the first snapshot file may be stored on a cloud server.
[0142] In this embodiment of the application, the source of the cloud service is not specifically limited.
[0143] For example, a cloud server can be a cloud server provided by an electronic device manufacturer.
[0144] For example, a cloud server may be a cloud server provided by the operating system provider of an electronic device.
[0145] For example, the cloud server may be a cloud server provided by the vendor of the application corresponding to the first data.
[0146] For example, the cloud server can be a cloud server provided by a third-party vendor.
[0147] In some embodiments, the first snapshot file may be stored locally on the electronic device.
[0148] It is understandable that, since the first snapshot file is a snapshot file generated when the first data is backed up for the (M-1)th time, the first snapshot file stores the storage addresses corresponding to each data block when the first data is backed up for the (M-1)th time.
[0149] In some embodiments, the (M-1)th backup is a full backup, and the Mth backup can be an incremental backup or a differential backup.
[0150] In some embodiments, the (M-1)th backup is an incremental backup, and the Mth backup can be an incremental backup.
[0151] In some embodiments, the (M-1)th backup is a differential backup, and the Mth backup can be an incremental backup.
[0152] S302, Generate a second snapshot file, which is generated in response to the Mth backup of the first data.
[0153] In this embodiment of the application, when the electronic device performs the Mth backup of the first data, it can also generate a second snapshot file, which is used to indicate the storage location of each data block when performing the Mth backup of the first data.
[0154] It should be noted that there is no fixed order of execution between steps S301 and S302. Step S301 can be executed first and then step S302, or step S302 can be executed first and then step S301, or steps S301 and S302 can be executed simultaneously.
[0155] S303, determine the first data block storage address set based on the first snapshot file and the second snapshot file. The first data block storage address set includes the data block storage addresses corresponding to the data blocks whose data was updated after the first data was backed up for the (M-1)th time.
[0156] As described above, if the first data is updated after the (M-1)th backup, the updated data blocks include the off-site updated data blocks within the first data. These off-site updated data blocks are written to new blocks, meaning their storage addresses are updated. The updated data blocks may also include newly added data blocks after the (M-1)th backup. Furthermore, the updated data blocks may also include deleted data blocks after the (M-1)th backup. Since the first snapshot file stores the storage addresses of the data blocks of the first data during the (M-1)th backup, and the second snapshot file stores the storage addresses of the data blocks of the first data during the (M)th backup, the electronic device can determine the storage addresses of off-site updated data blocks and / or newly added and / or deleted data blocks after the (M-1)th backup by comparing the first and second snapshot files.
[0157] For example, the first snapshot file stores the storage addresses of data block #1, data block #2, and database #3, which are data block storage addresses #1, #2, and #3, respectively. The second snapshot file stores the storage addresses of the updated data block #1, data block #2, data block #3, and the newly added data block #4. The updated data block #1 is stored at data block storage address #4, and the newly added data block #4 is stored at data block storage address #5. Comparing the first and second snapshot files determines that the first set of storage addresses includes data block storage address #4 and data block storage address #5.
[0158] For example, the first snapshot file stores the storage addresses of data block #1, data block #2, and database #3, which are data block storage addresses #1, #2, and #3, respectively. The second snapshot file stores the storage addresses of the updated data block #1, data block #3, and the newly added data block #4. The updated data block #1 is stored at data block storage address #4, and the newly added data block #4 is stored at data block storage address #5. Comparing the first and second snapshot files, it can be determined that the first set of storage addresses includes data block storage addresses #2, #4, and #5.
[0159] S304, determine the first backup package based on the first data block storage address set.
[0160] In this embodiment of the application, the first data block storage address set includes the data block storage addresses that have been updated after the (M-1)th backup and / or the newly added data block storage addresses and / or the deleted data block storage addresses. The electronic device can determine the first backup package based on the first data block storage address set.
[0161] It is understood that the first backup package may include data blocks and / or data block storage addresses. The data blocks may be data blocks that have been updated off-site after the (M-1)th backup and / or newly added data blocks. The data block storage addresses may be the data block storage addresses corresponding to the data blocks that were deleted after the (M-1)th backup.
[0162] For example, the first snapshot file stores the storage addresses of data block #1, data block #2, and database #3, which are data block storage addresses #1, #2, and #3, respectively. The second snapshot file stores the storage addresses of the updated data block #1, data block #2, data block #3, and the newly added data block #4, where the updated data block #1 is stored at data block storage address #4, and the newly added data block #4 is stored at data block storage address #5. Comparing the first and second snapshot files, the first set of storage addresses determined includes data block storage address #4 and data block storage address #5. Since the first set of storage addresses includes data block storage address #4 and data block storage address #5, it can be determined that the first backup package includes the updated data block #1 and data block #4.
[0163] For example, the first snapshot file stores the storage addresses of data block #1, data block #2, and database #3, which are data block storage addresses #1, #2, and #3, respectively. The second snapshot file stores the storage addresses of the updated data block #1, data block #3, and the newly added data block #4, where the updated data block #1 is stored at data block storage address #4, and the newly added data block #4 is stored at data block storage address #5. Comparing the first and second snapshot files, we can determine that the first set of storage addresses includes data block storage addresses #2, #4, and #5. Since the first set of storage addresses includes data block storage addresses #2, #4, and #5, and data block storage address #2 is the storage address of the deleted data block #2, we can determine that the first backup package includes the updated data block #1, data block #4, and data block storage address #2.
[0164] S305 sends the first backup package to the cloud server.
[0165] In this embodiment, when an electronic device performs a backup of the first data that is not the first time, it can obtain the first snapshot file generated during the last backup of the first data and generate a second snapshot file. By comparing the first snapshot file and the second snapshot file, the storage address of the updated data block and / or the storage address of the newly added data block and / or the storage address of the deleted data block can be determined. Then, the backup package can be determined based on the storage address of the updated data block and / or the storage address of the newly added data block and / or the storage address of the deleted data block. This eliminates the need to perform fingerprint calculation on each data block of the first data, saves backup time, and does not cause the electronic device to lag, thus improving the user experience.
[0166] Figure 5 shows a schematic flowchart of the data backup method provided in an embodiment of this application. As shown in Figure 5, in some embodiments, before performing step S302, the method 300 further includes:
[0167] S307, determine whether the size of the first data is less than or equal to the first threshold.
[0168] When the electronic device determines that the size of the first data is less than or equal to the first threshold, it can execute step S308; when it determines that the size of the first data is greater than the first threshold, it can end the process.
[0169] It is understandable that in step S307, the size of the first data during the Mth backup is determined.
[0170] S308, determine whether the first data matches the first snapshot file.
[0171] When the electronic device determines that the first data matches the first snapshot file, it can execute step S309; when it determines that the first data does not match the first snapshot file, it can end the process.
[0172] Understandably, when the first data matches the first snapshot file, it indicates that the first data is associated with the first snapshot file; when the first data does not match the first snapshot file, it indicates that the first data and the first snapshot file are not associated. When the first snapshot file and the first data do not match, since the first data and the first snapshot file are not associated, if the electronic device compares the mismatched first snapshot file with the second snapshot file, the generated comparison result may be incorrect. Therefore, the electronic device can first determine whether the first snapshot file matches the first data before generating the second snapshot file.
[0173] In this embodiment of the application, the information stored in the inode of the first data and the information stored in the inode of the first snapshot file can be compared. When the information is consistent, it can be determined that the first data matches the first snapshot file.
[0174] For example, if the inode number of the first data is the same as the inode number of the first snapshot file, it can be determined that the first data matches the first snapshot file.
[0175] For example, if the filename stored in the inode of the first data is the same as the filename stored in the inode of the first snapshot file, it can be determined that the first data matches the first snapshot file.
[0176] S309, determine if the first snapshot file is complete.
[0177] If the electronic device determines that the first snapshot file is a complete snapshot file, it can proceed to step S302. If it determines that the first snapshot file is incomplete, the process can end.
[0178] Understandably, since the first snapshot file includes data block storage addresses, if the first snapshot file is incomplete, it indicates that some data block storage addresses may be missing, potentially leading to incorrect comparison results. Therefore, electronic devices can ensure the first snapshot file is complete before generating the second snapshot file.
[0179] In this embodiment of the application, a verification value can be calculated on the snapshot content of the first snapshot file using a verification algorithm. Then, the calculated verification value is compared with the file verification value stored in the snapshot file header of the first snapshot file. When the two are the same, it is determined that the first snapshot file is complete.
[0180] It is understandable that this verification algorithm corresponds to the file verification value stored in the snapshot header of the first snapshot file.
[0181] For example, if the file checksum stored in the snapshot header of the first snapshot file is an SHA256 value, then the verification algorithm is SHA256.
[0182] It should be noted that the schematic flowchart shown in Figure 5 is only an example where the electronic device can execute step S307 first, then step S308, and then step S309. In other embodiments of this application, the execution order of steps S307, S308, and S309 is not specifically limited.
[0183] For example, the electronic device can first execute step S309, execute step S308 when it is determined that the first snapshot file is a complete snapshot file, execute step S307 when it is determined that the first snapshot file matches the first data, and execute step S302 when it is determined that the size of the first data is less than or equal to the first threshold.
[0184] In some other embodiments of this application, there is no correlation between steps S307, S308 and S309, that is, the electronic device can independently execute any one or more of the above three steps.
[0185] For example, the electronic device can execute step S307, and when it is determined that the size of the first data is less than or equal to the first threshold, execute step S302.
[0186] For example, the electronic device can execute steps S307 and S308, and execute step S302 when it is determined that the size of the first data is less than or equal to the first threshold and that the first snapshot file matches the first data. It should be noted that in this example, there is no correlation between steps S307 and S308.
[0187] For example, the electronic device can execute steps S307, S308, and S309. When it is determined that the size of the first data is less than or equal to a first threshold, the first snapshot file matches the first data, and the first snapshot file is a complete snapshot file, step S302 is executed. It should be noted that in this example, there is no correlation between steps S307, S308, and S309.
[0188] In some embodiments, as shown in FIG5, before performing step S303, the method 300 further includes:
[0189] S310, determine whether the version numbers of the first snapshot file and the second snapshot file match.
[0190] Both the first and second snapshot files include snapshot file headers. The electronic device can compare whether the version number in the snapshot file header of the first snapshot file is the same as the version number in the snapshot file header of the second snapshot file. When it is determined that the version numbers are the same, step S303 can be executed. When it is determined that the version numbers are inconsistent, the process can be terminated.
[0191] It should be noted that the above description only illustrates the example where the electronic device executes one or more of steps S307, S308, and S309 before executing step S302. In other embodiments of this application, one or more of steps S307, S308, and S309 may be executed after step S302. In other words, the electronic device may execute one or more of steps S307, S308, S309, and S310 after executing step S302 and before executing step S303.
[0192] In the above description, the electronic device can determine the first backup data package by comparing the first snapshot file and the second snapshot file. The method of comparing snapshot files will be described in detail below.
[0193] In this embodiment of the application, since the data block corresponding to a node is updated through off-site update, the node can be updated to the storage address of other nodes. Therefore, when comparing the first snapshot file and the second snapshot file, the node that was updated after the M-1th backup can be found from the first snapshot file and the second snapshot file with the node as the comparison granularity. The data backup is then performed based on the comparison result. The following will be described in detail with reference to Figure 6.
[0194] Figure 6 shows a schematic flowchart of a method for comparing snapshot files provided in an embodiment of this application. This method can be executed by an electronic device or by the processor shown in Figure 1. The following description uses an electronic device as an example. As shown in Figure 6, the method 600 includes:
[0195] S601, determine whether the inode information in the first snapshot file is different from the inode information in the second snapshot file.
[0196] The electronic device may execute step S602 when it is determined that the inode information in the first snapshot file is different from the inode information in the second snapshot file.
[0197] In some embodiments, the inode information includes the modification time.
[0198] The electronic device can compare the modification time in the first snapshot file with the modification time in the second snapshot file. When the modification times in the first snapshot file and the second snapshot file are the same, it is determined that the inode information in the first snapshot file is the same as the inode information in the second snapshot file.
[0199] In some embodiments, the inode information includes the size of the first data.
[0200] The electronic device can compare the size of the first data in the first snapshot file with the size of the first data in the second snapshot file. When the sizes of the first data in the first snapshot file and the first data in the second snapshot file are the same, the inode information in the first snapshot file and the inode information in the second snapshot file are determined.
[0201] In some embodiments, inode information includes the number of data blocks.
[0202] The electronic device can compare the number of data blocks in the first snapshot file with the number of data blocks in the second snapshot file. When the number of data blocks in the first snapshot file and the second snapshot file are the same, it is determined that the inode information in the first snapshot file is the same as the inode information in the second snapshot file.
[0203] In some embodiments, the inode information includes the version number of the checkpoint.
[0204] The electronic device can compare the version number of the checkpoint in the first snapshot file with the version number of the checkpoint in the second snapshot file. When the version numbers of the checkpoints in the first snapshot file and the second snapshot file are the same, it is determined that the inode information in the first snapshot file is the same as the inode information in the second snapshot file.
[0205] It is understood that the above inode information is merely an example and should not be construed as a specific limitation on the embodiments of this application, and the above inode information can be combined with each other.
[0206] For example, inode information includes the modification time and the size of the first data. When the size and modification time of the first data in the first snapshot file and the second snapshot file are the same, it is determined that the inode information in the first snapshot file is the same as the inode information in the second snapshot file.
[0207] For example, inode information includes the modification time, the size of the first data, and the number of data blocks. When the size of the first data, the modification time, and the number of data blocks are the same in the first snapshot file and the second snapshot file, it is determined that the inode information in the first snapshot file is the same as the inode information in the second snapshot file.
[0208] S602, determine a first node set based on the first snapshot file and the second snapshot file, the first node set including the nodes where the first data was updated after the (M-1)th backup of the first data.
[0209] In some embodiments, the node whose first data is updated includes the node corresponding to the data block updated remotely. When the electronic device updates data remotely, the node sequence number of each data block does not change, but the node version number and node storage address do. Therefore, the electronic device can extract and compare the node version number and / or node storage address of the same node sequence number in the first snapshot file and the second snapshot file. When the node version number and / or node storage address of a node are updated, it indicates that some or all of the data blocks in one or more data blocks corresponding to that node have been updated.
[0210] In some embodiments, the node version number can be the version number in the node metadata, i.e., the version number in the ntt_entry field.
[0211] In some embodiments, the node version number can be the version number of the checkpoint corresponding to the node, i.e., cp_ver.
[0212] Checkpoints are used by the file system to store data that has not been written to disk after a power outage or failure, or to recover corrupted data. The file system normally writes to the journal partition sequentially. At regular intervals, data is written to the corresponding location in the file system through the journal partition, and the corresponding metadata's `cp_ver` is updated. Therefore, comparing `cp_ver` can determine whether an update has occurred.
[0213] In some embodiments, since the inode stores the data block storage address, the electronic device also compares the version number and / or storage address of the inode in the first snapshot file and the second snapshot file.
[0214] In summary, in some embodiments, the first node set includes nodes in the first snapshot file and the second snapshot file that have the same node sequence number but different node storage addresses and / or node version numbers.
[0215] The electronic device can determine, based on the comparison results of the first snapshot file and the second snapshot file, that each node in the first snapshot file and the second snapshot file that has the same node number but different node storage address and / or node version number is an element of the first node set.
[0216] For example, the first snapshot file includes first node metadata, which indicates the node number and storage address of the first data during the (M-1)th backup. The second snapshot file includes second node metadata, which indicates the node number and storage address of the first data during the Mth backup. The first node metadata can be represented using Table 1, and the second node metadata can be represented using Table 2. Table 2 shows that the second snapshot file contains four nodes: node number 0 is stored at node storage address #1-1, node number 1 at node storage address #2-2, node number 2 at node storage address #3, and node number 3 at node storage address #4. Comparing Table 1 and Table 2, the electronic device can determine that the storage addresses of nodes with node numbers 0 and 1 are different in the first and second snapshot files.
[0217] Table 2. A node address table
[0218] In some embodiments, if the node where the first data is updated includes newly added nodes, then the first node set includes nodes added after the (M-1)th backup of the first data.
[0219] The electronic device can determine the node that is not in the first snapshot file but is present in the second snapshot file based on the comparison results of the first snapshot file and the second snapshot file. That is, the node added after the (M-1)th backup of the first data.
[0220] For example, the first snapshot file includes first node metadata, which indicates the node number and storage address of the first data during the (M-1)th backup of the first data. The second snapshot file includes second node metadata, which indicates the node number and storage address of the first data during the Mth backup of the first data. The first node metadata can be represented using Table 1, and the second node metadata can be represented using Table 3. Table 3 shows that the second snapshot file contains 5 nodes. The storage address of the node with sequence number 0 is node storage address #1, the storage address of the node with sequence number 1 is node storage address #2, the storage address of the node with sequence number 2 is node storage address #3, the storage address of the node with sequence number 3 is node storage address #4, and the storage address of the node with sequence number 4 is node storage address #5. Comparing Table 1 and Table 3, the electronic device can determine that the node with sequence number 4 in the second snapshot file is a newly added node.
[0221] Table 3. A node address table
[0222] In some embodiments, if the node where the first data is updated includes a deleted node, then the first set of nodes includes the nodes deleted after the (M-1)th backup of the first data.
[0223] The electronic device can determine the node that is present in the first snapshot file but not in the second snapshot file based on the comparison results of the first snapshot file and the second snapshot file. That is, the node that was deleted after the (M-1)th backup of the first data.
[0224] For example, the first snapshot file includes first node metadata, which indicates the node number and storage address of the first data during the (M-1)th backup. The second snapshot file includes second node metadata, which indicates the node number and storage address of the first data during the Mth backup. The first node metadata can be represented using Table 1, and the second node metadata can be represented using Table 4. Table 4 shows that the second snapshot file contains three nodes: node number 0 is stored at node storage address #1, node number 1 at node storage address #2, and node number 2 at node storage address #3. Comparing Tables 1 and 4, the electronic device can determine that node number 3 in the first snapshot file is a deleted node.
[0225] Table 4. A node address table
[0226] S603, determine the data block storage address corresponding to the first node set as the first data block storage address set.
[0227] In some embodiments, the first node set includes nodes in the first snapshot file and the second snapshot file that have the same node sequence number but different node storage addresses and / or node version numbers. Based on this, the electronic device can output a set of data block storage addresses in the second snapshot file for nodes in the first snapshot file and the second snapshot file that have the same node sequence number but different node storage addresses and / or node version numbers.
[0228] For example, comparing Table 1 and Table 2, it can be seen that the electronic device can determine that the storage addresses of nodes with node number 0 and node number 1 in the first snapshot file and the second snapshot file are different. The electronic device can output the storage addresses of the data blocks included in the node with node number 0 and the storage addresses of the data blocks included in the node with node number 1 in the second snapshot file.
[0229] In some embodiments, the first node set includes nodes added after the (M-1)th backup of the first data. Based on this, the electronic device can output the set of data block storage addresses stored in the second snapshot file for the newly added nodes.
[0230] For example, by comparing Table 1 and Table 3, the electronic device can determine that node with node number 4 in the second snapshot file is a newly added node, and the electronic device can output the storage address of the data block included by node with node number 4 in the second snapshot file.
[0231] In some embodiments, the first node set includes nodes deleted after the (M-1)th backup of the first data. Based on this, the electronic device can output the set of data block storage addresses of the deleted nodes stored in the first snapshot file.
[0232] For example, by comparing Table 1 and Table 4, the electronic device can determine that the node with node number 3 in the first snapshot file is a newly added node, and the electronic device can output the storage address of the data block included by the node with node number 3 in the first snapshot file.
[0233] Understandably, in the method shown in Figure 6, the electronic device uses nodes as the comparison granularity. The electronic device can determine the nodes that have been updated and / or added and / or deleted after the first data has been processed for the M-1th time. Then, the electronic device can generate a backup package based on the data block storage address corresponding to the above-mentioned nodes.
[0234] In this embodiment of the application, when the electronic device compares the first snapshot file and the second snapshot file, it can use the node as the comparison granularity. Since the amount of data corresponding to the node is large, the node that has been updated can be quickly determined, which helps to improve the speed of data backup.
[0235] In this embodiment of the application, when the comparison granularity is node, there may be data block storage addresses in the first data block storage address set that have not been updated. Therefore, in some other embodiments of the application, a comparison can be made based on the comparison result determined by node as the comparison granularity, and a more accurate comparison result can be obtained by comparing data block storage address as the comparison granularity. The following will be described in detail with reference to Figure 7.
[0236] Figure 7 shows a schematic flowchart of a method for comparing snapshot files provided in an embodiment of this application. This method can be executed by an electronic device or by the processor shown in Figure 1. The following description uses an electronic device as an example. As shown in Figure 7, the method 700 includes:
[0237] S701, determine whether the inode information in the first snapshot file is different from the inode information in the second snapshot file.
[0238] S702, a first set of nodes is determined based on the first snapshot file and the second snapshot file, the first set of nodes including the nodes where the first data has been updated after the (M-1)th backup of the first data.
[0239] It should be understood that detailed descriptions of steps S701 to S702 can be found in the descriptions of S601 to S602, and for the sake of brevity, they will not be repeated here.
[0240] S703, determine the storage address of the updated data block in each node of the first node set based on the first snapshot file, the second snapshot file and the first node set.
[0241] After determining the first set of nodes, the electronic device indicates that the nodes in the first set are those that have been updated. The electronic device can compare the checkpoint version number of each node in the first set with the node in the first snapshot file and the second snapshot file, and compare the storage address of the data block with the same data block sequence number for each node in the first set with the data block in the first snapshot file and the second snapshot file, thereby determining the storage address of the updated data block in each node.
[0242] In some embodiments, each node stores a data block sequence number, and each data block sequence number corresponds to a data block address. Therefore, the electronic device can compare the storage addresses of data blocks with the same data block sequence number in nodes with the same node sequence number in the first node set.
[0243] In some embodiments, the data block number may be generated when traversing and comparing nodes with the same node number.
[0244] Understandably, for the same node, when one or more data blocks corresponding to that node are deleted, by comparing the information of that node in the first snapshot file and the second snapshot file, the storage address of the data block corresponding to the specific data block that was deleted can be determined.
[0245] Similarly, for the same node, when a new data block storage address is added to the node, the specific new data block storage address can be determined by comparing the information in the first snapshot file and the second snapshot file.
[0246] In some embodiments, when the first node set includes a deleted node, the storage address of the data block stored in the first snapshot file of the deleted node is the storage address of the updated data block.
[0247] In some embodiments, when the first node set includes a newly added node, the storage address of the data block of the newly added node in the second snapshot file is the storage address of the updated data block.
[0248] S704, determine the first data block storage address set based on the updated data block storage address of each node in the first node set.
[0249] As analyzed above, when a data block is updated, its corresponding data block storage address will also be updated. Therefore, based on the determination that a node has been updated, the electronic device can compare the information stored in the first snapshot file and the second snapshot file of that node, thereby further determining the specific storage address of the updated data block in that node.
[0250] In some embodiments, the set of data block storage addresses includes the storage addresses of data blocks in the first data that have been remotely updated after the (M-1)th backup of the first data. It is understood that in these embodiments, the data block storage addresses are the data block storage addresses recorded in the second snapshot file.
[0251] In some embodiments, the set of data block storage addresses includes the storage addresses of data blocks newly added to the first data after the (M-1)th backup of the first data. It is understood that in these embodiments, the data block storage addresses are the data block storage addresses recorded in the second snapshot file.
[0252] In some embodiments, the set of data block storage addresses includes the storage addresses of data blocks deleted from the first data after the (M-1)th backup of the first data. It is understood that in these embodiments, the data block storage addresses are the data block storage addresses recorded in the first snapshot file.
[0253] Understandably, in the method shown in Figure 7, the electronic device first uses the node as the comparison granularity to determine the set of nodes that have been updated, and then it can use the data block storage address as the comparison granularity to determine the storage address of the updated data block in each node. Compared with the method shown in Figure 6, the method shown in Figure 7 is more accurate.
[0254] In this embodiment of the application, when the electronic device compares the first snapshot file and the second snapshot file, it can first compare at the node level to determine the set of nodes that have been updated. Since the amount of data corresponding to a node is large, the updated node can be quickly determined, which helps to improve the speed of data backup. Then, the electronic device uses the data block storage address as the comparison granularity to find the updated data block storage address from the set of updated nodes, thereby improving the accuracy of data backup.
[0255] The method for backing up data provided in the embodiments of this application has been described in detail above. In the various embodiments of this application, unless otherwise specified or in case of logical conflict, the terminology and / or descriptions between the various embodiments are consistent and can be referenced by each other. The technical features in different embodiments can be combined to form new embodiments according to their inherent logical relationships.
[0256] The foregoing primarily describes a data backup method provided by the embodiments of this application from the perspective of an electronic device. It is understood that, in order to achieve the above functions, the electronic device includes corresponding hardware structures and / or software modules for executing each function. Those skilled in the art should readily recognize that, based on the algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art 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.
[0257] Figure 8 shows a schematic flowchart of a data backup method provided in an embodiment of this application. As shown in Figure 8, the electronic device includes a first application, a backup service module, a cloud backup module, a differential module, and a file system. The method includes:
[0258] S801, the first application launches the first process.
[0259] In some embodiments, the first application may launch a first process in response to a user-triggered backup operation. This first process is the process corresponding to the backup service module.
[0260] In some embodiments, the first application may launch the first process in response to the fulfillment of a triggering condition.
[0261] For example, the trigger condition is that the time since the last backup is greater than or equal to a threshold.
[0262] S802, the first application sends the file descriptor of the first data to the cloud backup module.
[0263] In some embodiments, the first application may directly send the file descriptor of the first data to the cloud backup module.
[0264] In some embodiments, the first application can send the file descriptor of the first data to the cloud backup module through the backup service module.
[0265] S803, the cloud backup module sends the file descriptor of the first data, the path of the first data, the path of the first snapshot file, and the path of the second snapshot file to the differential module.
[0266] It is understandable that, since the file system has not yet filled the snapshot content into the second snapshot file when the cloud backup module executes step S803, the content of the second snapshot file corresponding to the path of the second snapshot file sent by the cloud backup module is blank.
[0267] For example, the cloud backup module can send the above information to the differential module by calling the GetFileDiff interface.
[0268] S804, the differential module sends the file descriptor of the first data, the file descriptor of the first snapshot file, and the first identification information to the file system.
[0269] The first identification information is used to indicate whether the first data is the data from the first backup.
[0270] For example, the differential module can send the above information by calling the iocl interface.
[0271] In some embodiments, before executing step S804, the differential module may also verify whether the file descriptor of the first data matches the path of the first file, and if they match, execute step S804.
[0272] In some embodiments, before executing step S804, the differential module may also lock the first data according to the path of the first data.
[0273] S805, the file system writes the snapshot content to the second snapshot file.
[0274] The file system can read the file descriptor of the first data to determine the node information pointing to the first data, and then write the snapshot content to the second snapshot file according to the snapshot file format.
[0275] In some embodiments, before executing step S805, the differential module can determine whether the first data is data updated remotely. When it is determined that the first data is data updated remotely, step S805 can be executed.
[0276] S806, the differential module determines the first data block storage address set based on the first snapshot file and the second snapshot file.
[0277] S807, the differential module sends the first data block storage address set to the cloud backup module.
[0278] S808, the cloud backup module generates the first backup package based on the first data block storage address set.
[0279] It should be understood that the descriptions of steps S806 to S808 can be found above, and for the sake of brevity, they will not be repeated here.
[0280] S809, the cloud backup module sends the first backup package to the cloud server.
[0281] S810, the cloud backup module deletes the first snapshot file.
[0282] After the cloud backup module determines the first data packet, it can send the first data packet to the cloud server, and then delete the first snapshot file.
[0283] This application provides a computer program product that, when run on an electronic device, causes the electronic device to execute the technical solutions described in the above embodiments. Its implementation principle and technical effects are similar to those of the related embodiments described above, and will not be repeated here.
[0284] This application provides a readable storage medium containing instructions that, when executed by an electronic device, cause the electronic device to perform the technical solution described in the above embodiments. The implementation principle and technical effects are similar and will not be repeated here.
[0285] This application provides a chip for executing instructions. When the chip is running, it executes the technical solutions described in the above embodiments. Its implementation principle and technical effects are similar and will not be repeated here.
[0286] Those skilled in the art will recognize that the units and algorithm steps of the various examples 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 implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of this application.
[0287] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0288] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0289] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0290] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0291] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, essentially, or the parts that contribute to the prior art, or parts of the technical solutions, can be embodied in the form of software products. These computer software products are stored in a storage medium and include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0292] The above description is merely a specific implementation of the embodiments of this application, but the protection scope of the embodiments of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the embodiments of this application should be included within the protection scope of the embodiments of this application. Therefore, the protection scope of the embodiments of this application should be determined by the protection scope of the claims.
Claims
1. A method for backing up data, characterized in that, The method includes: When performing the Mth backup of the first data, a first snapshot file is obtained and a second snapshot file is generated. The first snapshot file is a snapshot file generated when performing the (M-1)th backup of the first data. The first snapshot file includes the data block storage address of the data block of the first data when performing the (M-1)th backup of the first data. The second snapshot file includes the data block storage address of the data block of the first data when performing the Mth backup of the first data. M≥2 and is an integer. A first data block storage address set is determined based on the first snapshot file and the second snapshot file. The first data block storage address set includes the data block storage addresses corresponding to the data blocks whose data was updated after the (M-1)th backup of the first data. The first backup package is determined based on the first set of data block storage addresses; Send the first backup package to the cloud server.
2. The method according to claim 1, characterized in that, The step of determining the first data block storage address set based on the first snapshot file and the second snapshot file includes: A first node set is determined based on the first snapshot file and the second snapshot file. The first node set includes nodes where the first data is updated after the first data is backed up for the (M-1)th time. Each node in the first node set corresponds to one or more data block storage addresses. The storage address of the data block corresponding to the first node set is determined as the first data block storage address set.
3. The method according to claim 1, characterized in that, The step of determining the first data block storage address set based on the first snapshot file and the second snapshot file includes: A first node set is determined based on the first snapshot file and the second snapshot file. The first node set includes nodes where the first data is updated after the first data is backed up for the (M-1)th time. Each node in the first node set corresponds to one or more data block storage addresses. The storage address of the updated data block in each node of the first node set is determined based on the first snapshot file, the second snapshot file, and the first node set. The storage address of the updated data block in each node of the first node set includes the storage address of the data block corresponding to the remotely updated data block and / or the storage address of the deleted data block and / or the storage address of the newly added data block. The first data block storage address set is determined based on the updated data block storage address of each node in the first node set.
4. The method according to claim 2 or 3, characterized in that, The nodes where the first data is updated include the nodes corresponding to the data blocks updated remotely and / or the deleted nodes and / or the newly added nodes.
5. The method according to any one of claims 1 to 4, characterized in that, Before generating the second snapshot file, the method further includes: The size of the first data is determined to be greater than or equal to the first threshold.
6. The method according to any one of claims 1 to 5, characterized in that, Before generating the second snapshot file, the method further includes: It is determined that the first data matches the first snapshot file.
7. The method according to claim 6, characterized in that, The step of determining that the first data matches the first snapshot file includes: When the node information of the first data matches the node information stored in the first snapshot file, it is determined that the first data matches the first snapshot file.
8. The method according to any one of claims 1 to 7, characterized in that, Before generating the second snapshot file, the method further includes: The first snapshot file is determined to be a complete snapshot file.
9. The method according to any one of claims 1 to 8, characterized in that, Before determining the first data block storage address set based on the first snapshot file and the second snapshot file, the method further includes: It is determined that the version number of the first snapshot file is the same as the version number of the second snapshot file.
10. An electronic device, characterized in that, It includes one or more processors; one or more memories; said one or more memories storing one or more computer programs, said one or more computer programs including instructions that, when executed by said one or more processors, cause the method of any one of claims 1 to 9 to be performed.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed on a computer, cause the method as described in any one of claims 1 to 9 to be performed.
12. A chip, characterized in that, The chip includes a processor and a communication interface, the communication interface being used to receive signals and transmit the signals to the processor, the processor processing the signals such that the method as described in any one of claims 1 to 9 is executed.
13. A computer program product, characterized in that, When the computer program product is run on a computer, it causes the computer to perform the method as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Backup method, system and device for ceph distributed block storage
CN112650447A
Data processing method and device, computer equipment, storage medium and program product
CN115344428A
Hierarchical storage data migration method and related device
CN117807022A
Data backup method, electronic equipment, storage medium and chip
CN120066848A
Forever incremental backups for database and file servers
US20190179711A1
Cited By
Multi-participant cloud collaboration management method and system for construction project
CN122264743A