Export running VM as backup

Alessandro 123

Well-Known Member
May 22, 2016
653
24
58
40
Sorry for the dumb question but i'm new to proxmox, i'm using it from less than a year and with only 4 VMs currently.

How can I export a running VM as a backup image, ready to be restored in case of disaster recovery ?
 
Last edited:
I've seen that is possible to use the following command line to backup and restore a VM via command line without using a dedicated storage (from the web interface, I'm forced to choose local storage for backup and this is not what i want)

Code:
vzdump 101 --stdout | pct restore --rootfs 4 300 -

Can I do the same via API? In example, with XenServer I can create & fetch a VM backup remotely with "wget", how can I do the same with proxmox ?

Something like (pseudocode):
Code:
curl -X POST "/api2/json/nodes/{node}/vzdump" -d '{"stdout": true}'

will download the backup file as response to the POST call ?
 
Basic approach:

* Configure an external storage device to export some NFS shares.

* Configure Proxmox to use that external storage location.

* In /etc/pve/vzdump.cron create a cron job:

Code:
02 00 * * * root vzdump 101 --quiet 1 --mode snapshot --storage ${name of external storage}

If desired the cron job can be configured using the web browser interface (Datacenter->Backup)
 
I don't want to add an external NFS server. Our backup environment in on a natted network. The ability to dump the whole backup file remotely via API would be better.

In example, our current XenServer backup is made by a couple of shell script called from backup server but on the end, they do a simple "wget https://my.xenserver.host/export?uuid=....................."

With this, I don't have to share anything from xenserver. I would like to do the same with proxmox, if possible. Additionally, this will allow me to remotely backup our servers.
 
no, it is not possible to backup and get the backup contents via the API, neither directly (backups run async), nor via a file as intermediate (there is no "download" or "upload" API call for backups).
 
Is this something you plan to add ? It's a very very useful feature.

Anyway, i've seen that vzdump is able to send a stream to stdout. Is possible to use vzdump remotely by specifiying the remote host to connect to ? Like "xe -h" in XenServer
 
Is this something you plan to add ? It's a very very useful feature.

we don't really want long-running sync tasks in our API from a design point of view.

Anyway, i've seen that vzdump is able to send a stream to stdout. Is possible to use vzdump remotely by specifiying the remote host to connect to ? Like "xe -h" in XenServer

you can always use ssh if you want to directly dump and restore in one go - but most people use "clone" operations for this, which are supported via the API.
 
we don't really want long-running sync tasks in our API from a design point of view.

That's a shame, it is very useful. I've used this kind of export not less than hundreds time, with XenServer (probably, it is the only think I like in that junk software).

you can always use ssh if you want to directly dump and restore in one go - but most people use "clone" operations for this, which are supported via the API.

I can't use ssh because SSH is not directly accessible from outside our network. The only accessible port is the web interface
Keep in mind that I don't have to dump and restore in one go. I just have to dump, from a remote host (the backup server) that doesn't have SSH access to proxmox node. I'm trying to backup some VMs without using a shared storage connected to proxmox (our backup server) can't be directly connected, it's natted and on another room and also for security reasons we don't expose anything from it, so no NFS server) and without using SSH (ssh is blocked except from our single VPN aggregator in multiple points: switches, firewalls and so on, allowing ssh to pass would be a mess)
 
I can't use ssh because SSH is not directly accessible from outside our network. The only accessible port is the web interface
Keep in mind that I don't have to dump and restore in one go. I just have to dump, from a remote host (the backup server) that doesn't have SSH access to proxmox node. I'm trying to backup some VMs without using a shared storage connected to proxmox (our backup server) can't be directly connected, it's natted and on another room and also for security reasons we don't expose anything from it, so no NFS server) and without using SSH (ssh is blocked except from our single VPN aggregator in multiple points: switches, firewalls and so on, allowing ssh to pass would be a mess)

sounds like you should re-evaluate your policies then. if access to the web interface is not a problem, then some kind of access to download or upload files should also not be a problem (or vice-versa, if limited ssh/scp/... access to copy backup archives is a problem, then access to the web interface should be a problem as well)
 
ssh is dropped at datacenter level.
I can download/upload a file from/to PVE, yes, but currently, I can't create a backup without using a shared storage connected to PVE and I don't have enough space available on each node.

As I can see in the web interface, backups can be stored locally, and I don't have space, that's why I've asked for a direct stream like with XenServer.

What exactly does 'vzdump 101 --stdout' ? It should call an API, right ?
 
ssh is dropped at datacenter level.
I can download/upload a file from/to PVE, yes, but currently, I can't create a backup without using a shared storage connected to PVE and I don't have enough space available on each node.

As I can see in the web interface, backups can be stored locally, and I don't have space, that's why I've asked for a direct stream like with XenServer.

What exactly does 'vzdump 101 --stdout' ? It should call an API, right ?

the CLI 'vzdump' tool uses the same code as the REST API does, but the 'stdout' option is limited to the CLI.
 
the CLI 'vzdump' tool uses the same code as the REST API does, but the 'stdout' option is limited to the CLI.

Ok, but how the stdout option works ? Which call is made to the API to not save a file ? Or are you saving a file and the stream that file to stdout ?
 
I'm not a perl programmer. Is still unclear, I don't see where 'stdout' option is passed to the API

I am not sure what you want here.. the API does not support what you want it to do, and I already gave you the solution to your problem...
 
If api doesn't support a stream to stdout, how does vzdump work?

vzdump (the CLI tool) uses the same code as the vzdump API endpoints, but it is not called over the API/HTTP. the code checks whether it's run from the CLI or from the API, and changes behaviour accordingly. the same applies to the restore operations and piping from stdin.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!