Blogs

Backing Up Virutal Machines in Promox

Apr 23, 2025 - 3 minute read

My Story

I have been using Promox since a while for my home lab and it has a ton of Virtual Machines in them that continuously keeps running throughout the year and I hardly used to get any time to backup them up. Yeah, I had snapshots and other kinds of emergency stuff in places for my Virtual Machines, but taking a backup at the image level of the Virtual Machine was a bit task to me. Mainly the waiting time for the image to be extracted and then to be transferred to my external Hard Disk, etc….. Long ago I had build an automated script for exporting my virtual machines (Proxmox.sh, you can find that Here). And so one night, I thought, I will build an automation script for backing up my servers. And here was my plan.

My Plan

Now, Since Sundays are my usual holidays and there are higher probability that I stay at my home on Sundays, I thought of scheduling an automatic backup of all my servers at 00:05.

So, here is is how it looks:

My Virtual Machines are going to Power off automatically at 00:00 –> The Proxmox Server is going to make a list of powered off virtual machines –> Backup those powered off virtual machines using the Proxmox.sh tool –> Power on the Virtual Machine –> Zip the the images of the virtual machines –> and save it in a folder.

As simple as that…… if you want the command for powering off your Virtual Machines (only Linux), you can add this to your cronjob using the command sudo crontab -e

0 0 * * 0 /sbin/shutdown -h now

The story and events described is purely fictional and was used for the purpose of providing context and reference to the upcoming technical steps and methods

Backing up

Getting the Codes

Here, it was a simple job, I asked ChatGPT to build a script and it works…… hahaha….

NO, let’s break it down, you can get the script from the GitHub Repository, Here

Clone that repository into your Promox server where you would want to keep all your scripts together.

git clone https://github.com/Rao-Pranava/Automation-Scripts.git

Once cloned, browse to the Automation-Scripts/Proxmox folder.

!Image Description

Now, give it the permission to run as an executable

chmod +x export_all_vms.sh

!Image Description

Now, for the purpose of example, we will run this script manually

./export_all_vms.sh

!Image Description

Here, in my case I just have two virtual machines powered off.

Automation

Now, according to my plans, I want to automate the process of the Backup script, I don’t want to manually login and then these commands to backup my virtual machines.

For that I will be making use of cronjobs using the command crontab -e in my Promox Server and then paste the following command at the last

5 0 * * 0 /home/export_all_vms.sh >> /var/log/vm_backup.log 2>&1

Make sure to update it with your actual path where the script is hosted at.

!Image Description

That is it….. as simple as that to backup the virtual machines at a scheduled time.