public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] api2/tape/backup: list backed up snapshots on failed backup notification
Date: Fri, 23 Apr 2021 14:57:18 +0200	[thread overview]
Message-ID: <20210423125718.574-1-d.csapak@proxmox.com> (raw)

if a backup task failed (e.g. it was aborted), show the snapshots
which were successfully backed up in the notification

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/api2/tape/backup.rs           | 25 ++++++++++++-------------
 src/server/email_notifications.rs |  6 ++++++
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/src/api2/tape/backup.rs b/src/api2/tape/backup.rs
index bce0fbcc..4dc35945 100644
--- a/src/api2/tape/backup.rs
+++ b/src/api2/tape/backup.rs
@@ -197,7 +197,8 @@ pub fn do_tape_backup_job(
             job.start(&worker.upid().to_string())?;
             let mut drive_lock = drive_lock;
 
-            let (job_result, summary) = match try_block!({
+            let mut summary = Default::default();
+            let job_result = try_block!({
                 if schedule.is_some() {
                     // for scheduled tape backup jobs, we wait indefinitely for the lock
                     task_log!(worker, "waiting for drive lock...");
@@ -217,17 +218,16 @@ pub fn do_tape_backup_job(
                     task_log!(worker,"task triggered by schedule '{}'", event_str);
                 }
 
+
                 backup_worker(
                     &worker,
                     datastore,
                     &pool_config,
                     &setup,
                     email.clone(),
+                    &mut summary,
                 )
-            }) {
-                Ok(summary) => (Ok(()), summary),
-                Err(err) => (Err(err), Default::default()),
-            };
+            });
 
             let status = worker.create_state(&job_result);
 
@@ -365,16 +365,15 @@ pub fn backup(
             let _drive_lock = drive_lock; // keep lock guard
             set_tape_device_state(&setup.drive, &worker.upid().to_string())?;
 
-            let (job_result, summary) = match backup_worker(
+            let mut summary = Default::default();
+            let job_result = backup_worker(
                 &worker,
                 datastore,
                 &pool_config,
                 &setup,
                 email.clone(),
-            ) {
-                Ok(summary) => (Ok(()), summary),
-                Err(err) => (Err(err), Default::default()),
-            };
+                &mut summary,
+            );
 
             if let Some(email) = email {
                 if let Err(err) = crate::server::send_tape_backup_status(
@@ -403,11 +402,11 @@ fn backup_worker(
     pool_config: &MediaPoolConfig,
     setup: &TapeBackupJobSetup,
     email: Option<String>,
-) -> Result<TapeBackupJobSummary, Error> {
+    summary: &mut TapeBackupJobSummary,
+) -> Result<(), Error> {
 
     let status_path = Path::new(TAPE_STATUS_DIR);
     let start = std::time::Instant::now();
-    let mut summary: TapeBackupJobSummary = Default::default();
 
     task_log!(worker, "update media online status");
     let changer_name = update_media_online_status(&setup.drive)?;
@@ -531,7 +530,7 @@ fn backup_worker(
 
     summary.duration = start.elapsed();
 
-    Ok(summary)
+    Ok(())
 }
 
 // Try to update the the media online status
diff --git a/src/server/email_notifications.rs b/src/server/email_notifications.rs
index 4e07ed13..8c72250e 100644
--- a/src/server/email_notifications.rs
+++ b/src/server/email_notifications.rs
@@ -176,7 +176,13 @@ Datastore:  {{job.store}}
 Tape Pool:  {{job.pool}}
 Tape Drive: {{job.drive}}
 
+{{#if snapshot-list ~}}
+Snapshots included:
 
+{{#each snapshot-list~}}
+{{this}}
+{{/each~}}
+{{/if}}
 Tape Backup failed: {{error}}
 
 
-- 
2.20.1





                 reply	other threads:[~2021-04-23 12:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210423125718.574-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal