Reader small image

You're reading from  Mastering Proxmox. - Second Edition

Product typeBook
Published inMay 2016
PublisherPackt
ISBN-139781785888243
Edition2nd Edition
Tools
Right arrow
Author (1)
Wasim Ahmed
Wasim Ahmed
author image
Wasim Ahmed

Wasim Ahmed, born in Bangladesh and now a citizen of Canada, is a veteran of the IT world. He first came into close contact with computers in 1992 and never looked back. Wasim has a deep understanding of networks, virtualization, big data storage, and network security. By profession, Wasim is the CEO of a global IT support and cloud service provider based in Calgary, Alberta. He serves many companies and organizations through his company on a daily basis. Wasim's strength comes from his experience, which comes from learning and serving continually. Wasim strives to find the most effective solution at the most competitive price. He has built over 20 enterprise production virtual infrastructures using Proxmox and the Ceph storage system. Wasim and his team are notorious for not simply accepting a technology based on its description alone, but putting it through rigorous testing to check its validity. Any new technology that his company provides goes through months of continuous testing before it is accepted. Proxmox made the cut superbly.
Read more about Wasim Ahmed

Right arrow

Chapter 10. Backup/Restore VMs

A good backup strategy is the last line of defense against disasters, such as hardware failure, environmental damage, accidental deletions, or misconfigurations. In a virtual environment, a backup strategy can turn into a daunting task because of the number of virtual machines needed to be backed up. In a busy production environment, a new virtual machine can come and go any time. Without a proper backup plan, the entire backup task can become difficult to manage. Gone are those days when we only had a few servers' hardware to deal with, and backing them up was an easy task. In today's virtual environments, a backup solution has to deal with several dozens or possibly several hundred virtual machines.

Depending on the business requirement, an administrator may have to backup all the virtual machines regularly instead of just the files inside VMs. Backing up an entire virtual machine takes up a very large amount of space after a while, depending on how many previous...

Proxmox backup options


As of Proxmox VE 4.1, there are two backup options included out of the box:

  • Full backup: This backs up the entire virtual machine

  • Snapshots: This freezes the state of a VM at a point in time

Proxmox 4.1 can only do a full backup and cannot do any granular file backup from inside a virtual machine. Proxmox also does not use any backup agent.

A full backup

A full backup is a complete compressed backup of a virtual machine, including its configuration file. We can take this backup and restore it locally to the same cluster or to an entirely different Proxmox cluster. We can potentially set up a full backup everyday or on a different schedule up to one week. Since a full backup commits the complete backup of the entire virtual machine, including all the virtual disk images in it, it is the slowest backup option. It is also the safest since the final backup file is not dependent on the original VM. Two of the most important components of a full backup are backup modes and...

Configuring backup storage


A sound backup strategy has a dedicated shared storage for the backup images instead of local storage that is used for the disk images themselves. This way, we can centralize the backup location and restore them even in the event of a Proxmox node failure. If the backup is stored locally on the same node, during hardware failures, that node may become completely inaccessible causing a VM restoration delay.

One of the most popular options for a backup storage node is NFS. In an enterprise or mission-critical environment, a cluster with built in redundancy dedicated to backups is a recommended practice. In smaller environments, good redundancy can still be achieved using storage options, such as Gluster or DRBD. With the addition of ZFS and Gluster in Proxmox VE, it is now a viable option to turn a Proxmox node into a backup using Gluster on top of ZFS, and still manage the node through the Proxmox GUI. Unfortunately, we cannot store backup files on the Ceph RBD storage...

Configuring full backup


All full backups are in the tar format containing both the configuration file and virtual disk image file. The backup files are all you need to restore a virtual machine on any nodes and on any storage. Full backup files are named based on the several following formats for both KVM and LXC virtual machines:

vzdump-lxc-<ct_id>-YYYY_MM_DD-HH_MM_SS.tar
vzdump-lxc-<ct_id>-YYYY_MM_DD-HH_MM_SS.tar.lzo
vzdump-lxc-<ct_id>-YYYY_MM_DD-HH_MM_SS.tar.gz

vzdump-qemu-<vm_id>-YYYY_MM_DD-HH_MM_SS.vma
vzdump-qemu-<vm_id>-YYYY_MM_DD-HH_MM_SS.vma.lzo
vzdump-qemu-<vm_id>-YYYY_MM_DD-HH_MM_SS.vma.fz

The following screenshot shows a list of backup files in a backup storage node, as seen from the Proxmox GUI:

In Proxmox, we can schedule automated backup tasks or commit manual backups for each virtual machine. Whether scheduled or manual, the backup process is the same for both KVM and LXC virtual machines.

Creating a schedule for Backup

Schedules can be created...

Creating a manual backup


A manual backup can be performed on a particular virtual machine at any time through the Proxmox GUI. The Manual backup option is accessible through the Backup tabbed menu of the virtual machine. From the same Backup menu, we can back up, restore, and delete backup files.

