From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-api] backup: add SA custom score file to backup
Date: Tue, 10 Nov 2020 18:56:35 +0100 [thread overview]
Message-ID: <20201110175635.30142-1-s.ivanov@proxmox.com> (raw)
/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 <s.ivanov@proxmox.com>
---
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
next reply other threads:[~2020-11-10 17:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-10 17:56 Stoiko Ivanov [this message]
2020-11-18 7:12 ` [pmg-devel] applied: " Thomas Lamprecht
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=20201110175635.30142-1-s.ivanov@proxmox.com \
--to=s.ivanov@proxmox.com \
--cc=pmg-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox