all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 manager 1/3] pve6to7: add checks for backup retention options
Date: Wed, 16 Jun 2021 09:26:53 +0200	[thread overview]
Message-ID: <20210616072700.54289-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20210616072700.54289-1-f.ebner@proxmox.com>

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 <f.ebner@proxmox.com>
---

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





  reply	other threads:[~2021-06-16  7:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-16  7:26 [pve-devel] [PATCH-SERIES v2 manager/storage] Some breaking API changes/cleanups Fabian Ebner
2021-06-16  7:26 ` Fabian Ebner [this message]
2021-06-16  7:26 ` [pve-devel] [PATCH v2 manager 2/3] pve6to7: add check for CIFS credentials Fabian Ebner
2021-06-16  7:26 ` [pve-devel] [PATCH v2 manager 3/3] ui: storage: update hint about prune-backups default Fabian Ebner
2021-06-16  7:26 ` [pve-devel] [PATCH v2 storage 1/5] postinst: move cifs credential files into subdirectory upon update Fabian Ebner
2021-06-16 13:11   ` Thomas Lamprecht
2021-06-17  8:09     ` Fabian Ebner
2021-06-16  7:26 ` [pve-devel] [PATCH v2 storage 2/5] config: mention that maxfiles is deprecated Fabian Ebner
2021-06-16  7:26 ` [pve-devel] [PATCH v2 storage 3/5] config: add backup content type to default local storage Fabian Ebner
2021-06-16  7:26 ` [pve-devel] [PATCH v2 storage 4/5] cephfs: revert safe-guard check for Luminous Fabian Ebner
2021-06-16  7:27 ` [pve-devel] [RFC v2 storage 5/5] cephfs: update reminder for systemd_netmount removal Fabian Ebner
2021-06-16 11:51 ` [pve-devel] applied-series: [PATCH-SERIES v2 manager/storage] Some breaking API changes/cleanups Fabian Grünbichler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210616072700.54289-2-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal