public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pmg-devel] [PATCH pmg-api/gui/docs v2] small improvments for PBS integration
@ 2021-03-01 14:12 Stoiko Ivanov
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-api v2 1/3] backup: pbs: prevent race in concurrent backups Stoiko Ivanov
                   ` (8 more replies)
  0 siblings, 9 replies; 14+ messages in thread
From: Stoiko Ivanov @ 2021-03-01 14:12 UTC (permalink / raw)
  To: pmg-devel

v2->v1:
* addressed Thomas great feedback!:
** reordered the patches (the prevention of the race for concurrent
   pbs-backup is not before the notification feature)
** concurrent pbs-backups now simply use a backup-tmpdir indexed by
   remote+pid+time instead of locking.
** printing and exiting on error now happen as before (instead of being delayed)
** default is 'never' (instead of the unclear mix of 'error' in the schema
   and 'never' in the code
** not having an admin-email configured is treated as warning.

original cover-letter for v1:
This patchset addresses #3146 and #3154.
Additionally I added patches for small cosmetic cleanups, and a fix
for concurrent pbs-backups (they raced with each other during my tests)

patch 1/4 for pmg-gui depends on an updated pmg-docs-generator for building
(and on an updated pmg-docs for linking to the correct section)

pmg-api:
Stoiko Ivanov (3):
  backup: pbs: prevent race in concurrent backups
  backup: fix #3146 add email notifications
  backup: add notify parameter to 'classic' backup

 src/Makefile                         |  1 +
 src/PMG/API2/Backup.pm               | 23 +++++++++++--
 src/PMG/API2/PBS/Job.pm              | 50 +++++++++++++++++++++-------
 src/PMG/Backup.pm                    | 35 +++++++++++++++++++
 src/PMG/PBSConfig.pm                 |  7 ++++
 src/templates/backup-notification.tt | 19 +++++++++++
 6 files changed, 120 insertions(+), 15 deletions(-)
 create mode 100644 src/templates/backup-notification.tt

pmg-gui:
Stoiko Ivanov (4):
  backup: pbs: add onlineHelp anchors
  backup: fix #3154: make statistic backup optional
  backup: pbs: fix #3154: add statistic setting to remote
  backup: pbs: fix #3146  add notify setting to remote

 js/BackupRestore.js   | 45 ++++++++++++++++++++++++++++---------------
 js/PBSConfig.js       |  1 +
 js/PBSRemoteEdit.js   | 20 +++++++++++++++++++
 js/PBSSnapshotView.js | 19 +++---------------
 4 files changed, 53 insertions(+), 32 deletions(-)

pmg-docs:
Stoiko Ivanov (1):
  backup: shortly document #3146 and #3154

 pmgbackup.adoc | 4 ++++
 1 file changed, 4 insertions(+)

-- 
2.20.1





^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pmg-devel] [PATCH pmg-api v2 1/3] backup: pbs: prevent race in concurrent backups
  2021-03-01 14:12 [pmg-devel] [PATCH pmg-api/gui/docs v2] small improvments for PBS integration Stoiko Ivanov
@ 2021-03-01 14:12 ` Stoiko Ivanov
  2021-03-05 21:42   ` [pmg-devel] applied: " Thomas Lamprecht
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-api v2 2/3] backup: fix #3146 add email notifications Stoiko Ivanov
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Stoiko Ivanov @ 2021-03-01 14:12 UTC (permalink / raw)
  To: pmg-devel

If two pbs backup-creation calls happen simultaneously, it is possible
that the first removes the backup dir before the other is done
creating or sending it to the pbs remote.

This patch takes the same route as non-PBS backups - creating a unique
tempdir indexed by remote, PID and current time.

the tmp-dir now also needs to be removed in case of error while
backing up. (before the next invocation would have wiped it).

Noticed while having 2 schedules to different PBS instances with the
same interval and w/o random delay.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 src/PMG/API2/PBS/Job.pm | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/PMG/API2/PBS/Job.pm b/src/PMG/API2/PBS/Job.pm
index 2387422..c095d25 100644
--- a/src/PMG/API2/PBS/Job.pm
+++ b/src/PMG/API2/PBS/Job.pm
@@ -294,20 +294,28 @@ __PACKAGE__->register_method ({
 	$param->{statistic} //= $remote_config->{'include-statistics'} // 1;
 
 	my $pbs = PVE::PBSClient->new($remote_config, $remote, $conf->{secret_dir});
-	my $backup_dir = "/var/lib/pmg/backup/current";
+
+	my $time = time;
+	my $backup_dir = "/tmp/pbsbackup_${remote}_$$.$time";
 
 	my $worker = sub {
 	    my $upid = shift;
 
 	    print "starting update of current backup state\n";
 
-	    -d $backup_dir || mkdir $backup_dir;
-	    PMG::Backup::pmg_backup($backup_dir, $param->{statistic});
+	    eval {
+		-d $backup_dir || mkdir $backup_dir;
+		PMG::Backup::pmg_backup($backup_dir, $param->{statistic});
 
-	    $pbs->backup_fs_tree($backup_dir, $node, 'pmgbackup');
+		$pbs->backup_fs_tree($backup_dir, $node, 'pmgbackup');
 
-	    rmtree $backup_dir;
+		rmtree $backup_dir;
+	    };
+	    if (my $err = $@) {
+		rmtree $backup_dir;
+		die "backup failed: $err\n";
 
+	    }
 	    print "backup finished\n";
 
 	    my $group = "host/$node";
-- 
2.20.1





^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pmg-devel] [PATCH pmg-api v2 2/3] backup: fix #3146 add email notifications
  2021-03-01 14:12 [pmg-devel] [PATCH pmg-api/gui/docs v2] small improvments for PBS integration Stoiko Ivanov
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-api v2 1/3] backup: pbs: prevent race in concurrent backups Stoiko Ivanov
@ 2021-03-01 14:12 ` Stoiko Ivanov
  2021-03-05 21:43   ` [pmg-devel] applied: " Thomas Lamprecht
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-api v2 3/3] backup: add notify parameter to 'classic' backup Stoiko Ivanov
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Stoiko Ivanov @ 2021-03-01 14:12 UTC (permalink / raw)
  To: pmg-devel

this patch addresses the missing email notification for scheduled
backup related tasks, which we have in all our other products, for our
mail product.

the parameter names are inspired by PBS' datastore config.

the default is 'never' in order to stay consistent with the current
code.

it uses the templateing system for the notification, because this
results in less code and a bit of added flexibility for the users.

the recipient address is currently hardcoded to the admin address in
pmg.conf as we also send the (admin) pmgreport there, and I did not
want to overengineer this (even more).

I shortly considered adding a $SIG{'__DIE__'} handler to the
run_backup API call but dropped the idea due to the warning in
perlvar(1).

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 src/Makefile                         |  1 +
 src/PMG/API2/PBS/Job.pm              | 34 ++++++++++++++++++++-------
 src/PMG/Backup.pm                    | 35 ++++++++++++++++++++++++++++
 src/PMG/PBSConfig.pm                 |  7 ++++++
 src/templates/backup-notification.tt | 19 +++++++++++++++
 5 files changed, 88 insertions(+), 8 deletions(-)
 create mode 100644 src/templates/backup-notification.tt

diff --git a/src/Makefile b/src/Makefile
index 67e6878..8891a3c 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -43,6 +43,7 @@ TEMPLATES =				\
 	clamd.conf.in 			\
 	postgresql.conf.in		\
 	pg_hba.conf.in			\
+	backup-notification.tt		\
 
 TEMPLATES_FILES = $(addprefix templates/, ${TEMPLATES})
 
diff --git a/src/PMG/API2/PBS/Job.pm b/src/PMG/API2/PBS/Job.pm
index c095d25..fb2d914 100644
--- a/src/PMG/API2/PBS/Job.pm
+++ b/src/PMG/API2/PBS/Job.pm
@@ -273,6 +273,13 @@ __PACKAGE__->register_method ({
 		optional => 1,
 		default => 1,
 	    },
+	    notify => {
+		description => "Specify when to notify via e-mail",
+		type => 'string',
+		enum => [ 'always', 'error', 'never' ],
+		optional => 1,
+		default => 'never',
+	    },
 	},
     },
     returns => { type => "string" },
@@ -292,6 +299,7 @@ __PACKAGE__->register_method ({
 	die "PBS remote '$remote' is disabled\n" if $remote_config->{disable};
 
 	$param->{statistic} //= $remote_config->{'include-statistics'} // 1;
+	my $notify = $param->{notify} // $remote_config->{notify} // 'never';
 
 	my $pbs = PVE::PBSClient->new($remote_config, $remote, $conf->{secret_dir});
 
@@ -301,7 +309,10 @@ __PACKAGE__->register_method ({
 	my $worker = sub {
 	    my $upid = shift;
 
-	    print "starting update of current backup state\n";
+	    my $full_log = "";
+	    my $log = sub { print "$_[0]\n"; $full_log .= "$_[0]\n"; };
+
+	    $log->("starting update of current backup state\n");
 
 	    eval {
 		-d $backup_dir || mkdir $backup_dir;
@@ -312,25 +323,32 @@ __PACKAGE__->register_method ({
 		rmtree $backup_dir;
 	    };
 	    if (my $err = $@) {
+		$log->($err);
+		PMG::Backup::send_backup_notification($notify, $remote, $full_log, $err);
 		rmtree $backup_dir;
 		die "backup failed: $err\n";
-
 	    }
-	    print "backup finished\n";
+	    $log->("backup finished\n");
 
 	    my $group = "host/$node";
 	    if (defined(my $prune_opts = $conf->prune_options($remote))) {
-		print "starting prune of $group\n";
-		my $res = $pbs->prune_group(undef, $prune_opts, $group);
-
+		$log->("starting prune of $group\n");
+		my $res = eval { $pbs->prune_group(undef, $prune_opts, $group) };
+		if (my $err = $@) {
+		    $log->($err);
+		    PMG::Backup::send_backup_notification($notify, $remote, $full_log, $err);
+		    die "pruning failed: $err\n";
+		}
 		foreach my $pruned (@$res){
 		    my $time = strftime("%FT%TZ", gmtime($pruned->{'backup-time'}));
 		    my $snap = $pruned->{'backup-type'} . '/' . $pruned->{'backup-id'} . '/' .  $time;
-		    print "pruned snapshot: $snap\n";
+		    $log->("pruned snapshot: $snap\n");
 		}
-		print "prune finished\n";
+		$log->("prune finished\n");
 	    }
 
+	    PMG::Backup::send_backup_notification($notify, $remote, $full_log, undef);
+
 	    return;
 	};
 
diff --git a/src/PMG/Backup.pm b/src/PMG/Backup.pm
index 303bbb4..2f96412 100644
--- a/src/PMG/Backup.pm
+++ b/src/PMG/Backup.pm
@@ -5,6 +5,7 @@ use warnings;
 use Data::Dumper;
 use File::Basename;
 use File::Path;
+use POSIX qw(strftime);
 
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::Tools;
@@ -376,4 +377,38 @@ sub pmg_restore {
     die $err if $err;
 }
 
+sub send_backup_notification {
+    my ($notify_on, $target, $log, $err) = @_;
+
+    return if !$notify_on;
+    return if $notify_on eq 'never';
+    return if $notify_on eq 'error' && !$err;
+
+    my $cfg = PMG::Config->new();
+    my $email = $cfg->get ('admin', 'email');
+    if (!$email) {
+	warn "not sending notifcation: no admin email configured\n";
+	return;
+    }
+
+    my $nodename = PVE::INotify::nodename();
+    my $fqdn = PVE::Tools::get_fqdn($nodename);
+
+
+    my $vars = {
+	hostname => $nodename,
+	fqdn => $fqdn,
+	date => strftime("%F", localtime()),
+	target => $target,
+	log => $log,
+	err => $err,
+    };
+
+    my $tt = PMG::Config::get_template_toolkit();
+
+    my $mailfrom = "Proxmox Mail Gateway <postmaster>";
+    PMG::Utils::finalize_report($tt, 'backup-notification.tt', $vars, $mailfrom, $email);
+
+}
+
 1;
diff --git a/src/PMG/PBSConfig.pm b/src/PMG/PBSConfig.pm
index 29cff22..965d162 100644
--- a/src/PMG/PBSConfig.pm
+++ b/src/PMG/PBSConfig.pm
@@ -90,6 +90,12 @@ sub properties {
 	    description => "Username or API token ID on the Proxmox Backup Server"
 	}),
 	fingerprint => get_standard_option('fingerprint-sha256'),
+	notify => {
+	    description => "Specify when to notify via e-mail",
+	    type => 'string',
+	    enum => [ 'always', 'error', 'never' ],
+	    optional => 1,
+	},
 	'include-statistics' => {
 	    description => "Include statistics in scheduled backups",
 	    type => 'boolean',
@@ -107,6 +113,7 @@ sub options {
 	username => { optional => 1 },
 	password => { optional => 1 },
 	fingerprint => { optional => 1 },
+	notify => { optional => 1 },
 	'include-statistics' => { optional => 1 },
 	'keep-last' => { optional => 1 },
 	'keep-hourly' =>  { optional => 1 },
diff --git a/src/templates/backup-notification.tt b/src/templates/backup-notification.tt
new file mode 100644
index 0000000..3f956b0
--- /dev/null
+++ b/src/templates/backup-notification.tt
@@ -0,0 +1,19 @@
+[%- IF err -%]
+[%- SET titleprefix = "Backup failed" -%]
+[%- ELSE %]
+[%- SET titleprefix = "Backup successful" -%]
+[%- END -%]
+[%- IF target -%]
+[%- SET titlesuffix = "to ${target} - ($fqdn)" -%]
+[%- ELSE %]
+[%- SET titlesuffix = "($fqdn)" -%]
+[%- END -%]
+<html>
+  <head>
+    <title>[% titleprefix %] [% titlesuffix %]</title>
+  </head>
+  <body>
+    Detailed backup logs:<br /><br />
+    <pre>[% log %]</pre>
+  </body>
+</html>
-- 
2.20.1





^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pmg-devel] [PATCH pmg-api v2 3/3] backup: add notify parameter to 'classic' backup
  2021-03-01 14:12 [pmg-devel] [PATCH pmg-api/gui/docs v2] small improvments for PBS integration Stoiko Ivanov
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-api v2 1/3] backup: pbs: prevent race in concurrent backups Stoiko Ivanov
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-api v2 2/3] backup: fix #3146 add email notifications Stoiko Ivanov
@ 2021-03-01 14:12 ` Stoiko Ivanov
  2021-03-05 21:43   ` [pmg-devel] applied: " Thomas Lamprecht
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-gui v2 1/4] backup: pbs: add onlineHelp anchors Stoiko Ivanov
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Stoiko Ivanov @ 2021-03-01 14:12 UTC (permalink / raw)
  To: pmg-devel

for feature-parity, and since we recently had a user in our community
forum, who does regular backups via cron+rsync (small site w/o
dedicated backup host). Those setups could also benefit from this.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 src/PMG/API2/Backup.pm | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/PMG/API2/Backup.pm b/src/PMG/API2/Backup.pm
index 4ea28d1..2248fa5 100644
--- a/src/PMG/API2/Backup.pm
+++ b/src/PMG/API2/Backup.pm
@@ -110,6 +110,13 @@ __PACKAGE__->register_method ({
 		optional => 1,
 		default => 1,
 	    },
+	    notify => {
+		description => "Specify when to notify via e-mail",
+		type => 'string',
+		enum => [ 'always', 'error', 'never' ],
+		optional => 1,
+		default => 'never',
+	    },
 	},
     },
     returns => { type => "string" },
@@ -129,11 +136,21 @@ __PACKAGE__->register_method ({
 	my $worker = sub {
 	    my $upid = shift;
 
-	    print "starting backup to: $filename\n";
+	    my $full_log = "";
+	    my $log = sub { print "$_[0]\n"; $full_log .= "$_[0]\n"; };
+
+	    $log->("starting backup to: $filename\n");
+
+	    eval { PMG::Backup::pmg_backup_pack($filename, $param->{statistic}) };
+	    if (my $err = $@) {
+		$log->($err);
+		PMG::Backup::send_backup_notification($param->{notify}, undef, $full_log, $err);
+		die "backup failed: $err\n";
+	    }
 
-	    PMG::Backup::pmg_backup_pack($filename, $param->{statistic});
+	    $log->("backup finished\n");
 
-	    print "backup finished\n";
+	    PMG::Backup::send_backup_notification($param->{notify}, undef, $full_log, undef);
 
 	    return;
 	};
-- 
2.20.1





^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pmg-devel] [PATCH pmg-gui v2 1/4] backup: pbs: add onlineHelp anchors
  2021-03-01 14:12 [pmg-devel] [PATCH pmg-api/gui/docs v2] small improvments for PBS integration Stoiko Ivanov
                   ` (2 preceding siblings ...)
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-api v2 3/3] backup: add notify parameter to 'classic' backup Stoiko Ivanov
@ 2021-03-01 14:12 ` Stoiko Ivanov
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-gui v2 2/4] backup: fix #3154: make statistic backup optional Stoiko Ivanov
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Stoiko Ivanov @ 2021-03-01 14:12 UTC (permalink / raw)
  To: pmg-devel

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 js/PBSConfig.js     | 1 +
 js/PBSRemoteEdit.js | 1 +
 2 files changed, 2 insertions(+)

diff --git a/js/PBSConfig.js b/js/PBSConfig.js
index 2a32d83..5e88574 100644
--- a/js/PBSConfig.js
+++ b/js/PBSConfig.js
@@ -1,6 +1,7 @@
 Ext.define('PMG.PBSScheduleEdit', {
     extend: 'Proxmox.window.Edit',
     xtype: 'pmgPBSScheduleEdit',
+    onlineHelp: 'pmgbackup_pbs_schedule',
 
     isAdd: true,
     isCreate: true,
diff --git a/js/PBSRemoteEdit.js b/js/PBSRemoteEdit.js
index e478dbd..0cb06d3 100644
--- a/js/PBSRemoteEdit.js
+++ b/js/PBSRemoteEdit.js
@@ -160,6 +160,7 @@ Ext.define('PMG.PBSInputPanel', {
 Ext.define('PMG.PBSEdit', {
     extend: 'Proxmox.window.Edit',
     xtype: 'pmgPBSEdit',
+    onlineHelp: 'pmgbackup_pbs_remotes',
 
     subject: 'Proxmox Backup Server',
     isAdd: true,
-- 
2.20.1





^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pmg-devel] [PATCH pmg-gui v2 2/4] backup: fix #3154: make statistic backup optional
  2021-03-01 14:12 [pmg-devel] [PATCH pmg-api/gui/docs v2] small improvments for PBS integration Stoiko Ivanov
                   ` (3 preceding siblings ...)
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-gui v2 1/4] backup: pbs: add onlineHelp anchors Stoiko Ivanov
@ 2021-03-01 14:12 ` Stoiko Ivanov
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-gui v2 3/4] backup: pbs: fix #3154: add statistic setting to remote Stoiko Ivanov
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Stoiko Ivanov @ 2021-03-01 14:12 UTC (permalink / raw)
  To: pmg-devel

by creating an edit-window when clicking on the respective Backup now
button.

This is the second part of the enhancement request

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 js/BackupRestore.js   | 45 ++++++++++++++++++++++++++++---------------
 js/PBSSnapshotView.js | 19 +++---------------
 2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/js/BackupRestore.js b/js/BackupRestore.js
index 3cfabd8..21a979f 100644
--- a/js/BackupRestore.js
+++ b/js/BackupRestore.js
@@ -69,6 +69,32 @@ Ext.define('PMG.RestoreWindow', {
     },
 });
 
+Ext.define('PMG.BackupWindow', {
+    extend: 'Proxmox.window.Edit',
+    xtype: 'pmgBackupWindow',
+    onlineHelp: 'chapter_pmgbackup',
+
+    showProgress: true,
+    title: gettext('Backup'),
+    isCreate: true,
+    method: 'POST',
+    submitText: gettext('Backup'),
+    fieldDefaults: {
+	labelWidth: 150,
+    },
+    showTaskViewer: true,
+    items: [
+	{
+	    xtype: 'proxmoxcheckbox',
+	    name: 'statistic',
+	    value: 1,
+	    uncheckedValue: 0,
+	    fieldLabel: gettext('Include Statistics'),
+	},
+    ],
+
+});
+
 Ext.define('PMG.BackupRestore', {
     extend: 'Ext.grid.GridPanel',
     xtype: 'pmgBackupRestore',
@@ -80,23 +106,10 @@ Ext.define('PMG.BackupRestore', {
 
 	createBackup: function() {
 	    let view = this.getView();
-	    Proxmox.Utils.API2Request({
+	    Ext.create('PMG.BackupWindow', {
 		url: "/nodes/" + Proxmox.NodeName + "/backup",
-		method: 'POST',
-		waitMsgTarget: view,
-		failure: function(response, opts) {
-		    Ext.Msg.alert(gettext('Error'), response.htmlStatus);
-		},
-		success: function(response, opts) {
-		    let upid = response.result.data;
-
-		    let win = Ext.create('Proxmox.window.TaskViewer', {
-			upid: upid,
-			autoShow: true,
-		    });
-		    view.mon(win, 'close', () => view.store.load());
-		},
-	    });
+		taskDone: () => view.store.load(),
+	    }).show();
 	},
 
 	onRestore: function() {
diff --git a/js/PBSSnapshotView.js b/js/PBSSnapshotView.js
index 841bff8..c182bfb 100644
--- a/js/PBSSnapshotView.js
+++ b/js/PBSSnapshotView.js
@@ -25,23 +25,10 @@ Ext.define('PMG.PBSConfig', {
 	    let me = this;
 	    let view = me.lookup('snapshotsGrid');
 	    let remote = me.getViewModel().get('remote');
-	    Proxmox.Utils.API2Request({
+	    Ext.create('PMG.BackupWindow', {
 		url: `/nodes/${Proxmox.NodeName}/pbs/${remote}/snapshot`,
-		method: 'POST',
-		waitMsgTarget: view,
-		failure: function(response, opts) {
-		    Ext.Msg.alert(gettext('Error'), response.htmlStatus);
-		},
-		success: function(response, opts) {
-		    let upid = response.result.data;
-
-		    let win = Ext.create('Proxmox.window.TaskViewer', {
-			upid: upid,
-		    });
-		    win.show();
-		    me.mon(win, 'close', function() { view.getStore().load(); });
-		},
-	    });
+		taskDone: () => view.getStore().load(),
+	    }).show();
 	},
 
 	reload: function(grid) {
-- 
2.20.1





^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pmg-devel] [PATCH pmg-gui v2 3/4] backup: pbs: fix #3154: add statistic setting to remote
  2021-03-01 14:12 [pmg-devel] [PATCH pmg-api/gui/docs v2] small improvments for PBS integration Stoiko Ivanov
                   ` (4 preceding siblings ...)
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-gui v2 2/4] backup: fix #3154: make statistic backup optional Stoiko Ivanov
@ 2021-03-01 14:12 ` Stoiko Ivanov
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-gui v2 4/4] backup: pbs: fix #3146 add notify " Stoiko Ivanov
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Stoiko Ivanov @ 2021-03-01 14:12 UTC (permalink / raw)
  To: pmg-devel

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 js/PBSRemoteEdit.js | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/js/PBSRemoteEdit.js b/js/PBSRemoteEdit.js
index 0cb06d3..4fbe075 100644
--- a/js/PBSRemoteEdit.js
+++ b/js/PBSRemoteEdit.js
@@ -86,6 +86,13 @@ Ext.define('PMG.PBSInputPanel', {
 		    uncheckedValue: 0,
 		    fieldLabel: gettext('Enable'),
 		},
+		{
+		    xtype: 'proxmoxcheckbox',
+		    name: 'include-statistics',
+		    checked: true,
+		    uncheckedValue: 0,
+		    fieldLabel: gettext('Include Statistics'),
+		},
 	    ],
 	    columnB: [
 		{
-- 
2.20.1





^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pmg-devel] [PATCH pmg-gui v2 4/4] backup: pbs: fix #3146 add notify setting to remote
  2021-03-01 14:12 [pmg-devel] [PATCH pmg-api/gui/docs v2] small improvments for PBS integration Stoiko Ivanov
                   ` (5 preceding siblings ...)
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-gui v2 3/4] backup: pbs: fix #3154: add statistic setting to remote Stoiko Ivanov
@ 2021-03-01 14:12 ` Stoiko Ivanov
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-docs v2 1/1] backup: shortly document #3146 and #3154 Stoiko Ivanov
  2021-03-05 22:07 ` [pmg-devel] applied: [PATCH pmg-api/gui/docs v2] small improvments for PBS integration Thomas Lamprecht
  8 siblings, 0 replies; 14+ messages in thread
