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