From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 70CA8727D8 for ; Wed, 16 Jun 2021 09:27:36 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6A10DE7E1 for ; Wed, 16 Jun 2021 09:27:06 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 8595BE797 for ; Wed, 16 Jun 2021 09:27:04 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 4357244047 for ; Wed, 16 Jun 2021 09:27:04 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Wed, 16 Jun 2021 09:26:53 +0200 Message-Id: <20210616072700.54289-2-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210616072700.54289-1-f.ebner@proxmox.com> References: <20210616072700.54289-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.761 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [pve6to7.pm] Subject: [pve-devel] [PATCH v2 manager 1/3] pve6to7: add checks for backup retention options X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jun 2021 07:27:36 -0000 Note that it's not possible to use read_vzdump_defaults() and storage_config(), because they auto-converts maxfiles already. Signed-off-by: Fabian Ebner --- New in v2. PVE/CLI/pve6to7.pm | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/PVE/CLI/pve6to7.pm b/PVE/CLI/pve6to7.pm index 0b6267d5..b8263dab 100644 --- a/PVE/CLI/pve6to7.pm +++ b/PVE/CLI/pve6to7.pm @@ -18,6 +18,7 @@ use PVE::RPCEnvironment; use PVE::Storage; use PVE::Tools qw(run_command); use PVE::QemuServer; +use PVE::VZDump::Common; use Term::ANSIColor; @@ -513,6 +514,66 @@ sub check_ceph { } } +sub check_backup_retention_settings { + log_info("Checking backup retention settings.."); + + my $pass = 1; + + my $node_has_retention; + + my $maxfiles_msg = "parameter 'maxfiles' is deprecated with PVE 7.x and will be removed in a " . + "future version, use 'prune-backups' instead."; + + eval { + my $confdesc = PVE::VZDump::Common::get_confdesc(); + + my $fn = "/etc/vzdump.conf"; + my $raw = PVE::Tools::file_get_contents($fn); + + my $conf_schema = { type => 'object', properties => $confdesc, }; + my $param = PVE::JSONSchema::parse_config($conf_schema, $fn, $raw); + + if (defined($param->{maxfiles})) { + $pass = 0; + log_warn("$fn - $maxfiles_msg"); + } + + $node_has_retention = defined($param->{maxfiles}) || defined($param->{'prune-backups'}); + }; + if (my $err = $@) { + $pass = 0; + log_warn("unable to parse node's VZDump configuration - $err"); + } + + my $storage_cfg = PVE::Storage::config(); + + for my $storeid (keys $storage_cfg->{ids}->%*) { + my $scfg = $storage_cfg->{ids}->{$storeid}; + + if (defined($scfg->{maxfiles})) { + $pass = 0; + log_warn("storage '$storeid' - $maxfiles_msg"); + } + + next if !$scfg->{content}->{backup}; + next if defined($scfg->{maxfiles}) || defined($scfg->{'prune-backups'}); + next if $node_has_retention; + + log_info("storage '$storeid' - no backup retention settings defined - by default, PVE " . + "7.x will no longer keep only the last backup, but all backups"); + } + + my $vzdump_cron = PVE::Cluster::cfs_read_file('vzdump.cron'); + + # only warn once, there might be many jobs... + if (scalar(grep { defined($_->{maxfiles}) } $vzdump_cron->{jobs}->@*)) { + $pass = 0; + log_warn("/etc/pve/vzdump_cron - $maxfiles_msg"); + } + + log_pass("no problems found.") if $pass; +} + sub check_misc { print_header("MISCELLANEOUS CHECKS"); my $ssh_config = eval { PVE::Tools::file_get_contents('/root/.ssh/config') }; @@ -602,6 +663,8 @@ sub check_misc { log_pass("Certificate '$fn' passed Debian Busters security level for TLS connections ($size >= 2048)"); } } + + check_backup_retention_settings(); } __PACKAGE__->register_method ({ -- 2.20.1