Data backup method, device, electronic device and storage medium

By backing up the data between the starting address and the backup address during the data backup process of shared memory, and using the backup address as a new starting address, the problem of backup time and system lag in the existing technology is solved, and efficient data writing and backup is achieved.

CN114064357BActive Publication Date: 2025-08-12SHENZHEN HUABAO ELECTRONICS TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111339699.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-12
Publication Date
2025-08-12
Estimated Expiration
2041-11-12

AI Technical Summary

Technical Problem

In the process of data backup of shared memory, the backup takes a long time and is prone to block other processes, resulting in system lag and low writing and backup efficiency.

Method used

When writing data to the backup address of memory, the data between the starting address and the backup address is backed up, and the backup address is used as the new starting address to redetermine the backup address of memory, so that the data backup is carried out simultaneously with the next piece of data writing.

Benefits of technology

Reduces additional waiting time for data backup, improves the efficiency of data writing and backup, and avoids system lag.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114064357B_ABST
    Figure CN114064357B_ABST
Patent Text Reader

Abstract

The embodiments of the present invention disclose a data backup method, device, electronic device and storage medium. The method includes: writing data into the memory starting from the starting address; when writing to the backup address of the memory, backing up the data between the starting address and the backup address; using the backup address as the new starting address, and re-determining the backup address of the memory, and returning to execute the operation of writing data into the memory starting from the starting address. Compared with the prior art of backing up data after determining that the memory is full, the backup time takes a long time and blocks other processes; the technical solution provided by the embodiment of the present invention sets the backup address, backs up the data between the starting address and the backup address, and uses the backup address as the new starting address to write data, so that the backup of the current segment of data and the writing of the next segment of data are carried out simultaneously, reducing the extra waiting time for data backup, improving the efficiency of data writing and backup, and avoiding system freezes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of data processing technology, and in particular to a data backup method, device, electronic device, and storage medium. Background Art

[0002] Shared memory is frequently used for multi-process information transmission or to cache system debugging information. It handles large data volumes and high concurrent access. Shared memory generally records the size of shared memory allocated, the access boundaries set by mutual exclusion semaphores, and concurrency control. Typically, the writable limit of shared memory is equal to the memory size. Traditional backup methods for writing shared memory trigger data backups when the memory is deemed full. This results in large single backups, long backup times, and the blocking of other processes, which can easily lead to various system anomalies. However, in scenarios with large code volumes, high concurrent writes, and large data volumes, this backup method results in low data writing and backup efficiency, making it prone to overwriting boundaries and system lag. Summary of the Invention

[0003] Embodiments of the present invention provide a data backup method, device, electronic device, storage medium, and system to reduce the extra waiting time for data backup, improve the efficiency of data writing and backup, and avoid system freezes.

[0004] In a first aspect, an embodiment of the present invention provides a data backup method, comprising:

[0005] Write data to the memory starting from the starting address;

[0006] When writing to the backup address of the memory, backing up the data between the start address and the backup address;

[0007] The backup address is used as a new starting address, and the backup address of the memory is re-determined, and the operation of writing data into the memory starting from the starting address is returned to be executed.

[0008] In a second aspect, an embodiment of the present invention provides a data backup device, comprising:

[0009] A first writing module, used for writing data into the memory starting from the starting address;

[0010] A backup module, configured to back up data between the start address and the backup address when writing to the backup address of the memory;

[0011] The second writing module is configured to use the backup address as a new starting address, re-determine the backup address of the memory, and return to execute the operation of writing data into the memory starting from the starting address.

[0012] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:

[0013] one or more processors;

[0014] a storage device for storing one or more programs;

[0015] When the one or more programs are executed by the one or more processors, the one or more processors implement the data backup method as described in the first aspect.

[0016] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, which, when executed by a processor, implements the data backup method as described in the first aspect.

