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 783DB6888C for ; Tue, 10 Nov 2020 18:57:23 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6BA5E259A9 for ; Tue, 10 Nov 2020 18:56:53 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id C8B732599F for ; Tue, 10 Nov 2020 18:56:51 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 964E846066 for ; Tue, 10 Nov 2020 18:56:51 +0100 (CET) From: Stoiko Ivanov To: pmg-devel@lists.proxmox.com Date: Tue, 10 Nov 2020 18:56:35 +0100 Message-Id: <20201110175635.30142-1-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.090 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_PASS -0.001 SPF: sender matches SPF record T_SPF_HELO_TEMPERROR 0.01 SPF: test of HELO record failed (temperror) URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [backup.pm, pmg-scores.cf, custom.cf] Subject: [pmg-devel] [PATCH pmg-api] backup: add SA custom score file to backup X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Nov 2020 17:57:23 -0000 /etc/mail/spamassassin/pmg-scores.cf contains the custom scores users can set via GUI. It should be included in the backup (and restored if present). Reported via our community forum: https://forum.proxmox.com/threads/backup-restore-bug.78605/ Tested on my local setup by creating a bogus score, creating a backup, removing the pmg-scores file and restoring the backup. Signed-off-by: Stoiko Ivanov --- src/PMG/Backup.pm | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/PMG/Backup.pm b/src/PMG/Backup.pm index e77f67c..275fa12 100644 --- a/src/PMG/Backup.pm +++ b/src/PMG/Backup.pm @@ -13,7 +13,10 @@ use PMG::pmgcfg; use PMG::AtomicFile; use PMG::Utils qw(postgres_admin_cmd); -my $sa_custom_config_fn = "/etc/mail/spamassassin/custom.cf"; +my $sa_configs = [ + "/etc/mail/spamassassin/custom.cf", + "/etc/mail/spamassassin/pmg-scores.cf", +]; sub get_restore_options { return ( @@ -202,7 +205,7 @@ sub pmg_backup { my $extra_cfgs = []; - push @$extra_cfgs, $sa_custom_config_fn; + push @$extra_cfgs, @{$sa_configs}; my $extradb = $include_statistics ? $statfn : ''; @@ -308,10 +311,12 @@ sub pmg_restore { system("cp -a $dirname/config/etc/pmg/* /etc/pmg/") == 0 || die "unable to restore system configuration: ERROR"; - if (-f "$dirname/config/${sa_custom_config_fn}") { - my $data = PVE::Tools::file_get_contents( - "$dirname/config/${sa_custom_config_fn}", 1024*1024); - PVE::Tools::file_set_contents($sa_custom_config_fn, $data); + for my $sa_cfg (@{$sa_configs}) { + if (-f "$dirname/config/${sa_cfg}") { + my $data = PVE::Tools::file_get_contents( + "$dirname/config/${sa_cfg}", 1024*1024); + PVE::Tools::file_set_contents($sa_cfg, $data); + } } my $cfg = PMG::Config->new(); -- 2.20.1