To open the backup creation dialog box, we need to click on the Backup now button. The Manual backup dialog box is extremely simple. We only need to select the destination Storage node, backup Mode, and Compression level, as shown in the following screenshot:

Creating snapshots


Snapshots are a great way to preserve the state of a virtual machine. It is much faster than a full backup since it does not copy all the data. Snapshot is not really a backup in this way and does not perform granular level backup. It captures the state in a point in time and allows rollback to that previous state.

Snapshot is a great feature to be used in between full backups. The Snapshot option can be found under the Snapshots tabbed menu of the virtual machine. A newly installed VM without any Snapshots will appear under the Snapshots menu, as shown in the following screenshot:

The actual snapshot creation process is very straightforward. Click on Take Snapshot to open the dialog box, and then just enter a Name, select or deselect the RAM content, and type in some description. The Name textbox does not allow any spaces and the name must start with a letter of the alphabet. The following screenshot shows the Snapshots creation dialog box for our example VM #112:

Note

Keep...

Restoring a VM


Like Backup, we can also restore virtual machines through the Proxmox GUI. VMs can be restored through the Backup menu tab of the VM or by selecting a backup file through the storage content list. If restore is selected through the VM backup option, then the VM ID cannot be changed. To understand this better, let's take a look at the following example:

In the preceding screenshot, we are under the Backup option for VM #112. Since the backup option shows a list of all backup files stored in that backup storage node, we can see the backup files for VM #110. If we select the backup file and then click on Restore, we will not be able to restore the VM #110 on its own. Instead, it will actually replace VM #112. The following screenshot shows the Restore dialog box where the destination VM ID is not definable:

In order to restore a backup file with its original VM ID, we need to select the backup file from the storage content tab menu, as shown in the following screenshot:

If we select...

Backup/restore through the CLI


In Proxmox, the entire backup and restore process can be managed from the command line in case the GUI becomes inaccessible.

Backup using the CLI

The command to commit backup for both KVM and LXC virtual machines is the same. The following is the command format for backup:

# vzdump <vmid> <options>

There is a long list of vzdump options that can be used with the command. The following are just a few of the most commonly used ones:

Back up a configuration file


The backup configuration file in Proxmox allows more advanced options to be used. For example, if we want to limit the backup speed so that the backup task does not consume all of the available network bandwidth, we can limit it with the bwlimit option. As of Proxmox VE 4.1, the configuration file cannot be edited from the GUI. It has to be done from the CLI using an editor. The backup configuration file can be found in /etc/vzdump.conf. The following is the default vzdump.conf file on a new Proxmox cluster:

# tmpdir: DIR
# dumpdir: DIR
# storage: STORAGE_ID
# mode: snapshot|suspend|stop
# bwlimit: KBPS
# ionice: PRI
# lockwait: MINUTES
# stopwait: MINUTES
# size: MB
# maxfiles: N
# script: FILENAME
# exclude-path: PATHLIST
# pigz: N:

All the options are commented by default in the file because Proxmox has a set of default options already encoded in the operating system. Changing the vzdump.conf file overwrites the default settings and allows us to customize the...

Summary


In this chapter, we looked at the backup and restore features in Proxmox, how to configure them, and how to use them to create a good data disaster plan. There are no substitutes for data backup to face any disasters where data may be at risk. As much as backup is important, the ability to restore is also equally important, since backup files will not mean anything if restore is not possible in the time of need. Although Proxmox does not provide everything you need for backup such as a granular file backup, backing up a virtual machine is very helpful. Backup features in the Proxmox platform have proven to be reliable in production environments and during actual disaster scenarios.

In the next chapter, we are going to take a look at the necessity of an up-to-date Proxmox cluster and how to apply new releases or patches regularly.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Mastering Proxmox. - Second Edition
Published in: May 2016Publisher: PacktISBN-13: 9781785888243
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Wasim Ahmed

Wasim Ahmed, born in Bangladesh and now a citizen of Canada, is a veteran of the IT world. He first came into close contact with computers in 1992 and never looked back. Wasim has a deep understanding of networks, virtualization, big data storage, and network security. By profession, Wasim is the CEO of a global IT support and cloud service provider based in Calgary, Alberta. He serves many companies and organizations through his company on a daily basis. Wasim's strength comes from his experience, which comes from learning and serving continually. Wasim strives to find the most effective solution at the most competitive price. He has built over 20 enterprise production virtual infrastructures using Proxmox and the Ceph storage system. Wasim and his team are notorious for not simply accepting a technology based on its description alone, but putting it through rigorous testing to check its validity. Any new technology that his company provides goes through months of continuous testing before it is accepted. Proxmox made the cut superbly.
Read more about Wasim Ahmed

Options

Description

-all

The default value is 0. This option will back up all available virtual machines in a Proxmox node.

-bwlimit

This adjusts the backup bandwidth in KBPS.

-compress

The default value is LZO. This sets the compression type or disables compression. The available options are 0, 1, gzip, and lzo.

-mailto

This is the e-mail address used to send a backup report.

-maxfiles

This contains an integer number. This sets the maximum number of backup files to be kept.

-mode

The default value...