[0017] The embodiment of the present invention discloses a data backup method, device, electronic device and storage medium. The method includes: writing data into the memory starting from the starting address; when writing to the backup address of the memory, backing up the data between the starting address and the backup address; using the backup address as the new starting address, and re-determining the backup address of the memory, and returning to execute the operation of writing data into the memory starting from the starting address. Compared with the prior art of backing up data after judging that the memory is full, the backup time is long and blocks other processes, and various system abnormalities are prone to occur; the technical solution provided by the embodiment of the present invention sets the backup address, backs up the data between the starting address and the backup address, and uses the backup address as the new starting address to write data, so that the backup of the current segment of data and the writing of the next segment of data are carried out simultaneously, reducing the extra waiting time for data backup, improving the efficiency of data writing and backup, and avoiding system freezes. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 A flowchart of a data backup method provided in Example 1 of the present invention;

[0019] Figure 2 This is an example diagram of re-determining the backup address in the data backup method provided in the first embodiment of the present invention;

[0020] Figure 3 This is an example diagram of the data backup process in the data backup method provided in the first embodiment of the present invention;

[0021] Figure 4 A structural block diagram of a data backup device provided in Embodiment 2 of the present invention;

[0022] Figure 5 This is a structural diagram of an electronic device provided in Example 3 of the present invention. DETAILED DESCRIPTION

[0023] The present invention will be further described in detail below with reference to the accompanying drawings and examples. It will be understood that the specific embodiments described herein are intended only to illustrate the present invention and are not intended to limit the present invention. It should also be noted that, for ease of description, the accompanying drawings only illustrate portions relevant to the present invention, not all structures.

[0024] Example 1

[0025] Figure 1 This is a flowchart of a data backup method provided in the first embodiment of the present invention. This embodiment is applicable to the case where data backup is performed during the process of writing data to the memory. The method can be executed by a data backup device and is generally integrated into an electronic device. The electronic device includes but is not limited to: desktop computers, laptops, smart phones, and servers. Figure 1 As shown, the method specifically includes the following steps:

[0026] S110 , writing data into the memory starting from the starting address.

[0027] Among them, the memory can refer to a storage space for writing data. The memory in this embodiment can be a shared memory (Shared Memory), that is, a large-capacity memory that can be accessed by different central processing units (CPUs). The starting address can be specifically understood as the address where data starts to be written. In this embodiment, data can be written to the memory in batches, and each time the written data needs to be backed up, it can be considered that the writing of data is completed. For the opened memory, when writing data to the memory for the first time, the memory opening starting address, such as the first byte in the memory, can be used as the starting address; if it is the second or nth (n is an integer greater than 2) time to write data to the memory, the starting address can be re-determined based on the location where the data was written last time.

[0028] S120 . When writing to the backup address of the memory, back up the data between the start address and the backup address.

[0029] The backup address can be specifically understood as a node for data backup. During a data writing process, the area from the start address to the backup address is the backup size.

[0030] Specifically, each time the backup address of the memory is written, the data between the current starting address and the backup address is backed up. It should be noted that backing up data each time after writing to the backup address does not affect continuing to write data to the memory.

[0031] S130: Use the backup address as a new starting address, re-determine the backup address of the memory, and return to execute the operation of writing data into the memory starting from the starting address.

[0032] The current backup address is used as the starting address for the next data write. The new backup address can be understood as the node for the next data backup, used to determine when the next data write should be backed up. For example, the new backup address can be equal to the starting address of the next backup plus the backup size. This backup size can be consistent with the backup size of the current backup data, or it can be dynamically adjusted, for example, based on the speed of backing up data and the speed of writing data, to achieve a better balance between data backup and data writing.

[0033] For example, the first time data is written, it is written from the starting address (0000) to the backup address (0900), and then the 900 bytes of data written from 0000 to 0900 are backed up, and the backup address (0900) is used as the new starting address;

[0034] When writing data for the second time, the backup address needs to be re-determined. For example, the new starting address (0900) needs to be added to the backup size. If the backup size is the same as the first backup size, which is 900, then the new backup address is 0900 + 900 = 1800. Based on this, while backing up the data from 0000 to 0900, data can be written from 0900 until 1800. At this time, the 900 bytes of data written from 0900 to 1800 can be backed up, and the backup address (1800) can be used as the new starting address to continue writing data. Similarly, data backup and writing can be performed independently and synchronously.

[0035] It is clear that the memory in the present embodiment can be a circular buffer (buf). When data is written to the specified boundary position of the memory, it can return to continue writing data from the opening start address (0000), that is, for the circular buf, the next byte after the specified boundary position is the opening start address. Wherein, the specified boundary position can be the opening end address of the memory, or it can be the specified address before the opening end address, also known as the boundary address, for example, 1 byte is advanced for the opening end address, so as to reserve a certain memory space. This section of memory does not support data writing, thereby effectively preventing crossing the boundary. Exemplary, if the opening size is 1000, the memory opened is 0000-0999, and the specified boundary position is 0998, then in the above example, when writing data for the second time, the backup address 1800 needs to be converted to the position in the circular buf, that is, from 0900 to 0998, and then it will return to continue writing data from 0000 until it writes to 0802 (i.e. 1800-998), backing up the data written for the second time.

[0036] Specifically, each time the backup address of the memory is written, the data written this time can be backed up by the first thread, and another thread, that is, the second thread, can be used to continue writing data to the memory starting from the new starting address (that is, the backup address of this time). The first thread and the second thread are executed independently, and the backup of this data and the writing of the next data do not affect each other. Alternatively, the data backup operation can be performed by a background thread, and the data writing operation can be performed by the main process. The main process does not need to pay attention to data backup, so that the written data and the backup data are processed separately; while backing up, it does not affect the continued writing of data to the memory.

[0037] The embodiment of the present invention discloses a data backup method, device, electronic device and storage medium. The method includes: writing data into the memory starting from the starting address; when writing to the backup address of the memory, backing up the data between the starting address and the backup address; using the backup address as the new starting address, and re-determining the backup address of the memory, and returning to execute the operation of writing data into the memory starting from the starting address. Compared with the prior art of backing up data after judging that the memory is full, the backup time is long and blocks other processes, and various system abnormalities are prone to occur; the technical solution provided by the embodiment of the present invention sets the backup address, backs up the data between the starting address and the backup address, and uses the backup address as the new starting address to write data, so that the backup of the current segment of data and the writing of the next segment of data are carried out simultaneously, reducing the extra waiting time for data backup, improving the efficiency of data writing and backup, and avoiding system freezes.

[0038] As an optional embodiment of the present invention, based on the above embodiment, the step of writing data into the memory starting from the starting address can be specifically expressed as follows: when writing to the boundary address of the memory, if the data backup between the starting address and the backup address has been completed, then continue to write data from the allocated starting address of the memory.

[0039] Specifically, during the development process, when users write data or process data into the opened memory, they sometimes ignore that the array index starts from 0, which leads to code vulnerabilities and out-of-bounds writes. In this embodiment, the boundary address is set before the opening end address. The boundary address can be specifically understood as the end address that can be used to write data; the opening start address can be specifically understood as the starting point of the opened memory; and the opening end address can be specifically understood as the end point of the user's memory opening. The memory size between the opening start address and the opening end address is the opening size, and the memory size between the opening start address and the boundary address is the boundary size. The opening size is transparent to the user, and the boundary size is the memory size known to the user. In order to prevent the user from crossing the boundary when using it, a memory amount is reserved between the boundary address and the opening end address. Among them, the boundary address is smaller than the opening end address of the memory, and data writing is not supported between the boundary address and the opening end address.

[0040] For example, if 1000 bytes of memory are allocated, the array index access range is 0-999, and the allocation size of 1000 is transparent to the user. If the bounding size is less than the allocation size, the bounding size can be set to 998, and the bounding size is known to the user.

[0041] Specifically, writing to the memory boundary indicates that the memory usage has reached its limit. During a data write, the data previously written to the memory is being backed up. Once the backup is complete, the corresponding memory can be cleared and used for writing data. Therefore, the entire memory space can be considered recyclable. If the data between the starting address and the backup address is backed up, indicating that the previous memory is free for use, data can be written to the newly allocated starting address.

[0042] As an optional embodiment of the embodiment of the present invention, based on the above embodiment, the step of re-determining the backup address of the memory can be specifically expressed as follows:

[0043] S131, predicting the first time of writing from the backup address to the writable address of the memory;

[0044] S132: Re-determine the backup address of the memory according to the first time and the second time required for backing up the data.

[0045] The writable address can be understood as the maximum address that can be written to during a data write process, before the memory address occupied by the previously written data is written. It is understood that the writable address is less than the memory allocation end address; a boundary address can also be set to prevent overruns. In this case, the writable address can be less than or equal to the memory boundary address. The writable address is used to predict the first time to continue writing from the backup address to the writable address. The memory between the allocation start address and the available address represents the writable size, which is less than or equal to the boundary size.

[0046] For a loop buf, the estimated first time required to write data is the time required to write from the backup address to the writable address, where the writable address is related to the starting address corresponding to the current backup address. It can also be understood that the writable address is related to the starting address occupied by the last written data (or the starting address of the last written data, i.e., the "old" starting address). For example, the last time was from the (old) starting address 0900 to the boundary address and then returned from the opening starting address 0000 to write to the backup address 0802. In the prediction process of this data write, 0802 is used as the new starting address, and the first time required to write from 0802 to the writable address is predicted, where the writable address is equal to the (old) starting address 0900 of the last write data, or is a number of bytes ahead of the (old) starting address of the last write (for example, 0900 is 8 bytes ahead, i.e., 0892). Because during the current data writing process, the backup of the data written last time may not have been completed, the purpose of the prediction is to determine whether the backup speed of the data written last time is faster or the speed of writing to the writable address this time is faster; if the backup speed of the data written last time is faster, then when writing to the writable address this time, the backup of the data written last time can be completed, and the memory can be released for use by the data written this time; otherwise, when writing to the writable address this time, it is necessary to wait until the backup of the data written last time is completed and the corresponding memory is released before continuing to write data.

[0047] Specifically, the time it takes to write from the backup address to the writable address is related to the amount of memory between the backup address and the writable address and the data writing speed. The time it takes to write from the backup address to the writable address can be calculated by dividing the amount of memory between the backup address and the writable address by the data writing speed. The data writing speed can be determined by referring to the speed at which the backup data was previously written to the memory.

[0048] The second time required to back up data is related to the hard drive's usage and system environment. In this embodiment, a cache exists between the backup address and the writable address. This cache affects how long the system can operate without lags during peak activity. If the cache is too small, the system will experience lags while waiting for backups during busy periods. If the cache is too large, and the system is idle, the system will frequently back up, wasting available space.

[0049] Specifically, the first time is compared with the second time required to back up the data, and the memory backup address is re-determined based on the difference between the first and second times. If the first time is less than or close to the second time, it means that data backup is slow relative to data writing, which may cause system lag and require a smaller backup address. If the first time is much greater than the second time, it means that the backup is fast relative to data writing, and the backup address can be increased to reduce the system backup frequency. If the first time is greater than the second time and within the preset range, it means that data backup and writing are relatively stable and the backup size can be kept unchanged.

[0050] Optionally, the difference between the writable address and the boundary address is a preset memory amount, or the difference between the writable address and the start address corresponding to the backup address is a preset memory amount.

[0051] The writable address is used to predict the first time, and then, based on the first time and the second time required to back up the data, it can be determined whether the backup size needs to be adjusted. The writable address is the boundary address minus the preset memory amount, or the (old) starting address corresponding to the backup address minus the preset memory amount.

[0052] If the preset memory amount is not zero, it means that a buffer can be left between the writable address and the boundary address (or the starting address corresponding to the backup address). On this basis, the writable address can be used as the boundary limit for the data written this time, that is, in the process of writing data this time, it can be written to the writable address at most. The reserved address between the writable address and the boundary address (or the starting address corresponding to the backup address) does not support writing data, thereby preventing cross-border occurrence during each data writing process. The preset memory amount can also be zero, that is, the writable address is equal to the boundary address (or the starting address corresponding to the backup address). In this case, the boundary address (or the starting address corresponding to the backup address) can be directly used as the boundary limit for the data written this time.

[0053] It should be noted that, in this embodiment, only when the data written for the first time is backed up, the prediction of the data written for the second time satisfies the preset memory amount difference between the writable address and the boundary address, thereby restricting the user from writing to the boundary size; starting from the second time the data written is backed up, the prediction of each data write satisfies: the preset memory amount difference between the writable address and the starting address (of the last written data) corresponding to the backup address.

[0054] Optionally, predicting the first time of writing from the backup address to the writable address in the memory, including:

[0055] S1311. Calculate the data writing speed based on the amount of memory between the starting address corresponding to the backup address and the backup address, and the time taken to write from the starting address corresponding to the backup address to the backup address.

[0056] In this step, the data writing time from the starting address corresponding to the backup address (i.e., the previous or old starting address) to the backup address depends on the system operating environment and the specific applications encountered during this period. For example, if a certain memory is used for black box data recording and there is frequent operation over a period of time, the data writing speed will be very fast, and the time to write a fixed size will be very short. This time needs to be obtained through statistical analysis.

[0057] Specifically, the data writing speed can be calculated by dividing the amount of memory between the (last) starting address and the backup address by the time it takes to write from the starting address to the backup address.

[0058] For example, if the amount of memory between the (previous) starting address and the backup address is represented by K1, and the time it takes to write from the starting address to the backup address is represented by H1, then the data write speed V1 can be calculated as: V1 = K1 / H1. A larger H1 indicates a more idle system; a smaller H1 indicates a busier system. For example, if the first data write, from 0000 to 0900, takes 1 second, then V1 = 900 / 1 = 900 B / s.

[0059] S1312: Predict the first time of writing from the backup address to the writable address of the memory based on the amount of memory between the backup address and the writable address (this time) and the writing speed.

[0060] Specifically, the amount of memory between the backup address and the writable address (this time) is divided by the write speed, and the calculated quotient can be used as a reference value for writing from the backup address to the writable address in the memory, which is recorded here as the first time. For example, continuing with the example in S1311, if the amount of memory between the backup address and the writable address (this time) is represented as K2, and the write speed obtained in step S1311 is V1, then the predicted first time H2 for writing data to the writable address can be expressed as: H2 = K2 / V1. For example, if the second data write is predicted, from 0900 to 0990, then H2 = (990-900) / 900 = 0.1s.

[0061] Optionally, the backup address of the memory is re-determined based on the first time and the second time required to back up the data, including: if the first time is greater than the second time, and the difference between the first time and the second time is greater than or equal to a set threshold, then the backup address of the memory is adjusted according to the direction of writing data to increase the amount of data backed up in a single time.

[0062] Specifically, if the first time is greater than the second time, and the difference between the first and second times is greater than or equal to the set threshold, the backup speed can meet the cyclic write requirements. If the backup speed is fast enough and each data write takes a long time, it indicates that the cache area between the backup address and the writable address is large, and the system is in a relatively leisurely state, which may lead to frequent system backups and waste of available space. In this case, the memory backup address can be adjusted in the direction of data write, that is, backward adjustment or in the direction of increasing address numbers, thereby increasing the amount of data backed up in a single backup, reducing the system's backup frequency, and saving computing resources.

[0063] Optionally, the difference between the first time and the second time is greater than or equal to a set threshold, and the second time can be set to be greater than 2 times the first time, so that a better balance is achieved between data backup and writing, fully ensuring that when writing to a writable address this time, the data written last time can be backed up, and the memory can be released for use in the current writing of data; it can also avoid a small amount of single backup data, reduce the backup frequency, and save computing resources.

[0064] Optionally, the backup address of the memory is re-determined based on the first time and the second time required to back up the data, including: if the first time is less than or equal to the second time, or the difference between the first time and the second time is less than a set threshold, then the backup address of the memory is adjusted in the opposite direction of writing the data to reduce the amount of data backed up in a single time.

[0065] The premise for backup not to affect continued data writing is: backup time < the time it takes to write data to the usable memory (writable address - backup address space). In other words, the larger the memory between the backup address and the writable address, the longer the backup time can be supported.

[0066] Specifically, if the first time is less than or equal to the second time, or the difference between the first and second times is less than the set threshold, it means that the backup speed cannot meet the needs of cyclic writing. After the user writes to the writable address, the backup has not yet completed. It is very likely that the user needs to wait for the backup to complete before returning to the allocated starting address to continue writing data. The cache area between the backup address and the writable address is too small, and the system will experience lags while waiting for the backup when it is busy. In this case, the backup size can be reduced. The backup address of the memory needs to be adjusted in the opposite direction of the data being written, that is, adjusted forward or in the direction of decreasing address numbers, thereby reducing the amount of data backed up in a single time and avoiding lags.

[0067] Take the case where the memory is allocated with a size of 1000, a boundary address of 0998, and a circular buf as an example. The first time data is written, it is written from the starting address (0000) to the backup address (0900). Then the 900 bytes of data written from 0000 to 0900 are backed up, and the backup address (0900) is used as the new starting address.

