X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=qmrestore;h=506f2bdcebd0da3a7df17858bb47c9c35f83f8bc;hb=1e5143de74496a86b0ff4c550dc22aa4ce5d17b3;hp=f256b39fa109f752ea55c27e19bd703650123541;hpb=3e16d5fc605b1a5475c1e82630a7e37211626e65;p=qemu-server.git diff --git a/qmrestore b/qmrestore index f256b39..506f2bd 100755 --- a/qmrestore +++ b/qmrestore @@ -1,99 +1,8 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl use strict; -use PVE::SafeSyslog; -use PVE::Tools qw(extract_param); -use PVE::INotify; -use PVE::RPCEnvironment; -use PVE::CLIHandler; -use PVE::JSONSchema qw(get_standard_option); -use PVE::API2::Qemu; +use warnings; -use Data::Dumper; # fixme: remove +use PVE::CLI::qmrestore; -use base qw(PVE::CLIHandler); - -$ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin'; - -initlog('qmrestore'); - -die "please run as root\n" if $> != 0; - -PVE::INotify::inotify_init(); - -my $rpcenv = PVE::RPCEnvironment->init('cli'); - -$rpcenv->init_request(); -$rpcenv->set_language($ENV{LANG}); -$rpcenv->set_user('root@pam'); - -__PACKAGE__->register_method({ - name => 'qmrestore', - path => 'qmrestore', - method => 'POST', - description => "Restore QemuServer vzdump backups.", - parameters => { - additionalProperties => 0, - properties => { - vmid => get_standard_option('pve-vmid'), - archive => { - description => "The backup file.", - type => 'string', - maxLength => 255, - }, - storage => get_standard_option('pve-storage-id', { - description => "Default storage.", - optional => 1, - }), - force => { - optional => 1, - type => 'boolean', - description => "Allow to overwrite existing VM.", - }, - }, - }, - returns => { - type => 'string', - }, - code => sub { - my ($param) = @_; - - $param->{node} = PVE::INotify::nodename(); - - return PVE::API2::Qemu->create_vm($param); - }}); - -my $cmddef = [ __PACKAGE__, 'qmrestore', ['archive', 'vmid'], undef, - sub { - my $upid = shift; - my $status = PVE::Tools::upid_read_status($upid); - exit($status eq 'OK' ? 0 : -1); - }]; - -push @ARGV, 'help' if !scalar(@ARGV); - -PVE::CLIHandler::handle_simple_cmd($cmddef, \@ARGV, undef, $0); - -exit 0; - -__END__ - -=head1 NAME - -qmrestore - restore QemuServer vzdump backups - -=head1 SYNOPSIS - -=include synopsis - -=head1 DESCRIPTION - -Restore the QemuServer vzdump backup C to virtual machine -C. Volumes are allocated on the original storage if there is no -C specified. - -=head1 SEE ALSO - -vzdump(1) vzrestore(1) - -=include pve_copyright +PVE::CLI::qmrestore->run_cli_handler();