Method and electronic device for backing up data and recovering data
A method for backing up data includes: determining a storage tier for storing the data; determining a data access frequency of the data, where the data access frequency indicates a frequency at which the data is accessed; and taking information of the storage tier and the data access frequency of the data as metadata, and sending the metadata and the data to a backup server. By sending the information including the storage tier for storing the data and the data access frequency as the metadata to the backup server, the computing device is enabled to recover the data by using the information in the metadata during the data recovery process, so that the data tiering layout can be maintained in the storage region to maintain the storage service performance, and thus a seamless storage service is provided to improve the user experience.
1 . A method for backing up data, comprising:
determining a storage tier for storing the data;
determining a data access frequency of the data, wherein the data access frequency indicates a frequency at which the data is accessed and determining the data access frequency includes:
determining a region access frequency, the region access frequency indicating a frequency at which a storage region storing the data is accessed,
determining a first number of data blocks in the storage region, and
determining a data block access frequency based on the region access frequency and the first number of the data blocks, wherein the data block access frequency indicates a frequency at which the data blocks are accessed;
generating metadata based on information of the storage tier and the data access frequency of the data; and
sending the metadata and the data to a backup server.
2 . The method according to claim 1 , further comprising:
storing the data in the corresponding storage tier according to the frequency at which the data is accessed.
3 . The method according to claim 1 , wherein determining the data access frequency further comprises:
determining a second number of data blocks included in the data; and
determining the data access frequency based on the second number and the data block access frequency.
4 . The method according to claim 1 , wherein the storage region storing the data comprises a stripe.
5 . The method according to claim 4 , wherein the stripe corresponds to the storage tier storing the data.
6 . The method according to claim 1 , further comprising:
converting the data and the metadata into a data packet; and
sending the data packet to a file system layer to set the metadata in a property file via the file system layer; and
sending the property file and the data to the backup server, wherein the metadata comprises the information of the storage tier and the data access frequency.
7 . The method according to claim 1 , wherein the information of the storage tier is represented by a bit value, and wherein the information of the storage tier and the data access frequency are associated with an identifier of the data.
8 . An electronic device, comprising:
at least one processor; and
at least one memory coupled to the at least one processor and storing instructions to be executed by the at least one processor, the instructions, when executed by the at least one processor, cause the electronic device to:
determine a storage tier for storing data;
determine a data access frequency of the data, wherein the data access frequency indicates a frequency at which the data is accessed and to determine the data access frequency of the data the electronic device is caused to:
determine a region access frequency, the region access frequency indicating a frequency at which a storage region storing the data is accessed,
determine a first number of data blocks in the storage region, and
determine a data block access frequency based on the region access frequency and the first number of the data blocks, wherein the data block access frequency indicates a frequency at which the data blocks are accessed;
generate metadata based on information of the storage tier and the data access frequency of the data; and
send the metadata and the data to a backup server.
9 . The electronic device according to claim 8 , comprising further instructions that when executed by the at least one processor, cause the electronic device to:
store the data in the corresponding storage tier according to the frequency at which the data is accessed.
10 . The electronic device according to claim 8 , wherein determining the data access frequency further comprises:
determine a second number of data blocks included in the data; and
determine the data access frequency based on the second number and the data block access frequency.
11 . The electronic device according to claim 8 , wherein the storage region storing the data comprises a stripe.
12 . The electronic device according to claim 11 , wherein the stripe corresponds to the storage tier storing the data.
13 . The electronic device according to claim 8 , comprising further instructions that when executed by the at least one processor, cause the electronic device to:
convert the data and the metadata into a data packet; and
send the data packet to a file system layer to set the metadata in a property file via the file system layer.
14 . The electronic device according to claim 13 , comprising further instructions that when executed by the at least one processor, cause the electronic device to:
send the property file and the data to the backup server, wherein the metadata comprises the information of the storage tier and the data access frequency.
15 . The electronic device according to claim 8 , wherein the information of the storage tier is represented by a bit value and wherein the information of the storage tier and the data access frequency are associated with an identifier of the data.
16 . A non-transitory computer-readable medium storing machine-executable instructions, the machine-executable instructions, when executed, cause a machine to:
determine a storage tier for storing data;
determine a data access frequency of the data, wherein the data access frequency indicates a frequency at which the data is accessed and to determine the data access frequency of the data the machine is caused to:
determine a region access frequency, the region access frequency indicating a frequency at which a storage region storing the data is accessed,
determine a first number of data blocks in the storage region, and
determine a data block access frequency based on the region access frequency and the first number of the data blocks, wherein the data block access frequency indicates a frequency at which the data blocks are accessed;
generate metadata based on information of the storage tier and the data access frequency of the data; and
send the metadata and the data to a backup server.
17 . The non-transitory computer-readable medium according to claim 16 , comprising further instructions that when executed cause the machine to:
store the data in the corresponding storage tier according to the frequency at which the data is accessed.
18 . The non-transitory computer-readable medium according to claim 16 , wherein to determine the data access frequency the machine is further caused to:
determine a second number of data blocks included in the data; and
determine the data access frequency based on the second number and the data block access frequency.
19 . The non-transitory computer-readable medium according to claim 16 , wherein the storage region storing the data comprises a stripe.
20 . The non-transitory computer-readable medium according to claim 19 , wherein the stripe corresponds to the storage tier storing the data.