]> git.proxmox.com Git - qemu-server.git/blob - PVE/CLI/qmrestore.pm
bump version to 8.2.1
[qemu-server.git] / PVE / CLI / qmrestore.pm
1 package PVE::CLI::qmrestore;
2
3 use strict;
4 use warnings;
5 use PVE::SafeSyslog;
6 use PVE::Tools qw(extract_param);
7 use PVE::INotify;
8 use PVE::RPCEnvironment;
9 use PVE::CLIHandler;
10 use PVE::JSONSchema qw(get_standard_option);
11 use PVE::Cluster;
12 use PVE::QemuServer;
13 use PVE::API2::Qemu;
14
15 use base qw(PVE::CLIHandler);
16
17 sub setup_environment {
18 PVE::RPCEnvironment->setup_default_cli_env();
19 }
20
21 __PACKAGE__->register_method({
22 name => 'qmrestore',
23 path => 'qmrestore',
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.",
32 type => 'string',
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 => {
42 optional => 1,
43 type => 'boolean',
44 description => "Allow to overwrite existing VM.",
45 },
46 unique => {
47 optional => 1,
48 type => 'boolean',
49 description => "Assign a unique random ethernet address.",
50 },
51 pool => {
52 optional => 1,
53 type => 'string', format => 'pve-poolid',
54 description => "Add the VM to the specified pool.",
55 },
56 bwlimit => {
57 description => "Override I/O bandwidth limit (in KiB/s).",
58 optional => 1,
59 type => 'number',
60 minimum => '0',
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 },
67 },
68 },
69 returns => {
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);
78 }});
79
80 our $cmddef = [ __PACKAGE__, 'qmrestore', ['archive', 'vmid'], undef,
81 sub {
82 my $upid = shift;
83 my $status = PVE::Tools::upid_read_status($upid);
84 exit(PVE::Tools::upid_status_is_error($status) ? -1 : 0);
85 }];
86
87 1;