From: Stoiko Ivanov @ 2021-03-01 14:12 UTC (permalink / raw)
  To: pmg-devel

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 js/PBSRemoteEdit.js | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/js/PBSRemoteEdit.js b/js/PBSRemoteEdit.js
index 4fbe075..976b341 100644
--- a/js/PBSRemoteEdit.js
+++ b/js/PBSRemoteEdit.js
@@ -54,6 +54,18 @@ Ext.define('PMG.PBSInputPanel', {
 		    fieldLabel: 'Datastore',
 		    allowBlank: false,
 		},
+		{
+		    xtype: 'proxmoxKVComboBox',
+		    name: 'notify',
+		    fieldLabel: gettext('Notify'),
+		    comboItems: [
+			['always', 'always'],
+			['error', 'error'],
+			['never', 'never'],
+		    ],
+		    deleteEmpty: false,
+		    emptyText: gettext('never'),
+		},
 	    ],
 	    column2: [
 		{
-- 
2.20.1





^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pmg-devel] [PATCH pmg-docs v2 1/1] backup: shortly document #3146 and #3154
  2021-03-01 14:12 [pmg-devel] [PATCH pmg-api/gui/docs v2] small improvments for PBS integration Stoiko Ivanov
                   ` (6 preceding siblings ...)
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-gui v2 4/4] backup: pbs: fix #3146 add notify " Stoiko Ivanov
@ 2021-03-01 14:12 ` Stoiko Ivanov
  2021-03-05 21:45   ` [pmg-devel] applied: " Thomas Lamprecht
  2021-03-05 22:07 ` [pmg-devel] applied: [PATCH pmg-api/gui/docs v2] small improvments for PBS integration Thomas Lamprecht
  8 siblings, 1 reply; 14+ messages in thread
From: Stoiko Ivanov @ 2021-03-01 14:12 UTC (permalink / raw)
  To: pmg-devel

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 pmgbackup.adoc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/pmgbackup.adoc b/pmgbackup.adoc
index 2a230a8..be492ca 100644
--- a/pmgbackup.adoc
+++ b/pmgbackup.adoc
@@ -143,6 +143,10 @@ Server over a period of time.
 If prune settings are configured, the backup-group of {pmg} is pruned
 automatically after each successful backup.
 
+The `notify` and `include-statistics` setting of a remote define the defaults
+for notifications and whether to include the statistic database in backups.
+They are also used for xref:pmgbackup_pbs_schedule[scheduled backups].
+
 The public settings are stored in `/etc/pmg/pbs/pbs.conf`, sensitive settings,
 like passwords are stored in individual files named after the remote inside
 `/etc/pmg/pbs/`:
-- 
2.20.1





^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pmg-devel] applied: [PATCH pmg-api v2 1/3] backup: pbs: prevent race in concurrent backups
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-api v2 1/3] backup: pbs: prevent race in concurrent backups Stoiko Ivanov
@ 2021-03-05 21:42   ` Thomas Lamprecht
  0 siblings, 0 replies; 14+ messages in thread
From: Thomas Lamprecht @ 2021-03-05 21:42 UTC (permalink / raw)
  To: Stoiko Ivanov, pmg-devel

On 01.03.21 15:12, Stoiko Ivanov wrote:
> If two pbs backup-creation calls happen simultaneously, it is possible
> that the first removes the backup dir before the other is done
> creating or sending it to the pbs remote.
> 
> This patch takes the same route as non-PBS backups - creating a unique
> tempdir indexed by remote, PID and current time.
> 
> the tmp-dir now also needs to be removed in case of error while
> backing up. (before the next invocation would have wiped it).
> 
> Noticed while having 2 schedules to different PBS instances with the
> same interval and w/o random delay.
> 
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
>  src/PMG/API2/PBS/Job.pm | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pmg-devel] applied: [PATCH pmg-api v2 2/3] backup: fix #3146 add email notifications
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-api v2 2/3] backup: fix #3146 add email notifications Stoiko Ivanov
@ 2021-03-05 21:43   ` Thomas Lamprecht
  0 siblings, 0 replies; 14+ messages in thread
From: Thomas Lamprecht @ 2021-03-05 21:43 UTC (permalink / raw)
  To: Stoiko Ivanov, pmg-devel

On 01.03.21 15:12, Stoiko Ivanov wrote:
> this patch addresses the missing email notification for scheduled
> backup related tasks, which we have in all our other products, for our
> mail product.
> 
> the parameter names are inspired by PBS' datastore config.
> 
> the default is 'never' in order to stay consistent with the current
> code.
> 
> it uses the templateing system for the notification, because this
> results in less code and a bit of added flexibility for the users.
> 
> the recipient address is currently hardcoded to the admin address in
> pmg.conf as we also send the (admin) pmgreport there, and I did not
> want to overengineer this (even more).
> 
> I shortly considered adding a $SIG{'__DIE__'} handler to the
> run_backup API call but dropped the idea due to the warning in
> perlvar(1).
> 
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
>  src/Makefile                         |  1 +
>  src/PMG/API2/PBS/Job.pm              | 34 ++++++++++++++++++++-------
>  src/PMG/Backup.pm                    | 35 ++++++++++++++++++++++++++++
>  src/PMG/PBSConfig.pm                 |  7 ++++++
>  src/templates/backup-notification.tt | 19 +++++++++++++++
>  5 files changed, 88 insertions(+), 8 deletions(-)
>  create mode 100644 src/templates/backup-notification.tt
> 
>