[0068] For the second write of data, the process of re-determining the backup address by predicting the first time is as follows:

[0069] First, predict the first time of the second write from the backup address 0900 to the writable address. The writable address can be less than or equal to the boundary address 0998. For example, if the difference is 8, the writable address is 0990.

[0070] If the second time taken to back up data from 0000 to 0900 is significantly shorter than the first time taken to write from 0900 to 0990, this indicates that the backup speed can meet the requirements of cyclic writing, fully ensuring that after the user writes to the writable address, it can continue to write to the boundary address and return to write data from 0000. Therefore, the backup size can remain unchanged and can be 0900+900. The new backup address in the cyclic buf is 0802. (If the backup speed is fast enough, for example, the second time is less than 1 / 2 of the first time, the backup size can be appropriately increased, for example, the new backup address can be determined as 0810, thereby increasing the single backup volume, reducing the backup frequency, and saving computing resources).

[0071] If the second time is greater than the first time, it means that the backup speed cannot meet the needs of cyclic writing. After the user writes to the writable address, the backup has not yet completed. It is very likely that the user needs to wait for the backup to complete before returning to write data from 0000. In this case, the backup size can be reduced, for example, to 0900+890. The new backup address in the cyclic buf is 792, thereby reducing the backup amount and shortening the waiting time for cyclic writing.

[0072] During the process of backing up the data from 0000 to 0900, you can continue to write data from 0900. After writing to 0998, if the data backup from 0000 to 0900 is completed, you can return to continue writing data from 0000 until it reaches 0802. You can back up the data from 0900 to 0998 and 0000 to 0802, and then use 0802 as the new starting address.

[0073] In order to more clearly describe the embodiments of the present invention, Figure 2 This is an example diagram of re-determining the backup address in the data backup method provided in the first embodiment of the present invention. Figure 2 As shown in the figure, the memory allocation size is 1000, the allocation start address is (0000), the start address is (0000), the backup address is (0900), the writable address is (0990), the boundary address is (0998), the allocation end address is (1000), and the memory is a loop buf. Among them, the amount of memory between the allocation start address and the end allocation address represents the allocation size; the amount of memory between the start address and the writable address represents the writable size; and the amount of memory between the start address and the backup address represents the backup size.

[0074] The first time data is written, it is written from the start address (0000) to the backup address (0900), and then the 900 bytes of data written from 0000 to 0900 are backed up.

[0075] When writing data for the second time, the start address, boundary address, and end address remain unchanged. What needs to be re-determined are the new start address, backup address, and writable address. The backup address (0900) of the first data write can be used as the new start address. The new start address (0900) is added to the backup size. For example, if the backup size is the same as the first backup size, which is 900, the new backup address is 0900+900=1800. The backup address 1800 needs to be converted into a position in the loop buf, that is, writing from 0900 to 0998, then returning to 0000 to continue writing data until writing to 0802 (i.e., 1800-998), that is, the new backup address is determined to be (0802). If the preset memory capacity is 8 bytes, then for this data write starting from 0802, the writable address is the previous start address 0900-8=0882. It is understandable that the redetermination of the backup address can also take into account the backup speed of the first data write and the speed of writing to the writable address this time.

[0076] Figure 3 This is an example diagram of the data backup process in the data backup method provided in the first embodiment of the present invention. Figure 3As shown, multiple processes can share multiple memory blocks for writing and backing up data. A daemon process can monitor memory usage and initiate data backup when data is written to the memory backup address. While data is being backed up, other processes can continue writing data. After the data backup is complete, the backup address, writable address, and starting address can be redefined.

[0077] An optional embodiment of the present invention prevents users from writing data out of bounds by reserving memory between the writable address and the boundary address, and between the boundary address and the allocation end address. Furthermore, by comparing the first time with the second time required for data backup, the memory backup address is re-determined, preventing system freezes or excessive backup frequency, achieving a balance between data backup and writing, and improving backup and writing efficiency.

[0078] Example 2

