About backups in Proxmox VE


In the article “The Magic of Virtualization: An Introductory Course in Proxmox VE”, we successfully installed a hypervisor on the server, connected the storage to it, took care of basic security and even created the first virtual machine. Now we’ll look at how to implement the most basic tasks that you have to perform in order to always be able to restore the services in case of failure.

Established Proxmox tools allow you to not only back up data, but also create sets of pre-configured images of operating systems for quick deployment. This not only helps if necessary to create a new server for any service in a few seconds, but also reduces downtime to a minimum.

We will not talk about the need to create backups, since this is obvious and has long been an axiom. Let us dwell on some unobvious things and features.

First, consider how the data is saved during the backup procedure.

Backup algorithms


To begin with, Proxmox has a good staffing toolkit for creating backups of virtual machines. It allows you to easily save all the data of the virtual machine and supports two compression mechanisms, as well as three methods for creating these copies.

Let us first examine the compression mechanisms:

  1. LZO. , 90- . ( Proxmox lzop). . , , , .
  2. Compressing the GZIP . Using this algorithm, the backup will be compressed on the fly with the GNU Zip utility, which uses the powerful Deflate algorithm created by Phil Katz . The main emphasis is on maximum data compression, which reduces the disk space occupied by backups. The main difference from LZO is that the compression / decompression procedures take a fairly large amount of time.

Archiving Modes


Proxmox offers three backup methods for the system administrator to choose from. Using them, you can solve the required problem by determining the priority between the need for downtime and the reliability of the backup:

  1. Snapshot (). Live backup, . VM, — - . , , . , , .
  2. Suspend (). «» , . , , . , , / , . , . .
  3. Stop mode . The most reliable backup method, but requiring a complete shutdown of the virtual machine. A command is sent to shutdown normally, after stopping, a backup is performed and then a command is issued to turn on the virtual machine. The number of errors with this approach is minimal and most often reduced to zero. Backups created in this way almost always deploy correctly.

Perform backup procedure


To back up:

  1. We pass to the necessary virtual machine.
  2. Select the Reservation item .
  3. Click the Reserve Now button . A window will open in which you can select the options for the future backup.


  4. As the storage we indicate the one that we connected in the previous part .
  5. After selecting the parameters, click the Backup button and wait until the backup is created. This will be indicated by the inscription TASK OK .


Now created archives with backups of virtual machines will be available for download from the server. The simplest and most common way of copying is SFTP. To do this, use the popular Cross-platform FTP client FileZilla, which can work using the SFTP protocol.

  1. IP- , root, — , , «22» ( , SSH-).
  2. , , , .
  3. /mnt/storage. «dump». :
    • vzdump-qemu-_--.vma.gz GZIP;
    • vzdump-qemu-machine_number-date-time.vma.lzo if the LZO method is selected.

It is recommended that you download backups immediately from the server and save them in a safe place, for example, in our cloud storage. If you unzip a file with the resolution vma, the utility of the same name that comes bundled with Proxmox, then files with the extensions raw , conf and fw will be inside . These files contain the following:

  • raw - disk image;
  • conf - VM configuration;
  • fw - firewall settings.

Restore from backup


Consider the situation when the virtual machine was accidentally deleted and its emergency recovery from the backup is required:

  1. Open the storage on which the backup lies.
  2. Go to the Content tab .
  3. Select the desired copy and click the Restore button .


  4. We specify the target storage and the ID that will be assigned to the machine after the process is completed.
  5. Click the Restore button .

Once recovery is complete, the VM will appear in the list of available.

Virtual machine cloning


For example, suppose a company needs to make changes to a critical service. Such a change is implemented by making many changes to the configuration files. The result is unpredictable and any error can cause a service failure. To prevent such an experiment from affecting a running server, it is recommended that you clone the virtual machine.

The cloning mechanism will create an exact copy of the virtual server with which it is permissible to make any changes without affecting the operation of the main service. Then, if the changes are successfully applied, the new VM starts up and the old one shuts down. There is a feature in this process that should always be remembered. On the cloned machine, the IP address will be exactly the same as the source VM, that is, when it starts, there will be an address conflict.

We will tell you how to avoid such a situation. Immediately before performing the cloning, you should make changes to the network configuration. To do this, you need to temporarily change the IP address, but do not restart the network service. After cloning on the main machine, you should return the settings back, and on the cloned machine, specify any other IP address. Thus, we get two copies of the same server at different addresses. This will quickly introduce a new service.

If this service is a web server, then you just need to change the A-record of your DNS provider, after which client requests for this domain name will already be sent to the address of the cloned virtual machine.
By the way, Selectel provides all its customers with the service of placing any number of domains on NS servers for free. Records management is carried out both using our control panel, and using a special API. Read more about this in our knowledge base .
Cloning a VM in Proxmox is a very simple task. To perform it, you must perform the following steps:

  1. Go to the car we need.
  2. Choose from the menu More click the Clone .
  3. In the window that opens, fill in the Name parameter.

  4. Clone by pressing the Clone button .

This tool allows you to make a copy of a virtual machine not only on the local server. If several virtualization servers are combined into a cluster, then using this tool you can immediately move the created copy to the desired physical server. A useful function is the choice of disk storage ( Target Storage parameter ), which is very convenient when moving a virtual machine from one physical medium to another.

Virtual Drive Formats


We will tell you more about the drive formats used in Proxmox:

  1. RAW. . « » . , mount linux-. «» , .

    , , RAW ( ).
  2. QEMU image format (qcow2). , . , . , 40 , 2 , VM. .

    : , nbd, qemu-nbd, . , , .

    , - , . , RAW.
  3. VMware image format (vmdk) . This format is native to the VMware vSphere hypervisor and has been included with Proxmox for compatibility. It allows you to migrate a VMware virtual machine to the Proxmox infrastructure.

    Using vmdk on an ongoing basis is not recommended, this format is the slowest in Proxmox, so it is suitable only for migration, no more. Probably in the foreseeable future this shortcoming will be eliminated.

Work with disk images


Included with Proxmox is a very convenient utility called qemu-img . One of its functions is to convert images of virtual disks. To use it, just open the hypervisor console and run the command in the format:

qemu-img convert -f vmdk test.vmdk -O qcow2 test.qcow2

In the above example, the vmdk image of the VMware virtual drive called test will be converted to qcow2 format . This is a very useful command when you need to correct a mistake in the initial format selection.

Thanks to the same command, you can force the desired image using the create argument :

qemu-img create -f raw test.raw 40G

Such a command will create a test image in RAW format , 40 GB in size. Now it is suitable for connecting to any of the virtual machines.

Resize a virtual disk


In conclusion, we will show how to increase the size of a disk image if, for some reason, the space on it is no longer enough. To do this, use the resize argument:

qemu-img resize -f raw test.raw 80G

Now our image has become the size of 80 GB. You can view detailed information about the image using the info argument :

qemu-img info test.raw

Do not forget that the image extension itself will not increase the size of the partition automatically - it will simply add the available free space. To enlarge the section, use the command:

resize2fs /dev/sda1

where / dev / sda1 is the desired partition.

Automate backups


Using the manual method of creating backups is a very time-consuming task and takes a lot of time. Therefore, Proxmox VE includes a tool for automatic scheduled backups. Consider how to do this:

  1. Using the web interface of the hypervisor, open the Datacenter item .
  2. Select the Reservation item .
  3. Click the Add button .
  4. We set the parameters for the scheduler.


  5. Check the box Enable .
  6. Save the changes using the Create button .

Now the scheduler will automatically start the backup program at the exact specified time, based on the specified schedule.

Conclusion


We considered regular methods of backup and recovery of virtual machines. Their use allows you to save all the data without any problems and urgently restore them in case of emergency.

Of course, this is not the only possible way to save important data. There are many tools, for example, Duplicity , with which you can create full and incremental copies of the contents of virtual servers based on Linux.

When performing backup procedures, you should always consider that they are actively loading the disk subsystem. In this regard, it is recommended to perform these procedures at times of minimum load in order to avoid delays when performing I / O operations inside the machines. You can monitor the status of disk operation delays directly from the web interface of the hypervisor (IO delay parameter).

Source: https://habr.com/ru/post/undefined/


All Articles