Data backup method and system of backup virtual machine, electronic equipment and storage medium
By entering single-user mode at the initial startup of the backup virtual machine and running only the target service execution file, the energy consumption and resource occupation problems in the real-time activation state of the backup virtual machine are solved, and a significant reduction in energy consumption and cost is achieved.
Patent Information
- Application Number
- CN202510173452.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-17
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2045-02-17
AI Technical Summary
In the prior art, backup virtual machines need to be kept active in real time for instant inspection and failover, resulting in increased energy consumption, occupancy of computing resources, increased operational costs and adversely affecting the data center environment.
By entering single-user mode when the backup virtual machine is first started, the default boot in the boot program is started, only the target service execution file is run to set up network information, avoiding starting other services, thus detecting its network connection status through the master server when the backup virtual machine is not required.
Reduces the energy consumption and computing resource usage of backup virtual machines, significantly saves power resources, reduces operating costs, and avoids adverse effects on the data center environment.
Smart Images

Figure CN119645738A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data storage, and in particular to a method, system, electronic device and storage medium for backing up virtual machine data. Background Art
[0002] In modern data storage and management systems, backup data plays a vital role. To ensure business continuity and data security, enterprises usually store the primary copy of critical data in the primary virtual machine, and create backup copies of these data and store them in backup virtual machines that are different from the primary data. This separate storage strategy is designed to prevent single point failures, that is, when the primary virtual machine or the data center where it is located fails, the backup virtual machine can be quickly started to restore data and services, thereby effectively responding to catastrophic events.
[0003] However, backup data management is not without challenges. To ensure the validity and availability of backup data, regular health checks must be performed on backup virtual machines. These checks include, but are not limited to, verifying the integrity of backup data, confirming the operating status of the virtual machine operating system, and detecting any issues that may affect virtual machine startup or data recovery. This process is critical to ensuring seamless switching to the backup environment when needed and is a core step in implementing a disaster recovery plan.
[0004] As cloud computing and virtualization technologies become increasingly popular, energy efficiency has become one of the important indicators for measuring the operational benefits of data centers. In actual operations, if backup virtual machines are kept activated in real time, although it is convenient to conduct instant inspections and failovers, it will significantly increase energy consumption. When activated, virtual machines consume a large amount of power resources, may generate additional heat, and may occupy additional computing resources, which not only increases operating costs, but may also have an adverse impact on the environment of the data center. Summary of the invention
[0005] In order to solve the above problems existing in the prior art, the present invention provides a method, system, electronic device and storage medium for backing up virtual machine data. The technical problem to be solved by the present invention is achieved through the following technical solutions: A first aspect of an embodiment of the present invention provides a method for backing up virtual machine data, comprising the following steps: The backup virtual machine receives a startup instruction; The backup virtual machine reads a default configuration file of the boot program; wherein the default configuration file includes single-user mode parameters; The backup virtual machine runs the default configuration file to start up and enter single-user mode; The backup virtual machine reads the target service execution file from the startup directory of the single-user mode and runs the target service execution file; The target service execution file reads a network information file in a target setting directory and sets network information according to the network information file.
[0006] In one embodiment of the present invention, before the backup virtual machine receives the startup instruction, the method further includes: The local server deletes the original service execution file in response to the instruction to delete the original service execution file in the startup directory of the single-user mode of the backup virtual machine; The local server stores the target service execution file, the target setting directory and the network information file in response to an instruction to add a target service execution file in a startup directory in a single-user mode of the backup virtual machine and an instruction to add a target setting directory and a network information file in the single-user mode; The local server modifies the default configuration file in response to the instruction to add a single-user mode parameter in the default configuration file of the boot program of the backup virtual machine.
[0007] In one embodiment of the present invention, the method further comprises: The main server sends an ICMP echo request message to the IP address of the network information at a preset interval; The primary server detects whether an ICMP echo reply message of the backup virtual machine corresponding to the IP address of the network information is received.
[0008] In one embodiment of the present invention, the method further comprises: The primary server sends a disaster recovery instruction to the backup virtual machine; The backup virtual machine receives the disaster recovery instruction; wherein the disaster recovery instruction instructs switching the single-user mode to the multi-user mode; The backup virtual machine switches to multi-user mode according to the disaster recovery instruction; Back up the virtual machine for disaster recovery.
[0009] A second aspect of an embodiment of the present invention provides a virtual machine data backup system, including: a virtual machine backup; The backup virtual machine is used to receive a startup instruction; The backup virtual machine is used to read a default configuration file of the boot program; wherein the default configuration file includes single-user mode parameters; The backup virtual machine is used to run the default configuration file to start up and enter the single-user mode; The backup virtual machine is used to read the target service execution file from the startup directory of the single-user mode and run the target service execution file; The target service execution file reads a network information file in a target setting directory and sets network information according to the network information file.
[0010] In one embodiment of the present invention, a local server is also included; The local server is used to delete the original service execution file in response to the instruction to delete the original service execution file in the startup directory of the single-user mode of the backup virtual machine; The local server is used to store the target service execution file, the target setting directory and the network information file in response to an instruction to add a target service execution file in a startup directory in a single-user mode of the backup virtual machine and an instruction to add a target setting directory and a network information file in the single-user mode; The local server is used to modify the default configuration file in response to an instruction to add a single-user mode parameter in the default configuration file of the boot program of the backup virtual machine.
[0011] In one embodiment of the present invention, it also includes a main server; The main server is used to send an ICMP echo request message to the IP address of the network information at a preset interval; The primary server is used to detect whether an ICMP echo reply message of the backup virtual machine corresponding to the IP address of the network information is received.
[0012] In one embodiment of the present invention, the primary server is further used to send a disaster recovery instruction to the backup virtual machine; The backup virtual machine is also used to receive the disaster recovery instruction; wherein the disaster recovery instruction instructs to switch the single-user mode to the multi-user mode; The backup virtual machine is also used to switch to a multi-user mode according to the disaster recovery instruction; The backup virtual machine is also used for disaster recovery operations.
[0013] A third aspect of an embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a method for backing up virtual machine data provided by the first aspect of an embodiment of the present invention is implemented.
[0014] A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method for backing up virtual machine data provided by the first aspect of an embodiment of the present invention is implemented.
[0015] Beneficial effects of the present invention: The present invention enters the single-user mode at the default startup in the default configuration file in the boot program when the backup virtual machine is started for the first time. There are fewer programs running in the single-user mode, which can reduce the energy consumption of the backup virtual machine and occupy fewer computing resources. At the same time, after entering the single-user mode, only the target service execution file is run, that is, the backup virtual machine only starts the service in the target service execution file, and other services are not started. The target service execution file is used to set the network information, so that when the backup virtual machine is started for the first time, only the network information needs to be set, and no other services need to be started. The backup virtual machine completes the setting of the network information, so that when the backup virtual machine is not needed, the main server can be used to detect whether the network connection status of the backup virtual machine is normal. The backup virtual machine does not need to run other functions, which significantly reduces energy consumption, saves a lot of power resources, and avoids occupying additional computing resources. This not only reduces operating costs, but also avoids adverse effects on the environment of the data center.
[0016] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings.
[0017] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings: Figure 1 A flowchart of a method for backing up virtual machine data provided by an embodiment of the present invention; Figure 2 A schematic block diagram of a virtual machine data backup system provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0019] The present invention is further described in detail below with reference to specific embodiments, but the embodiments of the present invention are not limited thereto.
[0020] like Figure 1 As shown, a first aspect of an embodiment of the present invention provides a method for backing up virtual machine data, comprising the following steps: Step 11: The backup virtual machine receives a startup instruction.
[0021] Step 12: The backup virtual machine reads the default configuration file of the boot program.
[0022] Among them, the default configuration file includes single-user mode parameters.
[0023] Step 13: The backup virtual machine starts according to the default configuration file and enters single-user mode.
[0024] Step 14: The backup virtual machine reads the target service execution file from the startup directory in the single-user mode and runs the target service execution file.
[0025] Step 15: The target service execution file reads the network information file in the target setting directory and sets the network information according to the network information file.
[0026] In this embodiment, when the backup virtual machine is started for the first time, the default configuration file in the boot program enters single-user mode by default when starting. There are fewer programs running in single-user mode, which can reduce the energy consumption of the backup virtual machine and occupy fewer computing resources. At the same time, after entering the single-user mode, only the target service execution file is run, that is, the backup virtual machine only starts the service in the target service execution file, and other services are not started. The target service execution file is used to set the network information, so that when the backup virtual machine is started for the first time, only the network information needs to be set, and no other services need to be started. The backup virtual machine completes the setting of the network information, so that when the backup virtual machine is not needed, the main server can be used to detect whether the network connection status of the backup virtual machine is normal. The backup virtual machine does not need to run other functions, which significantly reduces energy consumption, saves a lot of power resources, and avoids occupying additional computing resources. This not only reduces operating costs, but also avoids adverse effects on the environment of the data center.
[0027] A second aspect of an embodiment of the present invention provides a method for backing up virtual machine data, which is applied to a Linux system and includes the following steps: Step 21: In response to an instruction to delete the original service execution file in the startup directory of the single-user mode of the backup virtual machine, the local server deletes the original service execution file.
[0028] In this step, before deleting the original service execution file, a target service execution file is created in advance. Before the backup virtual machine is started, the original service execution file used to start the service in the startup directory in the single-user mode is deleted.
[0029] Step 22, the local server stores the target service execution file, the target setting directory and the network information file in response to the instruction to add the target service execution file in the startup directory of the single-user mode of the backup virtual machine and the instruction to add the target setting directory and the network information file in the single-user mode.
[0030] Here, after deleting the original service execution file, the target service execution file is stored in the startup directory, so that when the backup virtual machine is started, only the service corresponding to the target service execution file will be run, and other services will not be run. At the same time, a new directory is added in the single-user mode, and the newly added directory is the target setting directory, and then the pre-created network information file is stored in the target setting directory. The network information file stores the network information of the backup virtual machine, such as the MAC address, IP address, subnet mask and gateway.
[0031] Step 23: The local server modifies the default configuration file in response to the instruction to add a single-user mode parameter to the default configuration file of the boot program of the backup virtual machine.
[0032] Before starting the backup virtual machine, modify the default configuration file of the boot program and add the single-user mode parameter single to the default configuration file.
[0033] Taking the Linux system as an example, modify the grub.cfg boot menu and add the single parameter. This parameter means starting the computer in single-user mode. The code example with the single parameter added is as follows: [root@localhost grub2]# pwd / boot / grub2 [root@localhost grub2]# vim grub.cfg menuentry 'centOS Linux(3.10.0-693.el7.x86_64) 7 (core)' --classcentos --class gnu –class os –unrestricted $menuentry_id_option 'gnulinux-3.10.0-693.el7.x86_64-advanced-b01e725a-445f-467f-94a6-cbebfa5df3cc'{ load_video set gfxpayload=keep insmod gzio insmod part_msdos insmod xfs set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 01701220-010c-4f5c-8bf8-f6c2f16731d3 else search --no-floppy --fs-uuid --set=root 01701220-010c-4f5c-8bf8-f6c2f16731d3 fi linux16 / vmlinuz-3.10.0-693.e17.x86_64 root= / dev / mapper / centos-rootro crashkernel=auto rd.lvm.lv=centos / root rd.lvm.lv=centos / swap rhgb quietLANG=en_US.UTF-8 single initrd16 / initramfs-3.10.0-693.el7.x86_64.img Here, the execution order of step 21, step 22 and step 23 is not particular, and the above steps are performed in the local server, that is, in the background end.
[0034] Step 24: The primary server sends a startup instruction to the backup virtual machine, and the backup virtual machine receives the startup instruction. The primary server is used to store primary data, and the backup virtual machine is used to back up the primary data of the primary server. The primary server can be a local server or a cloud server. The backup virtual machine can be local or cloud.
[0035] Step 25, the backup virtual machine reads the default configuration file of the boot program.
[0036] Among them, the default configuration file includes single-user mode parameters.
[0037] Step 26: The backup virtual machine runs the default configuration file to start and enter single-user mode.
[0038] Step 27: The backup virtual machine reads the target service execution file from the startup directory in the single-user mode and runs the target service execution file.
[0039] After the backup virtual machine is powered on in single-user mode, it will automatically read the executable file in the startup directory / etc / rc.d / rc1.d. The startup directory only stores the target service execution file start.sh. The content in the target service execution file start.sh is the program for starting the required related services, that is, the program for setting network information.
[0040] For example, the code to read the target service execution file and run the target service execution file is as follows: [root@localhost rcl.d]# pwd / etc / rc.d / rc1.d [root@localhost rc1.d]# cat start.sh systemctl start dsgcdpagent [root@localhost rc1.d]# Step 28: The target service execution file reads the network information file in the target setting directory and sets the network information according to the network information file.
[0041] After the target service execution file is run, it will read the contents of the network information file in the target setting directory, obtain and set the network information. For example, after the target service execution file is run, it will read the contents of the takeoverip.conf file in the / home / dsgcdpagent / conf directory and set the network information.
[0042] For example, the code to read the contents of the network information file in the target setting directory is as follows: [root@localhost conf]# pwd / home / dsgcdpagent / conf [root@localhost conf]# cat takeoverip.conf 00:0c:29:ba:f4:0a,192.168.80.207 / 24,192.168.80.1 [root@localhost conf]# After the network information is set, the backup virtual machine is started. To start the backup virtual machine, you only need to set the network information, and no other services need to be started.
[0043] Step 29: After the network information is set, the main server sends an ICMP echo request message to the IP address of the network information at a preset interval.
[0044] Step 30: The primary server detects whether an ICMP echo reply message of the backup virtual machine corresponding to the IP address of the network information is received.
[0045] Here, after the network information is set, the corresponding network information is also set on the primary server so that the primary server can communicate with the backup virtual machine. When the backup virtual machine does not need to perform backup disaster recovery, the primary server pings the IP address of the backup virtual machine at intervals to detect whether the ping is successful. If successful, it means that the network status of the backup virtual machine is normal and the target service executable file is available. If it fails, it means that the network status of the backup virtual machine may be abnormal, or the target service executable file may be abnormal.
[0046] In a feasible implementation, when disaster recovery is required, the backup virtual machine needs to switch from the current single-user mode to the multi-user mode to start the corresponding service for disaster recovery operation. The primary server sends a disaster recovery instruction to the backup virtual machine. After the backup virtual machine receives the disaster recovery instruction, the backup virtual machine switches from the current single-user mode to the multi-user mode according to the disaster recovery instruction, and performs the disaster recovery operation after the switch is completed.
[0047] like Figure 2 As shown, a third aspect of an embodiment of the present invention provides a backup virtual machine data backup system, including: a backup virtual machine 31; The backup virtual machine 31 is used to receive a startup instruction; The backup virtual machine 31 is used to read the default configuration file of the boot program; wherein the default configuration file includes single-user mode parameters; The backup virtual machine 31 is used to run a default configuration file to start up and enter a single-user mode; The backup virtual machine 31 is used to read the target service execution file from the startup directory of the single-user mode and run the target service execution file; The target service execution file reads the network information file in the target setting directory and sets the network information according to the network information file.
[0048] In one embodiment of the present invention, a local server 32 is also included; The local server 32 is used to delete the original service execution file in response to the instruction to delete the original service execution file in the startup directory of the single-user mode of the backup virtual machine; The local server 32 is used to store the target service execution file, the target setting directory and the network information file in response to the instruction to add the target service execution file in the startup directory of the single-user mode of the backup virtual machine and the instruction to add the target setting directory and the network information file in the single-user mode; The local server 32 is used to modify the default configuration file in response to an instruction to add a single-user mode parameter in the default configuration file of the boot program of the backup virtual machine.
[0049] In one embodiment of the present invention, it further includes a main server 33; The main server 33 is used to send ICMP echo request messages to the IP address of the network information at preset intervals; The main server 33 is used to detect whether an ICMP echo reply message of the backup virtual machine corresponding to the IP address of the network information is received.
[0050] In one embodiment of the present invention, the main server 33 is also used to send a disaster recovery instruction to the backup virtual machine; The backup virtual machine 31 is also used to receive a disaster recovery instruction; wherein the disaster recovery instruction indicates switching the single-user mode to the multi-user mode; The backup virtual machine 31 is also used to switch to multi-user mode according to the disaster recovery instruction; The backup virtual machine 31 is also used to perform disaster recovery operations.
[0051] A fourth aspect of an embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a method for backing up virtual machine data provided in the above-mentioned embodiment of the present invention is implemented.
[0052] A fifth aspect of an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of a method for backing up virtual machine data provided by the above-mentioned embodiment of the present invention are implemented.
[0053] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0054] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware systems.
[0055] The method provided in the embodiment of the present invention can be applied to electronic devices. Specifically, the electronic device can be: a desktop computer, a portable computer, an intelligent mobile terminal, a server, etc. This is not limited here, and any electronic device that can implement the present invention belongs to the protection scope of the present invention.
[0056] As for the system / electronic device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0057] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0058] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0059] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0060] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A method for backing up virtual machine data, characterized in that: The following steps are involved: The backup virtual machine receives a startup instruction; The backup virtual machine reads a default configuration file of the boot program; wherein the default configuration file includes single-user mode parameters; The backup virtual machine runs the default configuration file to start up and enter single-user mode; The backup virtual machine reads the target service execution file from the startup directory of the single-user mode and runs the target service execution file; The target service execution file reads a network information file in a target setting directory and sets network information according to the network information file.
2. The method according to claim 1, characterized in that Before the backup virtual machine receives the startup instruction, the method further includes: The local server deletes the original service execution file in response to the instruction to delete the original service execution file in the startup directory of the single-user mode of the backup virtual machine; The local server stores the target service execution file, the target setting directory and the network information file in response to an instruction to add a target service execution file in a startup directory in a single-user mode of the backup virtual machine and an instruction to add a target setting directory and a network information file in the single-user mode; The local server modifies the default configuration file in response to the instruction to add a single-user mode parameter in the default configuration file of the boot program of the backup virtual machine.
3. The method according to claim 1, characterized in that The method further comprises: The main server sends an ICMP echo request message to the IP address of the network information at a preset interval; The primary server detects whether an ICMP echo reply message of the backup virtual machine corresponding to the IP address of the network information is received.
4. The method according to claim 1, characterized in that The method further comprises: The primary server sends a disaster recovery instruction to the backup virtual machine; The backup virtual machine receives the disaster recovery instruction; wherein the disaster recovery instruction instructs switching the single-user mode to the multi-user mode; The backup virtual machine switches to multi-user mode according to the disaster recovery instruction; Back up the virtual machine for disaster recovery.
5. A virtual machine data backup system, characterized in that: include: Back up virtual machines; The backup virtual machine is used to receive a startup instruction; The backup virtual machine is used to read a default configuration file of the boot program; wherein the default configuration file includes single-user mode parameters; The backup virtual machine is used to run the default configuration file to start up and enter the single-user mode; The backup virtual machine is used to read the target service execution file from the startup directory of the single-user mode and run the target service execution file; The target service execution file reads a network information file in a target setting directory and sets network information according to the network information file.
6. The system according to claim 5, characterized in that Also includes local servers; The local server is used to delete the original service execution file in response to the instruction to delete the original service execution file in the startup directory of the single-user mode of the backup virtual machine; The local server is used to store the target service execution file, the target setting directory and the network information file in response to an instruction to add a target service execution file in a startup directory in a single-user mode of the backup virtual machine and an instruction to add a target setting directory and a network information file in the single-user mode; The local server is used to modify the default configuration file in response to an instruction to add a single-user mode parameter in the default configuration file of the boot program of the backup virtual machine.
7. The system according to claim 5, characterized in that It also includes the main server; The main server is used to send an ICMP echo request message to the IP address of the network information at a preset interval; The primary server is used to detect whether an ICMP echo reply message of the backup virtual machine corresponding to the IP address of the network information is received.
8. The system according to claim 7, characterized in that The primary server is also used to send disaster recovery instructions to the backup virtual machine; The backup virtual machine is also used to receive the disaster recovery instruction; wherein the disaster recovery instruction instructs to switch the single-user mode to the multi-user mode; The backup virtual machine is also used to switch to a multi-user mode according to the disaster recovery instruction; The backup virtual machine is also used for disaster recovery operations.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method for backing up virtual machine data according to any one of claims 1 to 4 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the backup virtual machine data backup method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Centralized management type backup and disaster recovery system
CN102012789A
Data backup method, device and computer program product
CN110058959A
File recovery method and system based on virtual machine backup data
CN111399984A
Migration method and system for dual backup of virtual machine and electronic equipment
CN118193139A
Virtual machine data replication
US20100262586A1