]> git.proxmox.com Git - pve-manager.git/blame - PVE/Jobs/VZDump.pm
fix #4026: add 'repeat-missed' option for jobs
[pve-manager.git] / PVE / Jobs / VZDump.pm
CommitLineData
76c6ee8a
DC
1package PVE::Jobs::VZDump;
2
3use strict;
4use warnings;
5
6use PVE::INotify;
7use PVE::VZDump::Common;
8use PVE::API2::VZDump;
9use PVE::Cluster;
b3422046 10use PVE::JSONSchema;
76c6ee8a
DC
11
12use base qw(PVE::Jobs::Plugin);
13
14sub type {
15 return 'vzdump';
16}
17
18my $props = PVE::VZDump::Common::json_config_properties();
19
20sub properties {
21 return $props;
22}
23
24sub options {
25 my $options = {
26 enabled => { optional => 1 },
27 schedule => {},
998b61fb 28 comment => { optional => 1 },
c61c192e 29 'repeat-missed' => { optional => 1 },
76c6ee8a
DC
30 };
31 foreach my $opt (keys %$props) {
32 if ($props->{$opt}->{optional}) {
33 $options->{$opt} = { optional => 1 };
34 } else {
35 $options->{$opt} = {};
36 }
37 }
38
39 return $options;
40}
41
b3422046
DC
42sub decode_value {
43 my ($class, $type, $key, $value) = @_;
44
45 if ($key eq 'prune-backups' && !ref($value)) {
46 $value = PVE::JSONSchema::parse_property_string(
47 'prune-backups',
48 $value,
49 );
50 }
51
52 return $value;
53}
54
55sub encode_value {
56 my ($class, $type, $key, $value) = @_;
57
58 if ($key eq 'prune-backups' && ref($value) eq 'HASH') {
59 $value = PVE::JSONSchema::print_property_string(
60 $value,
61 'prune-backups',
62 );
63 }
64
65 return $value;
66}
67
76c6ee8a
DC
68sub run {
69 my ($class, $conf) = @_;
70
71 # remove all non vzdump related options
72 foreach my $opt (keys %$conf) {
73 delete $conf->{$opt} if !defined($props->{$opt});
74 }
75
4048af34
TL
76 my $retention = $conf->{'prune-backups'};
77 if ($retention && ref($retention) eq 'HASH') { # fixup, its required as string parameter
78 $conf->{'prune-backups'} = PVE::JSONSchema::print_property_string($retention, 'prune-backups');
79 }
80ea4443 80
76c6ee8a
DC
81 $conf->{quiet} = 1; # do not write to stdout/stderr
82
83 PVE::Cluster::cfs_update(); # refresh vmlist
84
85 return PVE::API2::VZDump->vzdump($conf);
86}
87
881;