Proxmox How To Backup VMs

Oct 30, 2023 · 16 mins read
Proxmox How To Backup VMs

In the video below, we show you how to backup virtual machines from within Proxmox VE itself

Keeping backup copies of computers and data is extremely important

To give you some perspective, I was once told by an insurer that companies that don’t recover their computer systems within a month, usually go out of business

Now hopefully you’ll never have to face that scenario but you do need to be prepared

Fortunately, Proxmox VE has a built-in backup solution and you can use this with an NFS or SMB share on a NAS for instance

So in this video we go over how to backup and restore your VMs to a NAS

Now because this video is specifically about the built-in backup solution for Proxmox VE, I’m going to assume you already have a remote share configured that Proxmox VE can connect to

Every file server and NAS will have different ways to configure NFS and SMB shares, so it simply isn’t possible to cover them all

But I do have another video available that shows you how to setup NFS shares in TrueNAS for instance

Attach Remote Storage:
What Proxmox VE requires is somewhere to store backup files

Now while you could configure a backup job to store the backup files on an external hard drive, what we’re going to do is to create our backup storage using an NFS share

The reason being is that if we used an external drive, we’d then need to find another way for Proxmox VE for instance to backup those files offline

By storing them on a NAS, the files can be included in local and offline backup jobs that the NAS itself will be configured to do regularly

In any case, assuming you have a remote share available you’ll want to navigate to Datacenter | Storage

Here you should click on the Add drop down menu and select the type of storage to add. In this example it will be NFS

For this type of storage I need to provide an ID, in other words a meaningful name such as Backups

The server field should be the IP address or FQDN for the server with the share

Once that’s entered you should be able to click on the drop down menu for Export and select from the list of shares available

If you can’t you should check your NAS including connectivity to it as well as permissions because Proxmox VE will try to connect using its root account

Now click on the Content drop down menu, de-select Disk image, select VZDump backup file then click somewhere else to collapse the menu

TIP: For NFS, if you select Advanced you can select the NFS Version option. Typically I leave this alone as the newest version should be selected as part of the negotiation anyway so I won’t have to do anything for future NFS upgrades

I don’t have a reason to exclude certain nodes from this share, but the option is there if you need it

And by default, the storage will be enabled when we click Add, which is the final thing to do

Create Backup Job:
The backup solution that’s available allows you to backup your VMs on a regular basis by creating jobs

To do that, navigate to Datacenter | Backup and then click Add to create a new backup job

By default, all nodes and the VMs running on them can be covered by this job, but you can choose to limit this job to certain nodes from the Node drop down menu

It doesn’t seem to offer a means to select multiple nodes, only a single one, but this could be useful if there are certain VMs that need to be backed up more frequently than others for intanstance. The only problem I see here is if a VM is migrated to another node

For storage you need to opt for something that has been marked to keep backup files. In this example, we do have an option of the local drive as well but by default it has already picked the NFS share we attached earlier

There are several built-in schedules that you can choose from to run a job in the Schedule drop down menu. But if you recognise the systemd calendar event format you can create your own

As an example, if I select Every day 21:00, we just see a time of 21:00 which is 9pm. So if I want the job to run at 3am in the morning I can change this to 03:00

There are several selection modes to choose from but typically for a main backup job you’d want to use All. This way, any new VMs, containers or templates that are created will be automatically included. Likewise, any VMs that are deleted will be dropped

Now if you have VMs you don’t want to backup up, then the Exclude selected VMs might be the better choice so newer VMs don’t get missed out

There is an option to provide an email address to send emails to as well as choice of sending emails all the time or only if there’s a failure

If you don’t like receiving lots of emails, it may be tempting to choose On failure only. But if the email service ever stops working you could find yourself in a sitation where the backup jobs haven’t worked for a long time and you can’t recover anything recent

There are several options available for Compression, and although compressing a file means the backup job will take longer to run, it results in the backup file being smaller, there will be less data to transfer and it will save storage space as well

However, if the NAS for instance is already compressing files you might opt to disable this option at either end as it is possible for a compressed file to increase in size if it’s compressed again

The default mode that’s used is Snapshot which is probably the preferred option as it allows a VM to be backed up while it’s running

While you won’t get the best possible backup, the Suspend or Stop modes would require taking a VM out of commission while the backup is being done

And that’s another reason why it’s best not to keep important data on a computer

A backup job like this is unlikely to result in you being able to recover the most recent data file, but it could also require restoring an entire VM of maybe 20GB just to get a 20KB data file

In any case, you can provide a Comment for this job, to make it easier for Admins to know what it’s for for instance

And by default, the job will be enabled on creation so it will be ready as soon as it’s created

TIP: If you click the Advanced button, you’ll see an option to repeat missed jobs. By default this is disabled, because usually you’ll want backups to run at night due to the shear amount of data being transferred. If a problem ocurrs overnight, and is fixed the next morning, there’s a risk with this option of users experiencing connection problems if the backups kick in during the day and you don’t have a dedicated storage network to handle the traffic

Now aside from wanting to avoid running out of storage space, it pays to keep a certain number of backups and not every backup copy

This can be useful for dealing with software bugs that don’t show up for a while, file corruption as well as ransomware attacks for instance

In which case, click on the Retention tab so that we can create a policy for this job

Now what you select here really depends on your own situation

As an example, we’ll keep the last 3 daily backups, the last weekly backup and the last monthly backup

Anything older than that might be out of date in terms of patching or confiugration changes and I don’t keep important data on the VMs

For a business, however, it would make more sense to keep more monthly and even yearly copies as they have fiscal years to contend with and so you just don’t know what you’ll need to restore

When a backup is created, that will have a note created for it. By default it only contains the name of the VM, which makes it easier to identify, but there is a Note Template tab that you can select and change that template if you want to add more details to the files