applied, squashed in a fixup dropping the extra \n in $log->() calls we talked about off-list.
thanks!




^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pmg-devel] applied: [PATCH pmg-api v2 3/3] backup: add notify parameter to 'classic' backup
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-api v2 3/3] backup: add notify parameter to 'classic' backup Stoiko Ivanov
@ 2021-03-05 21:43   ` Thomas Lamprecht
  0 siblings, 0 replies; 14+ messages in thread
From: Thomas Lamprecht @ 2021-03-05 21:43 UTC (permalink / raw)
  To: Stoiko Ivanov, pmg-devel

On 01.03.21 15:12, Stoiko Ivanov wrote:
> for feature-parity, and since we recently had a user in our community
> forum, who does regular backups via cron+rsync (small site w/o
> dedicated backup host). Those setups could also benefit from this.
> 
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
>  src/PMG/API2/Backup.pm | 23 ++++++++++++++++++++---
>  1 file changed, 20 insertions(+), 3 deletions(-)
> 
>

applied, squashed in a fixup dropping the extra \n in $log->() calls we talked about off-list.
thanks!




^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pmg-devel] applied: [PATCH pmg-docs v2 1/1] backup: shortly document #3146 and #3154
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-docs v2 1/1] backup: shortly document #3146 and #3154 Stoiko Ivanov
@ 2021-03-05 21:45   ` Thomas Lamprecht
  0 siblings, 0 replies; 14+ messages in thread
From: Thomas Lamprecht @ 2021-03-05 21:45 UTC (permalink / raw)
  To: Stoiko Ivanov, pmg-devel

On 01.03.21 15:12, Stoiko Ivanov wrote:
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
>  pmgbackup.adoc | 4 ++++
>  1 file changed, 4 insertions(+)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pmg-devel] applied: [PATCH pmg-api/gui/docs v2] small improvments for PBS integration
  2021-03-01 14:12 [pmg-devel] [PATCH pmg-api/gui/docs v2] small improvments for PBS integration Stoiko Ivanov
                   ` (7 preceding siblings ...)
  2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-docs v2 1/1] backup: shortly document #3146 and #3154 Stoiko Ivanov
@ 2021-03-05 22:07 ` Thomas Lamprecht
  8 siblings, 0 replies; 14+ messages in thread
From: Thomas Lamprecht @ 2021-03-05 22:07 UTC (permalink / raw)
  To: Stoiko Ivanov, pmg-devel

On 01.03.21 15:12, Stoiko Ivanov wrote:
> v2->v1:
> * addressed Thomas great feedback!:
> ** reordered the patches (the prevention of the race for concurrent
>    pbs-backup is not before the notification feature)
> ** concurrent pbs-backups now simply use a backup-tmpdir indexed by
>    remote+pid+time instead of locking.
> ** printing and exiting on error now happen as before (instead of being delayed)
> ** default is 'never' (instead of the unclear mix of 'error' in the schema
>    and 'never' in the code
> ** not having an admin-email configured is treated as warning.
> 
> original cover-letter for v1:
> This patchset addresses #3146 and #3154.
> Additionally I added patches for small cosmetic cleanups, and a fix
> for concurrent pbs-backups (they raced with each other during my tests)
> 
> patch 1/4 for pmg-gui depends on an updated pmg-docs-generator for building
> (and on an updated pmg-docs for linking to the correct section)
> 
> pmg-api:
> Stoiko Ivanov (3):
>   backup: pbs: prevent race in concurrent backups
>   backup: fix #3146 add email notifications
>   backup: add notify parameter to 'classic' backup
> 
>  src/Makefile                         |  1 +
>  src/PMG/API2/Backup.pm               | 23 +++++++++++--
>  src/PMG/API2/PBS/Job.pm              | 50 +++++++++++++++++++++-------
>  src/PMG/Backup.pm                    | 35 +++++++++++++++++++
>  src/PMG/PBSConfig.pm                 |  7 ++++
>  src/templates/backup-notification.tt | 19 +++++++++++
>  6 files changed, 120 insertions(+), 15 deletions(-)
>  create mode 100644 src/templates/backup-notification.tt
> 
> pmg-gui:
> Stoiko Ivanov (4):
>   backup: pbs: add onlineHelp anchors
>   backup: fix #3154: make statistic backup optional
>   backup: pbs: fix #3154: add statistic setting to remote
>   backup: pbs: fix #3146  add notify setting to remote
> 
>  js/BackupRestore.js   | 45 ++++++++++++++++++++++++++++---------------
>  js/PBSConfig.js       |  1 +
>  js/PBSRemoteEdit.js   | 20 +++++++++++++++++++
>  js/PBSSnapshotView.js | 19 +++---------------
>  4 files changed, 53 insertions(+), 32 deletions(-)
> 
> pmg-docs:
> Stoiko Ivanov (1):
>   backup: shortly document #3146 and #3154
> 
>  pmgbackup.adoc | 4 ++++
>  1 file changed, 4 insertions(+)
> 



applied now also the remaining patches, thanks!




^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-03-05 22:08 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01 14:12 [pmg-devel] [PATCH pmg-api/gui/docs v2] small improvments for PBS integration Stoiko Ivanov
2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-api v2 1/3] backup: pbs: prevent race in concurrent backups Stoiko Ivanov
2021-03-05 21:42   ` [pmg-devel] applied: " Thomas Lamprecht
2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-api v2 2/3] backup: fix #3146 add email notifications Stoiko Ivanov
2021-03-05 21:43   ` [pmg-devel] applied: " Thomas Lamprecht
2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-api v2 3/3] backup: add notify parameter to 'classic' backup Stoiko Ivanov
2021-03-05 21:43   ` [pmg-devel] applied: " Thomas Lamprecht
2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-gui v2 1/4] backup: pbs: add onlineHelp anchors Stoiko Ivanov
2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-gui v2 2/4] backup: fix #3154: make statistic backup optional Stoiko Ivanov
2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-gui v2 3/4] backup: pbs: fix #3154: add statistic setting to remote Stoiko Ivanov
2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-gui v2 4/4] backup: pbs: fix #3146 add notify " Stoiko Ivanov
2021-03-01 14:12 ` [pmg-devel] [PATCH pmg-docs v2 1/1] backup: shortly document #3146 and #3154 Stoiko Ivanov
2021-03-05 21:45   ` [pmg-devel] applied: " Thomas Lamprecht
2021-03-05 22:07 ` [pmg-devel] applied: [PATCH pmg-api/gui/docs v2] small improvments for PBS integration Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal