]> git.proxmox.com Git - qemu-server.git/blame - qmrestore
drive-mirror : wait that busy eq false before block-job-complete
[qemu-server.git] / qmrestore
CommitLineData
990fc5e2 1#!/usr/bin/perl
1e3baf05
DM
2
3use strict;
990fc5e2 4use warnings;
3e16d5fc
DM
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::API2::Qemu;
12
13use Data::Dumper; # fixme: remove
14
15use base qw(PVE::CLIHandler);
16
17$ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
18
19initlog('qmrestore');
20
21die "please run as root\n" if $> != 0;
22
23PVE::INotify::inotify_init();
24
25my $rpcenv = PVE::RPCEnvironment->init('cli');
26
27$rpcenv->init_request();
28$rpcenv->set_language($ENV{LANG});
29$rpcenv->set_user('root@pam');
30
31__PACKAGE__->register_method({
32 name => 'qmrestore',
33 path => 'qmrestore',
34 method => 'POST',
35 description => "Restore QemuServer vzdump backups.",
36 parameters => {
37 additionalProperties => 0,
38 properties => {
39 vmid => get_standard_option('pve-vmid'),
40 archive => {
97fb319d 41 description => "The backup file. You can pass '-' to read from standard input.",
3e16d5fc
DM
42 type => 'string',
43 maxLength => 255,
44 },
45 storage => get_standard_option('pve-storage-id', {
46 description => "Default storage.",
47 optional => 1,
48 }),
49 force => {
50 optional => 1,
51 type => 'boolean',
52 description => "Allow to overwrite existing VM.",
53 },
51586c3a
DM
54 unique => {
55 optional => 1,
56 type => 'boolean',
57 description => "Assign a unique random ethernet address.",
58 },
a0d1b1a2
DM
59 pool => {
60 optional => 1,
61 type => 'string', format => 'pve-poolid',
62 description => "Add the VM to the specified pool.",
63 },
3e16d5fc
DM
64 },
65 },
66 returns => {
67 type => 'string',
68 },
69 code => sub {
70 my ($param) = @_;
71
72 $param->{node} = PVE::INotify::nodename();
73
74 return PVE::API2::Qemu->create_vm($param);
75 }});
76
77my $cmddef = [ __PACKAGE__, 'qmrestore', ['archive', 'vmid'], undef,
78 sub {
79 my $upid = shift;
80 my $status = PVE::Tools::upid_read_status($upid);
81 exit($status eq 'OK' ? 0 : -1);
82 }];
83
84push @ARGV, 'help' if !scalar(@ARGV);
85
86PVE::CLIHandler::handle_simple_cmd($cmddef, \@ARGV, undef, $0);
87
88exit 0;
1e3baf05
DM
89
90__END__
91
92=head1 NAME
3e16d5fc 93
1e3baf05
DM
94qmrestore - restore QemuServer vzdump backups
95
96=head1 SYNOPSIS
97
3e16d5fc 98=include synopsis
1e3baf05
DM
99
100=head1 DESCRIPTION
101
3e16d5fc
DM
102Restore the QemuServer vzdump backup C<archive> to virtual machine
103C<vmid>. Volumes are allocated on the original storage if there is no
104C<storage> specified.
1e3baf05
DM
105
106=head1 SEE ALSO
107
3e16d5fc
DM
108vzdump(1) vzrestore(1)
109
110=include pve_copyright