
In this article We have successfully installed the hypervisor on the server, connected storage to it, ensured basic security, and even created the first virtual machine. Now, let's discuss how to accomplish the most fundamental tasks that must be performed to always have the ability to restore services in case of an outage.
Proxmox's built-in tools not only allow for data backups, but also for the creation of sets of pre-configured operating system images for rapid deployment. This not only helps when it's necessary to create a new server for any service in seconds, but also minimizes downtime.
We won't discuss the necessity of creating backups, as this is obvious and has long been an axiom. Instead, let's focus on some less obvious aspects and features.
First, let's review how data is saved during the backup procedure.
Backup Algorithms
To begin with, Proxmox has decent built-in tools for creating backups of virtual machines. It easily saves all the data of the virtual machine and supports two compression mechanisms as well as three methods for creating these backups.
Let's first examine the compression mechanisms:
- LZO Compression. A lossless data compression algorithm developed back in the mid-1990s. The code was written by . The main feature of this algorithm is its very fast decompression. Consequently, any backup created using this algorithm can be restored in minimal time when needed.
- GZIP Compression. When using this algorithm, the backup is compressed "on the fly" by the GNU Zip utility, which employs a powerful Deflate algorithm created by . The primary focus is on maximizing data compression, which helps reduce the disk space occupied by backups. The main difference from LZO is that the compression/decompression processes take a considerable amount of time.
Archiving Modes
Proxmox offers system administrators three backup methods to choose from. These methods can help address the required tasks by balancing the need for downtime with the reliability of the backup created:
- Snapshot Mode. This mode can also be referred to as Live backup, as it does not require stopping the virtual machine's operation. Using this mechanism does not interrupt the VM's work, but there are two significant drawbacks — issues may arise due to file locks by the operating system and the lowest backup creation speed. Backups created using this method should always be tested in a test environment. Otherwise, there is a risk that they may fail during emergency restoration.
- Suspend Mode. The virtual machine temporarily "freezes" its state until the backup process is completed. The contents of RAM are not erased, allowing work to continue exactly from the point where it was paused. Naturally, this causes server downtime during the information copying process, yet there is no need to power off/on the virtual machine, which is quite critical for certain services. Especially if the startup of some services is not automatic. Nevertheless, these backups should also be deployed in a test environment for verification.
- Stop Mode. The most reliable backup method, requiring the virtual machine to be completely turned off. A command is sent to shut down the VM, once it is stopped, the backup is performed, followed by a command to power the virtual machine back on. The number of errors with this approach is minimal and often reduced to zero. Backups created in this way almost always deploy correctly.
Performing the backup procedure
To create a backup:
- Navigate to the required virtual machine.
- We choose the item Failover.
- Click the button Backup Now. A window will open where you can select the parameters for the future backup.

- As the storage, specify the one that we connected .
- After selecting the parameters, click the button Failover We are waiting for the backup to be created. A message will indicate this. TASK OK.

The created archives with virtual machine backups will now be available for download from the server. The simplest and most common way to copy is via SFTP. For this, use the popular cross-platform FTP client FileZilla, which supports the SFTP protocol.
- In the field Host Enter the IP address of our virtualization server in the field. Username Enter root in the field. Password — the one that was chosen during installation, and in the field Port specify '22' (or any other port specified for SSH connections).
- Click the button Quick connect and, if all data has been entered correctly, you will see all files located on the server in the active panel.
- Go to the directory /mnt/storage. All created backups will be located in the subdirectory 'dump'. They will be named:
- vzdump-qemu-machine_number-date-time.vma.gz if the GZIP method was selected;
- vzdump-qemu-machine_number-date-time.vma.lzo if the LZO method was selected.
It is recommended to immediately download backups from the server and save them in a secure location, for example, in our cloud storage. If you unpack a file with the .vma extension using the corresponding utility that comes with Proxmox, it will contain files with the following extensions .raw, .conf and .fw. These files contain the following:
- .raw — disk image;
- .conf — VM configuration;
- .fw — firewall settings.
Recovering from a backup
Let's consider a situation where a virtual machine was accidentally deleted and requires emergency recovery from a backup:
- Open the storage where the backup is located.
- Go to the Contents.
- Select the required copy and click the Restore.

- Specify the target storage and the ID that will be assigned to the machine after the process is completed.
- Click the button Restore.
Once the recovery is complete, the VM will appear in the list of available ones.
Cloning a virtual machine
For example, let’s assume that the company needs to make changes to a critical service. Such a change is implemented by making numerous edits to the configuration files. The result is unpredictable, and any mistake can cause a service failure. To avoid impacting the running server with such an experiment, it is recommended to clone the virtual machine.
The cloning mechanism will create an exact copy of the virtual server, allowing for any modifications without affecting the operation of the main service. Then, if the changes are successfully implemented, the new VM is put into operation, and the old one is shut down. There is an important detail to keep in mind during this process: the cloned machine will have the same IP address as the original VM, which means that a conflict will occur upon its launch.
Here's how to avoid such a situation. Directly before performing the cloning, you should make changes to the network configuration. This requires temporarily changing the IP address without restarting the network service. After the cloning is complete, revert the settings on the main machine and assign a different IP address to the cloned machine. This way, you will have two copies of the same server on different addresses, allowing you to quickly bring the new service online.
If this service is a web server, it is enough to simply change the A-record with your DNS provider, after which client requests to that domain name will be directed to the address of the cloned virtual machine.
By the way, Selectel provides all its clients with the service of hosting any number of domains on NS servers for free. Record management can be done both through our control panel and via a special API. Read more about this .
Cloning a VM in Proxmox is a very straightforward task. To perform it, you need to follow these steps:
- Go to the required machine.
- Select from the menu More the item . Then enter the name of the cloned report (let's call it.
- In the opened window, fill in the Name parameter.

- Execute the cloning by pressing the button . Then enter the name of the cloned report (let's call it.
This tool allows you to create a copy of the virtual machine not only on the local server. If several virtualization servers are combined into a cluster, this tool can simultaneously move the created copy to the desired physical server. A useful feature is selecting the storage option (the parameter Target Storage), which is very convenient when moving a virtual machine from one physical medium to another.
Virtual disk formats
Let's discuss in detail the storage formats used in Proxmox:
- RAWThe most straightforward and simple format. It is a file containing the data of the hard drive 'byte for byte' without compression or optimization. This format is very convenient, as it can be easily mounted using the standard mount command in any Linux system. Moreover, it is the fastest 'type' of storage, since the hypervisor does not need to process it in any way.
A significant drawback of this format is that whatever space you allocate for the virtual machine, the file in RAW format will occupy exactly that much space on the hard drive (regardless of the actual space used inside the virtual machine).
- QEMU image format (qcow2)This is perhaps the most versatile format for performing any tasks. Its advantage is that the data file will contain only the space actually used inside the virtual machine. For example, if 40 GB of space was allocated but only 2 GB was actually used, then the remaining space will be available for other VMs. This is very relevant in conditions of conserving disk space.
A slight downside to working with this format is that to mount such an image in any other system, you will first need to load the , and also use the utility qemu-nbd, which will allow the operating system to access the file as a regular block device. After that, the image will be available for mounting, partitioning, performing file system checks, and other operations.
It should be noted that all input/output operations when using this format are handled programmatically, which leads to slowdown during active work with the disk subsystem. If the task is to deploy a database on a server, it is better to choose the RAW format.
- VMware image format (vmdk)This format is 'native' to the VMware vSphere hypervisor and has been included in Proxmox for compatibility. It allows for the migration of a VMware virtual machine to the Proxmox infrastructure.
Using vmdk on a permanent basis is not recommended; this format is the slowest in Proxmox, therefore it is only suitable for migration, nothing more. This deficiency is likely to be addressed in the foreseeable future.
Working with disk images
The Proxmox package includes a very convenient utility called qemu-img. One of its functions is converting virtual disk images. To use it, simply open the hypervisor console and execute the command in the following format:
qemu-img convert -f vmdk test.vmdk -O qcow2 test.qcow2In the example provided, the vmdk image of the VMware virtual storage called test will be converted to the format qcow2. This is a very useful command when it's necessary to correct a mistake made during the initial format selection.
With this same command, you can also forcibly create the required image using the argument create:
qemu-img create -f raw test.raw 40GThis command will create an image named test in the format RAW, with a size of 40 GB. It is now suitable for connection to any of the virtual machines.
Resizing a Virtual Disk
Finally, let's show how to increase the size of a disk image if, for some reason, space on it has become insufficient. For this, we will use the resize argument:
qemu-img resize -f raw test.raw 80GNow our image has a size of 80 GB. You can view detailed information about the image using the argument info:
qemu-img info test.rawRemember that simply changing the image size will not automatically increase the partition size — it will merely add available free space. To increase the partition, use the command:
resize2fs /dev/sda1where /dev/sda1 — the required partition.
Automating Backup Creation
Using a manual method for creating backups is quite labor-intensive and time-consuming. Therefore, Proxmox VE includes a tool for automatic scheduled backups. Let's see how to do this:
- Using the web interface of the hypervisor, navigate to the section Datacenter.
- We choose the item Failover.
- Click the button Add.
- Set the parameters for the scheduler.

- Check the option Enable.
- Save the changes using the button Create.
Now the scheduler will automatically initiate the backup program at the exact specified time, based on the set schedule.
Conclusion
We reviewed the standard methods of backing up and restoring virtual machines. Their use allows for preserving all data and quickly restoring it in the event of an unexpected situation.
Of course, this is not the only possible way to save important data. There are many tools available, such as, , which allows you to create full and incremental backups of the content of Linux-based virtual servers.
When performing backup procedures, it is important to consider that they place a significant load on the disk subsystem. Therefore, it is recommended to carry out these procedures during periods of minimal load to avoid delays in input/output operations within the machines. You can monitor the status of disk operation delays directly from the hypervisor's web interface (parameter IO delay).
Source: habr.com