[0079] Figure 3 This is a structural block diagram of a data backup device provided in the second embodiment of the present invention. The device is suitable for performing data backup. The device can be implemented by hardware and / or software and is generally integrated into an electronic device. Figure 3 As shown, the device includes: a first writing module 21, a backup module 22, and a second writing module 23.

[0080] A first writing module 21 is used to write data into the memory starting from the starting address;

[0081] A backup module 22 is configured to back up data between the start address and the backup address when writing to the backup address of the memory;

[0082] The second writing module 23 is configured to use the backup address as a new starting address, re-determine the backup address of the memory, and return to execute the operation of writing data into the memory starting from the starting address.

[0083] Optionally, the first writing module 21 may be specifically configured to:

[0084] When writing to the boundary address of the memory, if the data backup between the start address and the backup address has been completed, the data will continue to be written from the memory's allocated start address;

[0085] The boundary address is smaller than the memory allocation end address, and data cannot be written between the boundary address and the memory allocation end address.

[0086] Optionally, the second writing module 23 includes:

[0087] A first time prediction unit, configured to predict a first time of writing from a backup address to a writable address of the memory, wherein the writable address is smaller than an allocation end address of the memory;

[0088] The backup address determining unit is configured to re-determine the backup address of the memory according to the first time and a second time required for backing up the data.

[0089] Optionally, the first time prediction unit may be specifically configured to:

[0090] Calculate the data writing speed based on the amount of memory between the starting address corresponding to the backup address and the backup address, and the time it takes to write from the starting address corresponding to the backup address to the backup address;

[0091] The first time of writing from the backup address to the writable address of the memory is predicted based on the amount of memory between the backup address and the writable address and the write speed.

[0092] Optionally, the backup address determination unit may be specifically configured to:

[0093] If the first time is greater than the second time, and the difference between the first time and the second time is greater than or equal to the set threshold, the backup address of the memory is adjusted according to the direction of writing data to increase the amount of data backed up in a single time.

[0094] Optionally, the backup address determination unit may be specifically configured to:

[0095] If the first time is less than or equal to the second time, or the difference between the first time and the second time is less than the set threshold, the backup address of the memory is adjusted in the opposite direction of writing data to reduce the amount of data backed up in a single time.

[0096] Optionally, the difference between the writable address and the boundary address is a preset memory amount, or the difference between the writable address and the start address corresponding to the backup address is a preset memory amount.

[0097] The above device can execute the methods provided by all the above embodiments of the present invention, and has the corresponding functional modules and beneficial effects of executing the above methods. For technical details not fully described in this embodiment, please refer to the methods provided by all the above embodiments of the present invention.

[0098] Example 3

[0099] Figure 4 This is a structural diagram of an electronic device provided in the third embodiment of the present invention, such as Figure 4 As shown, the electronic device includes a processor 31, a memory 32, an input device 33 and an output device 34; the number of processors 31 in the device can be one or more. Figure 4 In the embodiment, a processor 31 is used as an example; the processor 31, memory 32, input device 33 and output device 34 in the device can be connected by a bus or other means. Figure 4 The bus connection is taken as an example.

[0100] The memory 32, as a computer-readable storage medium, can be used to store software programs, computer executable programs, and modules, such as the modules corresponding to the data backup method in the embodiments of the present application (e.g., the first writing module 21, the backup module 22, and the second writing module 23). The processor 31 executes the software programs, instructions, and modules stored in the memory 32 to execute various functional applications and data processing of the electronic device, thereby implementing the above-mentioned data backup method.

[0101] The memory 32 may primarily include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function; the data storage area may store data generated based on the use of the terminal. Furthermore, the memory 32 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state memory device. In some instances, the memory 32 may further include a memory remotely located relative to the processor 31, and these remote memories may be connected to the electronic device via a network. Examples of the aforementioned networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0102] The input device 33 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the device. The output device 34 may include a display device such as a display screen.

[0103] Example 4

[0104] A fourth embodiment of the present invention further provides a storage medium containing computer-executable instructions. When the computer-executable instructions are executed by a computer processor, the computer-executable instructions are used to perform a data backup method. The method includes:

[0105] Write data to the memory starting from the starting address;

[0106] When writing to the backup address of the memory, the data between the start address and the backup address is backed up;

[0107] The backup address is used as the new starting address, and the backup address of the memory is re-determined, and the operation of writing data to the memory starting from the starting address is returned.

[0108] Of course, the storage medium containing computer-executable instructions provided in the embodiment of the present application is not limited to the above method operations, and can also execute related operations in the data backup method provided in any embodiment of the present invention.

[0109] Through the above description of the implementation methods, those skilled in the art can clearly understand that the present invention can be implemented with the help of software and necessary general-purpose hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for enabling an electronic device (which can be a personal computer, server, or network device, etc.) to execute the methods of various embodiments of the present invention.

[0110] It is worth noting that in the embodiment of the above-mentioned data backup device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the various functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.

[0111] Note that the above are only preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will appreciate that the present invention is not limited to the specific embodiments herein, and that various obvious changes, readjustments, and substitutions are possible for those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments and may include many other equivalent embodiments without departing from the scope of the present invention. The scope of the present invention is determined by the scope of the appended claims.

Claims

1. A data backup method, characterized in that: include: Write data to the memory starting from the starting address; When writing to the backup address of the memory, backing up the data between the start address and the backup address; wherein the backup address is a node for data backup; Using the backup address as a new starting address, re-determining the backup address of the memory, and returning to execute the operation of writing data into the memory starting from the starting address; wherein the new backup address is equal to the starting address of the next backup plus the backup size; The re-determining the backup address of the memory includes: Predicting the first time of writing from the backup address to the writable address of the memory, wherein the writable address is the maximum address that can be written to before writing to the memory address occupied by the data written previously during a data writing process; the writable address is less than the end address of the memory allocation; the end address of the memory allocation is the end point of the user's memory allocation; The backup address of the memory is re-determined according to the first time and a second time required for backing up data.

2. The method according to claim 1, characterized in that Writing data into the memory starting from the starting address includes: When writing to the boundary address of the memory, if the data backup between the start address and the backup address has been completed, then continue writing data from the start address of the memory; The boundary address is the end address for writing data, and the development start address is the starting point of the developed memory; the boundary address is smaller than the development end address of the memory, and data is not supported to be written between the boundary address and the development end address.

3. The method according to claim 1, characterized in that The predicting the first time of writing from the backup address to the writable address of the memory includes: Calculating a data writing speed based on the amount of memory between the starting address corresponding to the backup address and the backup address, and the time taken to write from the starting address corresponding to the backup address to the backup address; The first time of writing from the backup address to the writable address of the memory is predicted according to the amount of the memory between the backup address and the writable address and the write speed.

4. The method according to claim 1, wherein The re-determining the backup address of the memory according to the first time and the second time required for backing up the data includes: If the first time is greater than the second time, and the difference between the first time and the second time is greater than or equal to a set threshold, the backup address of the memory is adjusted according to the direction of writing data to increase the amount of data backed up in a single time.

5. The method according to claim 1, wherein The re-determining the backup address of the memory according to the first time and the second time required for backing up the data includes: If the first time is less than or equal to the second time, or the difference between the first time and the second time is less than a set threshold, the backup address of the memory is adjusted in the opposite direction of writing data to reduce the amount of data backed up in a single time.

6. The method according to claim 1, characterized in that The writable address differs from the boundary address by a preset memory amount, or the writable address differs from the starting address corresponding to the backup address by a preset memory amount; wherein the backup address refers to the re-determined backup address of the memory.

7. A data backup device, characterized in that: include: A first writing module, used for writing data into the memory starting from the starting address; A backup module, configured to back up data between the start address and the backup address when writing to the backup address of the memory; wherein the backup address is a node for data backup; a second writing module, configured to use the backup address as a new starting address, re-determine the backup address of the memory, and return to executing the operation of writing data into the memory starting from the starting address; wherein the new backup address is equal to the starting address of the next backup plus the backup size; The second writing module includes: a first time prediction unit, configured to predict a first time for writing from the backup address to a writable address of the memory, wherein the writable address is the maximum address that can be written to before writing to the memory address occupied by the data previously written during a data writing process; the writable address is smaller than an end address of memory allocation; the end address of memory allocation is the end point of the user's memory allocation; The backup address determining unit is configured to re-determine the backup address of the memory according to the first time and a second time required for backing up data.

8. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the data backup method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the data backup method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Data backup method and device based on Internet of Things cloud storage

    CN112527561A