The final thing to do is to click the Create button and your backup job is ready to go

Now one useful feature we can do is to run a job now rather than wait, but this may not be practical for a business as you don’t want to cause problems for users

Assuming you can do testing during the day, select the job then click the Run now button

When prompted click Yes, and wait for the job to complete in the task section

TIP: If you want know if a VM isn’t being backed up, click the Show: Guests Without Backup Job button
NOTE: This option only shows up if a VM isn’t being backed up

Restore For Real:
In an ideal world you won’t have to restore a VM, but you do need to be familiar with the restore process

Because the last thing you want is to be in situation where you do need to restore something, only to find you can’t

To restore a VM, you first need to decide which node to restore the VM to and then select the Backup storage attached to it

Assuming backups have been run, you should see a list of backup files which let you know what the VM is and when the backup was done

The ordering for these files is useful because the files for each VM can be grouped together for instance, or you can sort to show the most recent at the top

When it comes to restoring a VM there are options

Normally you’d restore a VM to replace one that was corrupted for instance, in which case you’d delete the original VM first and then restore it from backup

Or, you’d restore one when you’re carrying out a disaster recovery, in which case the VM is already missing

And there’s a key point here because you can’t overwrite an existing VM. If you try to restore one with the same ID, the system won’t let you and you don’t want to have duplicate computers on the network anyway

Assuming there is no existing VM, you would click the relevant backup file and then click the Restore button

The VM will be given the next available VM ID, but you can change that if you like

And you can set a bandwidth limit as well if you think the data transfer will overwhelm your network traffic

Unless there is a specific reason to reset things like the MAC address for NICs, you’ll probably want to leave the Unique option disabled

You also have an option to automatically start the VM when its restored, but usually this isn’t a good idea

And there are options to change some of the hardware allocations and even the name if you like, although you can edit these settings after it has been restored anyway

Finally you click Restore and wait for the process to complete

After that, you can then check the VM is working as intended

Restore For Testing:
When it comes to backing up computers and data, you can’t “set and forget”. You should regularly test that the backup process actually works

I’ve seen first hand what happens when backups can’t be restored, and the consquences were not pretty, so you MUST regularly check your backup process

The problem is, you can’t have identical computers on your network, ones with the same name, IP address, etc. because if you do you’ll run into a conflict and neither computer will work properly

While you could have a test VM that you regularly backup and restore. The only problem is you won’t know if the backup file for a real VM has become corrupted

In which case you could restore different VMs over time but to an isolated network. This could be an isolated bridge or VLAN on a PVE node for instance that allows you to at least spin up the VM after its restored so you can check the entire process

For that reason I’ve created a Linux Bridge in the cluster which essentially does nothing because it has no NICs attached to it. So even if a VM spins up it can’t communicate with anything beyond that bridge, not even the PVE node and so it can’t cause problems

To restore a VM like this, the first step is to decide which node to restore the VM to and then select the Backup storage attached to it

Now select the file to restore from and click Restore

The next available VM ID will be chosen, but I prefer to choose something else so that I know this VM is a backup test, 800 for instance versus the real ID of 100

As mentioned earlier there are options to change the bandwidth limit, reset things like the MAC address, start after restore and change some of the hardware settings but I’ll leave all these at the defaults and click Restore

NOTE: One key thing to point out is there is no option here to change the network settings so this VM should certainly not be allowed to start immediately

Once the VM has been restored therefore, the first thing to do is to select the VM, then navigate to hardware. Now select Network Device, change the Bridge and click OK

It doesn’t really matter what it’s other settings are at this point because it will be attached to an isolated bridge

Granted, it can’t be tested beyond a basic bootup and you can’t use an authentication system such as Active Directory to log into it, but as long as the VM does boot up, you could at least test local login to see if the computer seems to be working OK

If so, it should in theory be safe to assume that the backup file is intact and that it can be restored

In which case this VM should be shut down and deleted

NOTE: It wouldn’t be good to test a duplicate computer against Active Directory anyway, but I only point this out to set expectations in terms of testing functionality

File Management:
A useful option you get with this Proxmox backup solution is being able to manage the backup files it creates

Part of the backup job you create involves setting up a retention policy, so older files should get deleted automatically, but circumstances change and you can end up with files that are no longer needed for instance

You can remove a file for example, just select a file and then click Remove to delete it if it’s no longer needed

Unfortunately you can’t select multiple files though so it is a bit tediious if there are lots of files you want to remove

However, you can select a file and then click Prune group qemu/<vmid>, set some pruning details and then click Prune to only keep a certain number of files for that specific VM for instance

This can be a better way of recovering disk space for instance on your NAS rather then deleting files directly on the NAS itself

Another useful feature is that you can select a file and find the VMs configuration details by clicking Show Configuration

You can also edit the note for a file here as well by selecting that file and clicking on the Edit Notes button

But again, you can’t select multiple files to update them all in the same way unfortunately

If you want to protect a backup file from being pruned, you can select a file and click the Change Protection button

You can undo this by selecting the file and clicking the Change Protection button again

TIP: It didn’t seem all that intuitive to me at first because it appeared nothing was happening but there is a column between Notes and Date that has a shield in the header. When a file is being protected you’ll see a shield in that column

As far as VM backup solutions go, I think this is pretty much all you really need

As long as files on the NAS are being backed up to some other local storage, such as an external hard drive and also to the cloud for instance then this should cover you against most situations

But as I’ve hinted at before, the goal here isn’t to backup data files, because a restore would take too long if you only want to recover the data

What this backup solution is for is to cover you against a computer outage e.g. disaster recovery or corruption of the operating system and any applications installed on the VM

Bear in mind though, this doesn’t offer a way to backup Proxmox VE itself

Sharing is caring!