CN112783832B - Method and device for storing snapshot file - Google Patents

Method and device for storing snapshot file Download PDF

Info

Publication number
CN112783832B
CN112783832B CN202011614510.XA CN202011614510A CN112783832B CN 112783832 B CN112783832 B CN 112783832B CN 202011614510 A CN202011614510 A CN 202011614510A CN 112783832 B CN112783832 B CN 112783832B
Authority
CN
China
Prior art keywords
file
snapshot
snapshot file
field
files
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011614510.XA
Other languages
Chinese (zh)
Other versions
CN112783832A (en
Inventor
朱涛
葛春
单康杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Kunjingyun Co ltd
Original Assignee
Shanghai Kunjingyun Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Kunjingyun Co ltd filed Critical Shanghai Kunjingyun Co ltd
Priority to CN202011614510.XA priority Critical patent/CN112783832B/en
Publication of CN112783832A publication Critical patent/CN112783832A/en
Application granted granted Critical
Publication of CN112783832B publication Critical patent/CN112783832B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/128Details of file system snapshots on the file-level, e.g. snapshot creation, administration, deletion
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/13File access structures, e.g. distributed indices

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Quality & Reliability (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a method and a device for storing snapshot files, wherein the method comprises the following steps: receiving a snapshot file storage request sent by a virtual desktop according to a preset communication protocol, and acquiring a snapshot file to be stored; invoking a libvirt tool, generating a backup file in backup files of a pre-stored metadata file, and setting a target storage path of a snapshot file to be stored; acquiring a current snapshot file in a current snapshot file field of the metadata file; adding a later-stage sub-system snapshot file field with an empty field value into the sub-system snapshot file field, setting a snapshot file time field value, wherein the description information field and the snapshot file field are snapshot files to be stored, the file storage path field is a target storage path, and the father-system snapshot file field is a current snapshot file; and updating the stored snapshot files into the snapshot files to be stored in the current snapshot file field and the parent snapshot file field of the metadata file. The recovery efficiency of the snapshot file can be improved.

Description

Method and device for storing snapshot file
Technical Field
The invention relates to the technical field of virtualization, in particular to a method and a device for storing snapshot files.
Background
In desktop virtualization (Desktop Virtualization), a user needs to generate a snapshot file (restore point) for restoring the current environment according to the current environment of the virtual desktop of the virtual machine before performing an unreliable operation, and store the snapshot file to the physical terminal, so that after the unreliable operation makes the virtualization system unusable or unstable, the user can restore according to the generated snapshot file. Especially when the unreliable operation is complex, it may be necessary to generate a large number of snapshot files in operation, which are independent in the physical terminal. When a certain environment needs to be restored, a virtualization system of the current environment of the virtual desktop is cut out, a snapshot file corresponding to the environment to be restored is found out from all snapshot files stored in the physical terminal, and the snapshot file corresponding to the environment to be restored is restored by utilizing a snapshot restoration function. However, in the snapshot file recovery method, because the snapshot files are independently stored in the physical terminal, each snapshot file needs to be queried one by one to determine whether the snapshot file is the snapshot file corresponding to the environment to be recovered, so that the time required for recovering the snapshot file is longer, and the snapshot file recovery efficiency is lower; further, when the snapshot file is restored, the virtual desktop restoration process is complicated due to the fact that the virtual desktop virtual system needs to be cut out, and therefore the snapshot file restoration efficiency is low.
Disclosure of Invention
Therefore, the present invention is directed to a method and an apparatus for storing snapshot files, so as to improve the recovery efficiency of the snapshot files.
In a first aspect, an embodiment of the present invention provides a method for storing a snapshot file, including:
receiving a snapshot file storage request sent by a virtual desktop according to a pre-configured communication protocol, and acquiring a snapshot file to be stored in the snapshot file storage request;
calling a libvirt tool, generating a backup file of a snapshot file to be stored in backup files in a pre-stored metadata file, and setting a target storage path of the snapshot file to be stored;
acquiring a current snapshot file in a current snapshot file field of the metadata file;
adding a later-stage sub-system snapshot file field with an empty field value into a sub-system snapshot file field of a metadata file, setting a snapshot file time field value, wherein a description information field and a snapshot file field are both snapshot files to be stored, a file storage path field is a target storage path, and a parent-system snapshot file field is a current snapshot file;
and updating the stored snapshot files into the snapshot files to be stored in the current snapshot file field and the parent snapshot file field of the metadata file.
With reference to the first aspect, the embodiment of the present invention provides a first possible implementation manner of the first aspect, where the communication protocol is a json communication protocol.
With reference to the first aspect or the first possible implementation manner of the first aspect, the embodiment of the present invention provides a second possible implementation manner of the first aspect, where the method further includes:
receiving a snapshot file recovery request, and acquiring a snapshot file to be recovered, which is carried in the snapshot file recovery request, wherein the snapshot file recovery request is sent by a virtual desktop according to a metadata file, the snapshot file is displayed in a tree structure according to the snapshot file to be recovered selected from the displayed snapshot files by a user and according to a pre-configured communication protocol;
and modifying the current snapshot file name field in the metadata file to be the snapshot file to be restored, and restarting the snapshot file to enable the restarted terminal to restore the virtual desktop according to the current snapshot file in the modified metadata file.
With reference to the first aspect or the first possible implementation manner or the second possible implementation manner of the first aspect, the embodiment of the present invention provides a third possible implementation manner of the first aspect, where the method further includes:
uploading the metadata file to a remote server according to a preset backup period;
when hardware for storing metadata files on the terminal is damaged, the remote server is connected by using an account number of the damaged terminal through the new terminal, so that the new terminal and the remote server check snapshot files, and when checking results are inconsistent, the metadata files are downloaded from the remote server to restore the snapshot files.
In a second aspect, an embodiment of the present invention further provides an apparatus for storing a snapshot file, including:
the storage request module is used for receiving a snapshot file storage request sent by the virtual desktop according to a preset communication protocol and acquiring a snapshot file to be stored in the snapshot file storage request;
the calling module is used for calling the libvirt tool, generating a backup file of the snapshot file to be stored in backup files in the metadata file stored in advance, and setting a target storage path of the snapshot file to be stored;
the current snapshot file determining module is used for acquiring a current snapshot file from a current snapshot file field of the metadata file;
the metadata file first updating module is used for adding a later-stage sub-system snapshot file field with an empty field value into a sub-system snapshot file field of the metadata file, setting a snapshot file time field value, setting a description information field and a snapshot file field as snapshot files to be stored, wherein a file storage path field is a target storage path, and a father-system snapshot file field is a current snapshot file;
and the metadata file second updating module is used for updating the stored snapshot files into snapshot files to be stored in the current snapshot file field and the father snapshot file field of the metadata file.
With reference to the second aspect, an embodiment of the present invention provides a first possible implementation manner of the second aspect, where the communication protocol is a json communication protocol.
With reference to the second aspect or the first possible implementation manner of the second aspect, an embodiment of the present invention provides a second possible implementation manner of the second aspect, where the method further includes:
the snapshot file recovery module is used for receiving a snapshot file recovery request, acquiring a snapshot file to be recovered carried in the snapshot file recovery request, wherein the snapshot file recovery request is sent by a virtual desktop according to a preset communication protocol, and the snapshot file is displayed in a tree structure according to metadata files and is selected from the displayed snapshot files by a user;
and modifying the current snapshot file name field in the metadata file to be the snapshot file to be restored, and restarting the snapshot file to enable the restarted terminal to restore the virtual desktop according to the current snapshot file in the modified metadata file.
With reference to the second aspect or the first possible implementation manner of the second aspect, an embodiment of the present invention provides a third possible implementation manner of the second aspect, where the method further includes:
the snapshot file backup module is used for uploading the metadata file to the remote server according to a preset backup period;
when hardware for storing metadata files on the terminal is damaged, the remote server is connected by using an account number of the damaged terminal through the new terminal, so that the new terminal and the remote server check snapshot files, and when checking results are inconsistent, the metadata files are downloaded from the remote server to restore the snapshot files.
In a third aspect, embodiments of the present application provide a computer device including a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the above method when executing the computer program.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method described above.
According to the method and the device for storing the snapshot file, the snapshot file to be stored in the snapshot file storage request is obtained by receiving the snapshot file storage request sent by the virtual desktop according to the preset communication protocol; calling a libvirt tool, generating a backup file of a snapshot file to be stored in backup files in a pre-stored metadata file, and setting a target storage path of the snapshot file to be stored; acquiring a current snapshot file in a current snapshot file field of the metadata file; adding a later-stage sub-system snapshot file field with an empty field value into a sub-system snapshot file field of a metadata file, setting a snapshot file time field value, wherein a description information field and a snapshot file field are both snapshot files to be stored, a file storage path field is a target storage path, and a parent-system snapshot file field is a current snapshot file; and updating the stored snapshot files into the snapshot files to be stored in the current snapshot file field and the parent snapshot file field of the metadata file. In this way, the upper and lower relationships of the snapshot files are set in the metadata files, so that the tree-structure snapshot files with the association relationship are formed, when the snapshot files are required to be restored, the snapshot files required to be restored can be quickly found according to the snapshot files with the tree-structure, and the snapshot file restoration efficiency is improved.
In order to make the above objects, features and advantages of the present invention more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are needed in the embodiments will be briefly described below, it being understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart illustrating a method for storing a snapshot file according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a snapshot file generation, storage, and backup system according to an embodiment of the present invention;
FIG. 3 is a schematic diagram illustrating an apparatus for storing snapshot files according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a computer device 400 according to an embodiment of the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. The components of the embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the invention, as presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be made by a person skilled in the art without making any inventive effort, are intended to be within the scope of the present invention.
The embodiment of the invention provides a method and a device for storing snapshot files, and the method and the device are described in the following through the embodiment.
Fig. 1 shows a flowchart of a method for storing a snapshot file according to an embodiment of the present invention. As shown in fig. 1, the method includes:
step 101, receiving a snapshot file storage request sent by a virtual desktop according to a pre-configured communication protocol, and acquiring a snapshot file to be stored in the snapshot file storage request;
in the embodiment of the present invention, as an alternative embodiment, the pre-configured communication protocol is a pre-defined json communication protocol.
In the embodiment of the invention, predefined json communication protocols are respectively configured in the virtual machine and the terminal, and when the snapshot file is generated and required to be stored, a service (virtual desktop) in the virtual machine sends a snapshot file storage request to a terminal service (terminal) by utilizing the pre-configured communication protocols, wherein the snapshot file storage request format is as follows:
{"method":"take_snapshot","name":"2-1","desc":"2-1"}
wherein, name is the snapshot file to be stored, and desc is the description information of the snapshot file to be stored.
In the embodiment of the invention, the terminal comprises but is not limited to: local physical terminal, thin terminal, remote management platform, remote server, etc.
Step 102, calling a libvirt tool, generating a backup file of a snapshot file to be stored in backup files in a pre-stored metadata file, and setting a target storage path of the snapshot file to be stored;
in the embodiment of the invention, after receiving the snapshot file storage request, the terminal service responds to the snapshot file storage request.
Assume that metadata (metadata) file contents stored on a terminal are as follows:
{ "file": "/opt/idesk/data/_base/1590489699.28", "name": "9175e375d966ad35ca7a8692d5fd3ff9b67d02c3", "parent": null "," created_at ":"1606788839"," child ": [ ]," current ": 9175e375d966ad35ca7a8692d5fd3ff9b67d02c3", "parent": 9175e375d966ad35ca7a8692d5fd3ff9b67 c3"," parent ": 9175e375d966ad35ca7a869 d 67d02c3", "image": "9175e375d966ad35ca7a8692d5fd3ff9b67d02c3", "desc": base "}. Wherein,
"file"/opt/idesk/data/_base/1590489699.28 "is a backup file (backup file) storage path field;
"name" 9175e375d966ad35ca7a8692d5fd3ff9b67d02c3 "is a snapshot file field;
"parent" is the root system snapshot file field, null indicates that the current snapshot file has no parent snapshot file;
"created_at" is the snapshot file time field;
"child" [ ] is a sub-system snapshot file field;
"Current" is the current snapshot file field;
"pantsnap" is the parent snapshot file field;
"image" is the current image file field of the virtual machine;
"desc" is the descriptive information field of the snapshot file.
In the embodiment of the invention, under the storage path/opt/idesk/data/mode, taking/opt/idesk/data/_base/1590489699.28 as a backup file, calling a libvirt tool to generate a backup file of a snapshot file to be stored, setting a storage path of the snapshot file to be stored, for example, a complete storage path of the snapshot file to be stored is as follows:
/opt/idesk/data/2-1。
in the embodiment of the present invention, the sub-system snapshot file field includes: the subsequent sub-system snapshot file field, the creation snapshot file time field, the description information field, the snapshot file field, the file storage path field, and the parent snapshot file field. For the current snapshot file, each of the sub-system snapshot file fields is empty.
Step 103, obtaining a current snapshot file in a current snapshot file field of the metadata file;
in the embodiment of the present invention, the current snapshot file is "9175e375d966ad35ca7a8692d5fd3ff9b67d02c3" according to the current snapshot file field "current".
Step 104, adding a later-stage sub-system snapshot file field with an empty field value into a sub-system snapshot file field of the metadata file, setting a snapshot file time field value, wherein the description information field and the snapshot file field are snapshot files to be stored, the file storage path field is a target storage path, and the father-system snapshot file field is a current snapshot file;
in the embodiment of the invention, the sub-system snapshot file field is' child [ ], which indicates that the snapshot file is not stored on the basis of the current snapshot file. The updated sub-system snapshot file fields are:
"children":[{"children":[],"created_at":"1607924564","desc":"2-1","file":"/opt/idesk/data/2-1","name":"2-1","parent":"9175e375d966ad35ca7a8692d5fd3ff9b67d02c3"}]
step 105, in the current snapshot file field and the parent snapshot file field of the metadata file, the stored snapshot files are updated to be snapshot files to be stored.
In the embodiment of the invention, the fields of the current snapshot file are as follows: "Current" 9175e375d966ad35ca7a8692d5fd3ff9b67d02c3", parent snapshot file fields are: "pantsnap" 9175e375d966ad35ca7a8692d5fd3ff9b67d02c3", updated current snapshot file field and parent snapshot file field are:
"current":"2-1","parentsnap":"2-1"。
in the embodiment of the invention, the content of the updated metadata file is as follows:
{"file":"/opt/idesk/data/_base/1590489699.28","name":"9175e375d966ad35ca7a8692d5fd3ff9b67d02c3","parent":null,"created_at":"1606788839","children":[{"children":[],"created_at":"1607924564","desc":"2-1","file":"/opt/idesk/data/2-1","name":"2-1","parent":"9175e375d966ad35ca7a8692d5fd3ff9b67d02c3"}],"current":"2-1","parentsnap":"2-1","image":"9175e375d966ad35ca7a8692d5fd3ff9b67d02c3","desc":"basic vm image"}。
in the embodiment of the invention, the upper and lower relationships of the snapshot files are set in the metadata files by defining the metadata files in json format, so that the snapshot files with the association relationship are formed, a plurality of snapshot files are saved in the tree structure, the generation requirement of users on the snapshot files in a complex scene is met, and the links among the snapshot files are increased. Meanwhile, the logical management of the snapshot file is facilitated by utilizing the snapshot file with the tree structure, and the tracing efficiency of the snapshot file is improved.
In an embodiment of the present invention, as an optional embodiment, the method further includes:
receiving a snapshot file recovery request, and acquiring a snapshot file to be recovered, which is carried in the snapshot file recovery request, wherein the snapshot file recovery request is sent by a virtual desktop according to a metadata file, the snapshot file is displayed in a tree structure according to the snapshot file to be recovered selected from the displayed snapshot files by a user and according to a pre-configured communication protocol;
and modifying the current snapshot file name field in the metadata file to be the snapshot file to be restored, and restarting the snapshot file to enable the restarted terminal to restore the virtual desktop according to the current snapshot file in the modified metadata file.
In the embodiment of the present invention, as an optional embodiment, the snapshot file recovery request format is as follows:
{"method":"restore_snapshot","snapname":"2-1"}
after receiving the snapshot file recovery request, the terminal service modifies a metadata (metadata) file, sets current to 2-1, and then restarts the terminal.
After the terminal is restarted and started, the terminal service compares the virtual machine file of the virtual desktop with current in the metadata file, and if the virtual machine file is inconsistent with the current in the metadata file, a new virtual machine file is regenerated according to the metadata file, so that the terminal jumps to the designated snapshot file to be restored. Therefore, when snapshot file generation or recovery is carried out, a user can directly communicate with the terminal from the virtual machine through the newly established json communication protocol, the snapshot file generation or recovery function is operated, a virtual system of a virtual desktop does not need to be cut out first, switching back and forth between the terminal and the virtual machine is avoided, one-key snapshot file recovery is realized, experience is very smooth, and the recovery efficiency of the snapshot file can be effectively improved.
In an embodiment of the present invention, as an optional embodiment, the method further includes:
uploading the metadata file to a remote server according to a preset backup period;
when hardware for storing metadata files on the terminal is damaged, the remote server is connected by using an account number of the damaged terminal through the new terminal, so that the new terminal and the remote server check snapshot files, and when checking results are inconsistent, the metadata files are downloaded from the remote server to restore the snapshot files.
In the embodiment of the invention, the snapshot files are backed up and synchronized regularly or in real time, so that the safety of the snapshot files can be ensured. As an alternative embodiment, a Client service may be defined on the remote server, and the terminal (thin terminal) periodically communicates with the Client service, checks the stored snapshot file, and uploads to the remote server. Therefore, when the hardware of the thin terminal is damaged, the local system is damaged, and the snapshot file is damaged or lost, a user can use a new thin terminal to connect with and log in a remote server by using a user account, the client service checks with the thin terminal, the local snapshot file is found to be lost at the thin terminal, and the system environment before the damage of the hardware of the thin terminal is restored by automatically downloading the metadata file from the remote server and using the downloaded metadata file. Therefore, after the terminal system is in fault or even data is damaged, a user can directly restore the current use environment through the backed-up snapshot file, and the risk of data loss is avoided.
Fig. 2 shows a schematic diagram of a snapshot file generating, storing and backing up system according to an embodiment of the present invention. As shown in fig. 2, the system includes: the virtual machine comprises a virtual machine, a thin terminal and a remote server, wherein the virtual machine is provided with a QEMU-KVM and a Guest Channel (Guest Channel) Client, the thin terminal is provided with a QEMU-IMG and a Guest Channel service, the remote server is provided with a Client service, a snapshot file is created through the QEMU-IMG and the QEMU-KVM, the virtual machine can be directly communicated with the thin terminal through the Guest Channel Client and the Guest Channel service, the thin terminal is communicated with the Client service, and the snapshot file is periodically checked and backed up to the remote server.
Fig. 3 is a schematic diagram of an apparatus for storing snapshot files according to an embodiment of the present invention. As shown in fig. 3, the apparatus includes:
the storage request module 301 is configured to receive a snapshot file storage request sent by a virtual desktop according to a pre-configured communication protocol, and obtain a snapshot file to be stored in the snapshot file storage request;
in the embodiment of the present invention, as an optional embodiment, the communication protocol is a json communication protocol, and predefined json communication protocols are respectively configured in the virtual machine and the terminal.
In the embodiment of the invention, the snapshot file storage request format is as follows:
{"method":"take_snapshot","name":"2-1","desc":"2-1"}
the calling module 302 is configured to call the libvirt tool, generate a backup file of the snapshot file to be stored in the backup files in the metadata files stored in advance, and set a target storage path of the snapshot file to be stored;
the current snapshot file determining module 303 is configured to obtain a current snapshot file in a current snapshot file field of the metadata file;
the metadata file first updating module 304 is configured to add a later-stage sub-system snapshot file field with an empty field value into a sub-system snapshot file field of the metadata file, set a snapshot file time field value, describe information fields and snapshot file fields as snapshot files to be stored, wherein a file storage path field is a target storage path, and a parent-system snapshot file field is a current snapshot file;
the metadata file second updating module 305 is configured to update the stored snapshot file to the snapshot file to be stored in the current snapshot file field and the parent snapshot file field of the metadata file.
In an embodiment of the present invention, as an optional embodiment, the apparatus further includes:
a snapshot file recovery module (not shown in the figure) for receiving a snapshot file recovery request, and obtaining a snapshot file to be recovered carried in the snapshot file recovery request, where the snapshot file recovery request is sent by a virtual desktop according to a preset communication protocol, according to a metadata file, displaying the snapshot file in a tree structure, and according to the snapshot file to be recovered selected from the displayed snapshot files by a user;
and modifying the current snapshot file name field in the metadata file to be the snapshot file to be restored, and restarting the snapshot file to enable the restarted terminal to restore the virtual desktop according to the current snapshot file in the modified metadata file.
In the embodiment of the invention, the snapshot file recovery request format is as follows:
{"method":"restore_snapshot","snapname":"2-1"}
in an embodiment of the present invention, as another optional embodiment, the apparatus further includes:
the snapshot file backup module is used for uploading the metadata file to the remote server according to a preset backup period;
when hardware for storing metadata files on the terminal is damaged, the remote server is connected by using an account number of the damaged terminal through the new terminal, so that the new terminal and the remote server check snapshot files, and when checking results are inconsistent, the metadata files are downloaded from the remote server to restore the snapshot files.
As shown in fig. 4, an embodiment of the present application provides a computer device 400 for executing the method for storing a snapshot file in fig. 1, where the device includes a memory 401, a processor 402, and a computer program stored on the memory 401 and capable of running on the processor 402, where the steps of the method for storing a snapshot file are implemented when the processor 402 executes the computer program.
Specifically, the memory 401 and the processor 402 can be general-purpose memories and processors, and are not limited herein, and the method for storing snapshot files can be performed when the processor 402 runs a computer program stored in the memory 401.
Corresponding to the method for storing a snapshot file in fig. 1, the embodiment of the application further provides a computer readable storage medium, on which a computer program is stored, which when executed by a processor performs the steps of the method for storing a snapshot file.
In particular, the storage medium can be a general-purpose storage medium, such as a removable disk, a hard disk, or the like, and the computer program on the storage medium, when executed, can perform the above-described method of storing snapshot files.
In the embodiments provided herein, it should be understood that the disclosed systems and methods may be implemented in other ways. The system embodiments described above are merely illustrative, e.g., the division of the elements is merely a logical functional division, and there may be additional divisions in actual implementation, and e.g., multiple elements or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, system or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments provided in the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
It should be noted that: like reference numerals and letters in the following figures denote like items, and thus once an item is defined in one figure, no further definition or explanation of it is required in the following figures, and furthermore, the terms "first," "second," "third," etc. are used merely to distinguish one description from another and are not to be construed as indicating or implying relative importance.
Finally, it should be noted that: the foregoing examples are merely specific embodiments of the present application, and are not intended to limit the scope of the present application, but the present application is not limited thereto, and those skilled in the art will appreciate that while the foregoing examples are described in detail, the present application is not limited thereto. Any person skilled in the art may modify or easily conceive of the technical solution described in the foregoing embodiments, or make equivalent substitutions for some of the technical features within the technical scope of the disclosure of the present application; such modifications, changes or substitutions do not depart from the spirit and scope of the corresponding technical solutions. Are intended to be encompassed within the scope of this application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (8)

1. A method of storing snapshot files, comprising:
receiving a snapshot file storage request sent by a virtual desktop according to a pre-configured communication protocol, and acquiring a snapshot file to be stored in the snapshot file storage request; wherein the communication protocol is json communication protocol;
calling a libvirt tool, generating a backup file of a snapshot file to be stored in backup files in a pre-stored metadata file, and setting a target storage path of the snapshot file to be stored;
acquiring a current snapshot file in a current snapshot file field of the metadata file;
adding a later-stage sub-system snapshot file field with an empty field value into a sub-system snapshot file field of a metadata file, setting a snapshot file time field value, wherein a description information field and a snapshot file field are both snapshot files to be stored, a file storage path field is a target storage path, and a parent-system snapshot file field is a current snapshot file; the metadata file is provided with a superior-subordinate relation of the snapshot file, so that a tree-structure snapshot file with an association relation is formed; the child snapshot file field and the parent snapshot file field are used for representing the upper-lower relationship of the snapshot file;
and updating the stored snapshot files into the snapshot files to be stored in the current snapshot file field and the parent snapshot file field of the metadata file.
2. The method according to claim 1, wherein the method further comprises:
receiving a snapshot file recovery request, and acquiring a snapshot file to be recovered, which is carried in the snapshot file recovery request, wherein the snapshot file recovery request is sent by a virtual desktop according to a metadata file, the snapshot file is displayed in a tree structure according to the snapshot file to be recovered selected from the displayed snapshot files by a user and according to a pre-configured communication protocol;
and modifying the current snapshot file name field in the metadata file to be the snapshot file to be restored, and restarting the snapshot file to enable the restarted terminal to restore the virtual desktop according to the current snapshot file in the modified metadata file.
3. The method according to claim 1, wherein the method further comprises:
uploading the metadata file to a remote server according to a preset backup period;
when hardware for storing metadata files on the terminal is damaged, the remote server is connected by using an account number of the damaged terminal through the new terminal, so that the new terminal and the remote server check snapshot files, and when checking results are inconsistent, the metadata files are downloaded from the remote server to restore the snapshot files.
4. An apparatus for storing snapshot files, comprising:
the storage request module is used for receiving a snapshot file storage request sent by the virtual desktop according to a preset communication protocol and acquiring a snapshot file to be stored in the snapshot file storage request; wherein the communication protocol is json communication protocol;
the calling module is used for calling the libvirt tool, generating a backup file of the snapshot file to be stored in backup files in the metadata file stored in advance, and setting a target storage path of the snapshot file to be stored;
the current snapshot file determining module is used for acquiring a current snapshot file from a current snapshot file field of the metadata file;
the metadata file first updating module is used for adding a later-stage sub-system snapshot file field with an empty field value into a sub-system snapshot file field of the metadata file, setting a snapshot file time field value, setting a description information field and a snapshot file field as snapshot files to be stored, wherein a file storage path field is a target storage path, and a father-system snapshot file field is a current snapshot file; the metadata file is provided with a superior-subordinate relation of the snapshot file, so that a tree-structure snapshot file with an association relation is formed; the child snapshot file field and the parent snapshot file field are used for representing the upper-lower relationship of the snapshot file;
and the metadata file second updating module is used for updating the stored snapshot files into snapshot files to be stored in the current snapshot file field and the father snapshot file field of the metadata file.
5. The apparatus as recited in claim 4, further comprising:
the snapshot file recovery module is used for receiving a snapshot file recovery request, acquiring a snapshot file to be recovered carried in the snapshot file recovery request, wherein the snapshot file recovery request is sent by a virtual desktop according to a preset communication protocol, and the snapshot file is displayed in a tree structure according to metadata files and is selected from the displayed snapshot files by a user;
and modifying the current snapshot file name field in the metadata file to be the snapshot file to be restored, and restarting the snapshot file to enable the restarted terminal to restore the virtual desktop according to the current snapshot file in the modified metadata file.
6. The apparatus as recited in claim 4, further comprising:
the snapshot file backup module is used for uploading the metadata file to the remote server according to a preset backup period;
when hardware for storing metadata files on the terminal is damaged, the remote server is connected by using an account number of the damaged terminal through the new terminal, so that the new terminal and the remote server check snapshot files, and when checking results are inconsistent, the metadata files are downloaded from the remote server to restore the snapshot files.
7. A computer device, comprising: a processor, a memory and a bus, said memory storing machine readable instructions executable by said processor, said processor and said memory communicating over the bus when the computer device is running, said machine readable instructions when executed by said processor performing the steps of the method of storing snapshot files as claimed in any one of claims 1 to 3.
8. A computer-readable storage medium, characterized in that it has stored thereon a computer program which, when executed by a processor, performs the steps of the method of storing snapshot files as claimed in any of claims 1 to 3.
CN202011614510.XA 2020-12-30 2020-12-30 Method and device for storing snapshot file Active CN112783832B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011614510.XA CN112783832B (en) 2020-12-30 2020-12-30 Method and device for storing snapshot file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011614510.XA CN112783832B (en) 2020-12-30 2020-12-30 Method and device for storing snapshot file

Publications (2)

Publication Number Publication Date
CN112783832A CN112783832A (en) 2021-05-11
CN112783832B true CN112783832B (en) 2024-03-22

Family

ID=75754045

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011614510.XA Active CN112783832B (en) 2020-12-30 2020-12-30 Method and device for storing snapshot file

Country Status (1)

Country Link
CN (1) CN112783832B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8364639B1 (en) * 2007-10-11 2013-01-29 Parallels IP Holdings GmbH Method and system for creation, analysis and navigation of virtual snapshots
CN102981931A (en) * 2012-12-03 2013-03-20 中国联合网络通信集团有限公司 Backup method and device for virtual machine
CN107943557A (en) * 2017-11-18 2018-04-20 浙江网新恒天软件有限公司 A kind of magnetic disk of virtual machine incremental snapshot method based on cloud platform
CN109684273A (en) * 2019-01-07 2019-04-26 郑州云海信息技术有限公司 A kind of snapshot management method, apparatus, equipment and readable storage medium storing program for executing

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140258238A1 (en) * 2013-03-05 2014-09-11 VCE Company LLC Method to embed snapshot management into virtual machine instances

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8364639B1 (en) * 2007-10-11 2013-01-29 Parallels IP Holdings GmbH Method and system for creation, analysis and navigation of virtual snapshots
CN102981931A (en) * 2012-12-03 2013-03-20 中国联合网络通信集团有限公司 Backup method and device for virtual machine
CN107943557A (en) * 2017-11-18 2018-04-20 浙江网新恒天软件有限公司 A kind of magnetic disk of virtual machine incremental snapshot method based on cloud platform
CN109684273A (en) * 2019-01-07 2019-04-26 郑州云海信息技术有限公司 A kind of snapshot management method, apparatus, equipment and readable storage medium storing program for executing

Also Published As

Publication number Publication date
CN112783832A (en) 2021-05-11

Similar Documents

Publication Publication Date Title
CN111124755A (en) Cluster node fault recovery method and device, electronic equipment and storage medium
CN112506702B (en) Disaster recovery method, device, equipment and storage medium for data center
CN110825495A (en) Container cloud platform recovery method, device, equipment and readable storage medium
CN108121543B (en) Software code compiling processing method and device
US11397537B2 (en) Data restoration method and apparatus
CN105242990A (en) Cloud platform based data backup method and apparatus
US8612799B2 (en) Method and apparatus of backing up subversion repository
CN110825562B (en) Data backup method, device, system and storage medium
CN112596951A (en) NAS data disaster tolerance method, device, equipment and storage medium
CN110750325A (en) Mirror image backup method and device of virtual machine, fault recovery method and device and electronic equipment
CN111666266A (en) Data migration method and related equipment
CN112579361B (en) Backup data reconstruction method, device, equipment and storage medium
CN112783832B (en) Method and device for storing snapshot file
WO2018076696A1 (en) Data synchronization method and out-of-band management device
US11080150B2 (en) Method for creating consistency snapshot for distributed application, apparatus, and distributed system
CN114553859A (en) BMC configuration management method and device, electronic equipment and storage medium
CN112269683B (en) Off-line node on-line service recovery method and related components
CN108762988A (en) A kind of method and relevant device of data processing
CN113986450A (en) Virtual machine backup method and device
CN114153503A (en) BIOS control method, device and medium
CN113656378A (en) Server management method, device and medium
CN113515291A (en) Equipment online upgrading method and device
CN112000437A (en) Disaster recovery method and device, electronic equipment and storage medium
CN114443354A (en) File recovery method and device, electronic equipment and storage medium
CN115543539A (en) Virtual machine password resetting method, device and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant