From: Mauro de Pascale <mauro.depascale.work@outlook.it>
To: "pve-devel@lists.proxmox.com" <pve-devel@lists.proxmox.com>
Subject: [PATCH 1/2] manager: add API endpoint for streamed VM backup export
Date: Wed, 23 Sep 2026 12:25:08 +0000 [thread overview]
Message-ID: <LOBP265MB8961242F79498817CE7301DBAD822@LOBP265MB8961.GBRP265.PROD.OUTLOOK.COM> (raw)
From: Mauro de Pascale <mauro.depascale.work@outlook.it>
Add an API endpoint that exposes vzdump output as a streamed download,
allowing clients to export VM backups directly without storing them on
the server first.
________________________________
PVE/API2/VZDump.pm | 65 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/PVE/API2/VZDump.pm b/PVE/API2/VZDump.pm
index a8f21eba..84f42352 100644
--- a/PVE/API2/VZDump.pm
+++ b/PVE/API2/VZDump.pm
@@ -9,11 +9,15 @@ use PVE::Exception qw(raise_param_exc);
use PVE::INotify;
use PVE::JSONSchema qw(get_standard_option);
use PVE::RPCEnvironment;
+use PVE::SafeSyslog;
use PVE::Storage;
use PVE::Tools qw(extract_param);
use PVE::VZDump::Common;
use PVE::VZDump;
+use IPC::Open3;
+use Symbol qw(gensym);
+
use PVE::API2::Backup;
use PVE::API2Tools;
@@ -311,4 +315,65 @@ __PACKAGE__->register_method({
},
});
+__PACKAGE__->register_method({
*
name => 'export',
*
path => 'export',
*
method => 'GET',
*
description => "Export a VM dump stream",
*
proxyto => 'node',
*
protected => 1,
*
permissions => {
*
check => ['perm', '/vms/{vmid}', ['VM.Backup']],
*
},
*
parameters => {
*
additionalProperties => 0,
*
properties => {
*
node => get_standard_option('pve-node'),
*
vmid => get_standard_option('pve-vmid'),
*
compress => {
*
description => "compression algorithm to use.",
*
type => 'string',
*
enum => ['zstd', 'gzip', 'lzo', '0'],
*
optional => 1,
*
default => 'zstd',
*
},
*
},
*
},
*
returns => { type => 'object' },
*
download => 1,
*
code => sub {
*
my ($param) = @_;
*
*
my $vmid = $param->{vmid};
*
my $compress = $param->{compress} // 'zstd';
*
*
my $suffix = $compress eq 'zstd' ? 'zst'
*
: $param->{compress} eq 'gzip' ? 'gz'
*
: $param->{compress} eq 'lzo' ? 'lzo'
*
: 'vma';
*
*
my $filename = "vzdump-qemu-$vmid.vma.$suffix";
*
*
my $cmd = ['/usr/bin/vzdump', $vmid, '--stdout','1','--compress',$compress];
*
my $cmdstr = join(' ', @$cmd);
*
syslog('info', "running export cmd: $cmdstr");
*
*
#my ($fh, $pid) = PVE::Tools::run_command($cmd, pipe => 1);
*
open my $fh, '-|', @$cmd
*
or die "unable to execute backup $!
";
*
*
binmode($fh);
*
*
*
return {
*
download => {
*
fh => $fh,
*
filename => $filename,
*
stream => 1,
*
'content-type' => 'application/octet-stream',
*
'content-disposition' => "attachment; filename="$filename"",
*
}
*
};
*
}});
*
*
1;
*
--
2.47.3
next reply other threads:[~2026-09-23 12:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 12:25 Mauro de Pascale [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-06-26 16:43 [PATCH 0/2] RFC: manager: add direct VM backup export/import support Mauro de Pascale
2026-06-26 16:43 ` [PATCH 1/2] manager: add API endpoint for streamed VM backup export Mauro de Pascale
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=LOBP265MB8961242F79498817CE7301DBAD822@LOBP265MB8961.GBRP265.PROD.OUTLOOK.COM \
--to=mauro.depascale.work@outlook.it \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox