]> git.proxmox.com Git - qemu-server.git/blame - PVE/CLI/qmrestore.pm
bump version to 8.2.1
[qemu-server.git] / PVE / CLI / qmrestore.pm
CommitLineData
cc7b93ec
DM
1package PVE::CLI::qmrestore;
2
3use strict;
4use warnings;
5use PVE::SafeSyslog;
6use PVE::Tools qw(extract_param);
7use PVE::INotify;
8use PVE::RPCEnvironment;
9use PVE::CLIHandler;
10use PVE::JSONSchema qw(get_standard_option);
11use PVE::Cluster;
12use PVE::QemuServer;
13use PVE::API2::Qemu;
14
15use base qw(PVE::CLIHandler);
16
5e4035c7
DM
17sub setup_environment {
18 PVE::RPCEnvironment->setup_default_cli_env();
19}
20
cc7b93ec 21__PACKAGE__->register_method({
a022e3fd
AL
22 name => 'qmrestore',
23 path => 'qmrestore',
cc7b93ec
DM
24 method => 'POST',
25 description => "Restore QemuServer vzdump backups.",
26 parameters => {
27 additionalProperties => 0,
28 properties => {
29 vmid => get_standard_option('pve-vmid', { completion => \&PVE::Cluster::complete_next_vmid }),
30 archive => {
31 description => "The backup file. You can pass '-' to read from standard input.",
a022e3fd 32 type => 'string',
cc7b93ec
DM
33 maxLength => 255,
34 completion => \&PVE::QemuServer::complete_backup_archives,
35 },
36 storage => get_standard_option('pve-storage-id', {
37 description => "Default storage.",
38 optional => 1,
39 completion => \&PVE::QemuServer::complete_storage,
40 }),
41 force => {
a022e3fd 42 optional => 1,
cc7b93ec
DM
43 type => 'boolean',
44 description => "Allow to overwrite existing VM.",
45 },
46 unique => {
a022e3fd 47 optional => 1,
cc7b93ec
DM
48 type => 'boolean',
49 description => "Assign a unique random ethernet address.",
50 },
a022e3fd 51 pool => {
cc7b93ec
DM
52 optional => 1,
53 type => 'string', format => 'pve-poolid',
54 description => "Add the VM to the specified pool.",
55 },
7c536e11 56 bwlimit => {
31150d20 57 description => "Override I/O bandwidth limit (in KiB/s).",
7c536e11
WB
58 optional => 1,
59 type => 'number',
60 minimum => '0',
020dd358
SR
61 },
62 'live-restore' => {
63 optional => 1,
64 type => 'boolean',
65 description => "Start the VM immediately from the backup and restore in background. PBS only.",
66 },
cc7b93ec
DM
67 },
68 },
a022e3fd 69 returns => {
cc7b93ec
DM
70 type => 'string',
71 },
72 code => sub {
73 my ($param) = @_;
74
75 $param->{node} = PVE::INotify::nodename();
76
77 return PVE::API2::Qemu->create_vm($param);
a022e3fd 78 }});
cc7b93ec 79
a022e3fd 80our $cmddef = [ __PACKAGE__, 'qmrestore', ['archive', 'vmid'], undef,
cc7b93ec
DM
81 sub {
82 my $upid = shift;
83 my $status = PVE::Tools::upid_read_status($upid);
831ad442 84 exit(PVE::Tools::upid_status_is_error($status) ? -1 : 0);
cc7b93ec
DM
85 }];
86
871;