public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* Re: [PATCH pve-manager v4 5/7] fix #6464: vzdump: add retry strategies for failed guest backups
  2026-11-20 16:05 19% ` [PATCH pve-manager v4 5/7] fix #6464: vzdump: add retry strategies for failed guest backups Jakob Klocker
@ 2026-11-21 21:42  9%   ` Thomas Lamprecht
  0 siblings, 0 replies; 15+ results
From: Thomas Lamprecht @ 2026-11-21 21:42 UTC (permalink / raw)
  To: Jakob Klocker, pve-devel

Am 20.11.26 um 17:07 schrieb Jakob Klocker:
> Add the `error-behavior` and `max-retries` options to automatically
> retry failed guest backups, which helps with transient failures.
> 
> Supported retry strategies:
> - `ignore`: Preserves current behavior (no retries, default).
> - `retry-immediately`: Retries the guest inline after failure.
> - `retry`: Defers failed guests until all other guests have been
>   processed, then retries them in the order they failed.
> 
> A guest is retried at most `max-retries` times. Between attempts, the
> delay starts at 30 seconds and doubles with each retry, capped at 30
> minutes as suggested on bugzilla [0]. If a guest still fails after the
> last retry, it is counted as an error and the job finishes with errors.
> If a retry succeeds, the task finishes with a warning and the
> notification is sent with severity `warning`. Its subject shows how
> many guests needed retries, and the guest table shows how many retries
> each of them needed.
> 
> Guests whose archive was already created (e.g. failing backup-end hook)
> are not retried, to avoid duplicate archives and repeated pruning.
> 
> Retries are not possible with --stdout, as a retry would corrupt the
> stream. Setting `error-behavior` to a retry strategy together with
> --stdout is rejected, and a retry strategy from /etc/vzdump.conf is
> ignored with a warning.
> 
> The task log is kept across retries and contains all attempts.
> 
> [0]: https://bugzilla.proxmox.com/show_bug.cgi?id=6464#c5
> Link: https://bugzilla.proxmox.com/show_bug.cgi?id=6464
> 
> Signed-off-by: Jakob Klocker <j.klocker@proxmox.com>
> ---
>  PVE/VZDump.pm | 219 +++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 215 insertions(+), 4 deletions(-)
> 
> diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
> index d2861f9e..d0f98a13 100644
> --- a/PVE/VZDump.pm
> +++ b/PVE/VZDump.pm
> @@ -10,6 +10,7 @@ use File::Path;
>  use IO::File;
>  use IO::Select;
>  use IPC::Open3;
> +use List::Util qw(min);
>  use POSIX qw(strftime);
>  use Time::Local;
>  
> @@ -20,6 +21,7 @@ use PVE::HA::Config;
>  use PVE::HA::Env::PVE2;
>  use PVE::JSONSchema qw(get_standard_option);
>  use PVE::Notify;
> +use PVE::RESTEnvironment qw(log_warn);

debugmsg already calls this when passing 'warn' as level and also has
some other special handling for how vzdump is used, in any case
this should not be required here.

>  use PVE::RPCEnvironment;
>  use PVE::Storage;
>  use PVE::VZDump::Common;
> @@ -395,6 +397,11 @@ my sub read_backup_task_logs {
>      return $task_logs;
>  }
>  
> +my sub retries_text {
> +    my ($count) = @_;
> +    return $count == 1 ? '1 retry' : "$count retries";
> +}

I don't want to add such a helper for every plural text there might be...

Iff, then check if we can use pre-existing ones or do at least a generic
one, like:

sub plural($count, $singular, $plural) {
    return $count == 1 ? $singular : $plural;
}

Else this is gonna end in bloat.

> +
>  my sub build_guest_table {
>      my ($task_list) = @_;
>  
> @@ -436,11 +443,18 @@ my sub build_guest_table {
>          my $successful = $task->{state} eq 'ok';
>          my $size = $successful ? $task->{size} : 0;
>          my $filename = $successful ? $task->{target} : undef;
> +
> +        my $status = $task->{state};
> +        my $retries = $task->{retries};

could be

my ($status, $retries) = $task->{'state', 'retries'};

also $task->{'state'} is used a bit above already at my $successful.

but tbh. not a big fan of such "useless" (i.e. 1:1 reference) intermediate
variables for straight forward single-level hash element access. They just
add complexity as one needs to check where they are set while not winning much.

> +        if ($successful && $retries) {
> +            $status .= " (after " . retries_text($retries) . ")";
> +        }
> +
>          push @{ $table->{data} },
>              {
>                  "vmid" => int($task->{vmid}),
>                  "name" => $task->{hostname},
> -                "status" => $task->{state},
> +                "status" => $status,
>                  "time" => int($task->{backuptime}),
>                  "size" => int($size),
>                  "filename" => $filename,
> @@ -502,8 +516,11 @@ sub send_notification {
>      my ($error_count, $total_size) = aggregate_task_statistics($tasklist);
>  
>      my $failed = ($error_count || $err);
> +    my $retried_count = grep { $_->{state} eq 'ok' && $_->{retries} } @$tasklist;
>  
>      my $status_text = $failed ? 'backup failed' : 'backup successful';
> +    $status_text .= " ($retried_count guest(s) needed retries)"
> +        if !$failed && $retried_count;

here now plural difference? would do this consistently if we do.

>  
>      if ($err) {
>          if ($err =~ /\n/) {
> @@ -540,7 +557,7 @@ sub send_notification {
>      # Add backup-job metadata field in case this is a backup job.
>      $fields->{'job-id'} = $job_id if $job_id;
>  
> -    my $severity = $failed ? "error" : "info";
> +    my $severity = $failed ? "error" : $retried_count ? "warning" : "info";
>      my $email_configured = $mailto && scalar(@$mailto);
>  
>      if (($mode eq 'auto' && $email_configured) || $mode eq 'legacy-sendmail') {
> @@ -1048,7 +1065,9 @@ sub exec_backup_task {
>          -d $task->{tmpdir}
>              || die "unable to create temporary directory '$task->{tmpdir}'";
>  
> -        $logfd = IO::File->new(">$tmplog")
> +        # keep the log of earlier attempts of this job
> +        my $logmode = defined($task->{tmplog}) ? '>>' : '>';

meh, not a fan. rather would keep this one log per job and add a retry suffix
there. Say "-r$task->{retries}.log" (or whatever file ending this uses).

Else these get very long and hard to browse, harder than they are now.

> +        $logfd = IO::File->new("${logmode}${tmplog}")
>              || die "unable to create log file '$tmplog'";
>  
>          $task->{dumpdir} = $opts->{dumpdir};
> @@ -1216,6 +1235,9 @@ sub exec_backup_task {
>              debugmsg('info', "archive file size: $cs", $logfd);
>          }
>  
> +        # The backup exists from here on, later failures must not trigger a retry
> +        $task->{committed} = 1;
> +
>          # Mark as protected before pruning.
>          if (my $storeid = $opts->{storage}) {
>              my $volname =
> @@ -1445,14 +1467,193 @@ sub exec_backup {
>  
>      my $starttime = time();
>      my $errcount = 0;
> +    my $retried_count = 0;
> +
> +    my $error_behavior = $opts->{'error-behavior'} // 'ignore';
> +    if ($opts->{stdout} && $error_behavior ne 'ignore') {
> +        log_warn(
> +            "ignoring 'error-behavior' from vzdump.conf - retries are not possible with 'stdout'");
> +        $error_behavior = 'ignore';
> +    }
> +
> +    my $max_retries = $opts->{'max-retries'} // 5;
> +    my $min_between_retry = 30;
> +    my $max_wait = 60 * 30;
> +
> +    my $get_backoff = sub {
> +        my ($retry) = @_;
> +        return min($min_between_retry * 2**($retry - 1), $max_wait);

fwiw this still calculates 2^X even if we're clearly out of the window then for one with
a very high max-retries count:

Ad this whole code hunk here bloats exec_backup quite a bit up, and it's not exactly
small to begin width.. would be nice to either move some stuff out or avoid it in the
first place if simple or - a bigger rework is out of scope here.

> +    };
> +
> +    my $log_committed_failure = sub {
> +        my ($vmid) = @_;
> +        debugmsg(
> +            'err',
> +            "Backup of guest $vmid was created, but a later step failed - not retrying",
> +            undef,
> +            1,
> +        );
> +    };
> +
> +    my $log_retried_success = sub {
> +        my ($vmid, $retries) = @_;
> +        log_warn("Backup of guest $vmid succeeded after " . retries_text($retries));
> +        $retried_count++;
> +    };
> +
>      eval {
>  
>          $self->{'backup-provider'}->job_init($starttime) if $self->{'backup-provider'};
>          $self->run_hook_script('job-start', undef, $job_start_fd);
>  
> +        my $failed_tasks = {};
> +
>          foreach my $task (@$tasklist) {
> +            my $vmid = $task->{vmid};
> +            my $initial_task = {%$task};
> +
> +            $task->{retries} = 0;
>              $self->exec_backup_task($task);
> -            $errcount += 1 if $task->{state} ne 'ok';
> +
> +            next if $task->{state} eq 'ok';
> +
> +            if ($error_behavior ne 'ignore' && $task->{committed}) {
> +                $log_committed_failure->($vmid);
> +                $errcount++;
> +                next;
> +            }
> +
> +            if ($error_behavior eq 'retry-immediately') {
> +                for my $retry (1 .. $max_retries) {
> +                    my $backoff = $get_backoff->($retry);
> +
> +                    debugmsg(
> +                        'info',
> +                        "Retrying backup for guest $vmid (retry $retry/$max_retries)"
> +                            . " after ${backoff}s delay...",
> +                        undef,
> +                        1,
> +                    );
> +                    sleep($backoff);

this can be interrupted before we $backoff duration has gone by.
Normally one does something like (untested and not saying its perfectly
right for this usecase here as proposed):

my $current = time();
my $target = $current + $backoff;
while (sleep($target - $current)) {
    die "failed to wait for timeout - $!\n" if $! && !$!{EINTR};
    $current = time();
    last if $current >= $target;
}

bit overkill naturally, one can also just not care for simpler cases
(also not saying this is such one, seems borderline) but then comment
that.


> +
> +                    %$task = (%$initial_task, retries => $retry, tmplog => $task->{tmplog});
> +                    $self->exec_backup_task($task);
> +
> +                    if ($task->{state} eq 'ok') {
> +                        $log_retried_success->($vmid, $retry);
> +                        last;
> +                    }
> +                    last if $task->{committed};
> +                }
> +
> +            } elsif ($error_behavior eq 'retry') {
> +                $failed_tasks->{$vmid} = {
> +                    task => $task,
> +                    initial_task => $initial_task,
> +                    fail_time => time(),
> +                    retries => 0,
> +                };
> +                next;
> +            }
> +
> +            if ($task->{state} ne 'ok') {
> +                if ($error_behavior eq 'retry-immediately') {
> +                    if ($task->{committed}) {
> +                        $log_committed_failure->($vmid);
> +                    } else {
> +                        debugmsg(
> +                            'err',
> +                            "Guest $vmid failed after " . retries_text($max_retries),
> +                            undef,
> +                            1,
> +                        );
> +                    }
> +                }
> +                $errcount++;
> +            }
> +        }
> +
> +        if ($error_behavior eq 'retry') {

hmm, I think we probably do need to rework whit all a bit to prepare it for doing the
retires without having to bloat this up to zeppelin size class (to exaggerate).

With a modularizing this first retrying should come much more natural.

> +            while (%$failed_tasks) {
> +                my $now = time();
> +                my $min_sleep = $max_wait;
> +                my $ready_to_run = [];
> +
> +                my @sorted_vmids = sort {
> +                    $failed_tasks->{$a}->{fail_time} <=> $failed_tasks->{$b}->{fail_time}
> +                        || $a <=> $b
> +                } keys %$failed_tasks;
> +
> +                for my $vmid (@sorted_vmids) {
> +                    my $fail_info = $failed_tasks->{$vmid};
> +
> +                    if ($fail_info->{retries} >= $max_retries) {
> +                        debugmsg(
> +                            'err',
> +                            "Guest $vmid failed after " . retries_text($max_retries),
> +                            undef,
> +                            1,
> +                        );
> +                        $errcount++;
> +                        delete $failed_tasks->{$vmid};
> +                        next;
> +                    }
> +
> +                    my $delay = $get_backoff->($fail_info->{retries} + 1);
> +                    my $target_time = $fail_info->{fail_time} + $delay;
> +                    my $wait_time = $target_time - $now;
> +
> +                    if ($wait_time > 0) {
> +                        $min_sleep = $wait_time if $wait_time < $min_sleep;
> +                    } else {
> +                        push @$ready_to_run, $vmid;
> +                    }
> +                }
> +
> +                if (scalar(@$ready_to_run) == 0 && %$failed_tasks) {
> +                    debugmsg(
> +                        'info',
> +                        "Waiting $min_sleep seconds before next backup retry...",
> +                        undef,
> +                        1,
> +                    );
> +                    sleep($min_sleep);
> +                    next;
> +                }
> +
> +                for my $vmid (@$ready_to_run) {
> +                    my $fail_info = $failed_tasks->{$vmid};
> +
> +                    $fail_info->{retries}++;
> +                    debugmsg(
> +                        'info',
> +                        "Retrying backup for guest $vmid"
> +                            . " (retry $fail_info->{retries}/$max_retries)",
> +                        undef,
> +                        1,
> +                    );
> +
> +                    my $task = $fail_info->{task};
> +                    my $tmplog = $task->{tmplog};
> +                    %$task = (
> +                        %{ $fail_info->{initial_task} },
> +                        retries => $fail_info->{retries},
> +                        tmplog => $tmplog,
> +                    );
> +                    $self->exec_backup_task($task);
> +
> +                    if ($task->{state} eq 'ok') {
> +                        $log_retried_success->($vmid, $fail_info->{retries});
> +                        delete $failed_tasks->{$vmid};
> +                    } elsif ($task->{committed}) {
> +                        $log_committed_failure->($vmid);
> +                        $errcount++;
> +                        delete $failed_tasks->{$vmid};
> +                    } else {
> +                        $fail_info->{fail_time} = time();
> +                    }
> +                }
> +            }
>          }
>  
>          $self->{'backup-provider'}->job_cleanup() if $self->{'backup-provider'};
> @@ -1472,6 +1673,13 @@ sub exec_backup {
>      } else {
>          if ($errcount) {
>              debugmsg('info', "Backup job finished with errors", undef, 1);
> +        } elsif ($retried_count) {
> +            debugmsg(
> +                'info',
> +                "Backup job finished with warnings - $retried_count guest(s) needed retries",
> +                undef,
> +                1,
> +            );
>          } else {
>              debugmsg('info', "Backup job finished successfully", undef, 1);
>          }
> @@ -1547,6 +1755,9 @@ sub verify_vzdump_parameters {
>      raise_param_exc({ pool => "option conflicts with option 'vmid'" })
>          if $param->{pool} && $param->{vmid};
>  
> +    raise_param_exc({ 'error-behavior' => "retries are not possible with option 'stdout'" })
> +        if $param->{stdout} && ($param->{'error-behavior'} // 'ignore') ne 'ignore';
> +
>      $parse_prune_backups->($param, 'CLI parameters');
>      parse_fleecing($param);
>      parse_performance($param);





^ permalink raw reply	[relevance 9%]

* superseded: [PATCH docs/guest-common/manager v3 0/4] fix #6464: backup: add backup retry strategies
  2026-11-16 10:13 17% [PATCH docs/guest-common/manager v3 " Jakob Klocker
  2026-11-16 10:13 19% ` [PATCH pve-manager v3 2/4] fix #6464: vzdump: add retry strategies for failed guest backups Jakob Klocker
@ 2026-11-20 16:09  7% ` Jakob Klocker
  1 sibling, 0 replies; 15+ results
From: Jakob Klocker @ 2026-11-20 16:09 UTC (permalink / raw)
  To: Jakob Klocker, pve-devel

Superseded-by: https://lore.proxmox.com/all/20261120160510.311796-1-j.klocker@proxmox.com/T/#u




^ permalink raw reply	[relevance 7%]

* [PATCH pve-manager v4 5/7] fix #6464: vzdump: add retry strategies for failed guest backups
  2026-11-20 16:05 16% [PATCH docs/guest-common/manager/storage/storage-plugin-examples v4 0/7] " Jakob Klocker
@ 2026-11-20 16:05 19% ` Jakob Klocker
  2026-11-21 21:42  9%   ` Thomas Lamprecht
  0 siblings, 1 reply; 15+ results
From: Jakob Klocker @ 2026-11-20 16:05 UTC (permalink / raw)
  To: pve-devel

Add the `error-behavior` and `max-retries` options to automatically
retry failed guest backups, which helps with transient failures.

Supported retry strategies:
- `ignore`: Preserves current behavior (no retries, default).
- `retry-immediately`: Retries the guest inline after failure.
- `retry`: Defers failed guests until all other guests have been
  processed, then retries them in the order they failed.

A guest is retried at most `max-retries` times. Between attempts, the
delay starts at 30 seconds and doubles with each retry, capped at 30
minutes as suggested on bugzilla [0]. If a guest still fails after the
last retry, it is counted as an error and the job finishes with errors.
If a retry succeeds, the task finishes with a warning and the
notification is sent with severity `warning`. Its subject shows how
many guests needed retries, and the guest table shows how many retries
each of them needed.

Guests whose archive was already created (e.g. failing backup-end hook)
are not retried, to avoid duplicate archives and repeated pruning.

Retries are not possible with --stdout, as a retry would corrupt the
stream. Setting `error-behavior` to a retry strategy together with
--stdout is rejected, and a retry strategy from /etc/vzdump.conf is
ignored with a warning.

The task log is kept across retries and contains all attempts.

[0]: https://bugzilla.proxmox.com/show_bug.cgi?id=6464#c5
Link: https://bugzilla.proxmox.com/show_bug.cgi?id=6464

Signed-off-by: Jakob Klocker <j.klocker@proxmox.com>
---
 PVE/VZDump.pm | 219 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 215 insertions(+), 4 deletions(-)

diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index d2861f9e..d0f98a13 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -10,6 +10,7 @@ use File::Path;
 use IO::File;
 use IO::Select;
 use IPC::Open3;
+use List::Util qw(min);
 use POSIX qw(strftime);
 use Time::Local;
 
@@ -20,6 +21,7 @@ use PVE::HA::Config;
 use PVE::HA::Env::PVE2;
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::Notify;
+use PVE::RESTEnvironment qw(log_warn);
 use PVE::RPCEnvironment;
 use PVE::Storage;
 use PVE::VZDump::Common;
@@ -395,6 +397,11 @@ my sub read_backup_task_logs {
     return $task_logs;
 }
 
+my sub retries_text {
+    my ($count) = @_;
+    return $count == 1 ? '1 retry' : "$count retries";
+}
+
 my sub build_guest_table {
     my ($task_list) = @_;
 
@@ -436,11 +443,18 @@ my sub build_guest_table {
         my $successful = $task->{state} eq 'ok';
         my $size = $successful ? $task->{size} : 0;
         my $filename = $successful ? $task->{target} : undef;
+
+        my $status = $task->{state};
+        my $retries = $task->{retries};
+        if ($successful && $retries) {
+            $status .= " (after " . retries_text($retries) . ")";
+        }
+
         push @{ $table->{data} },
             {
                 "vmid" => int($task->{vmid}),
                 "name" => $task->{hostname},
-                "status" => $task->{state},
+                "status" => $status,
                 "time" => int($task->{backuptime}),
                 "size" => int($size),
                 "filename" => $filename,
@@ -502,8 +516,11 @@ sub send_notification {
     my ($error_count, $total_size) = aggregate_task_statistics($tasklist);
 
     my $failed = ($error_count || $err);
+    my $retried_count = grep { $_->{state} eq 'ok' && $_->{retries} } @$tasklist;
 
     my $status_text = $failed ? 'backup failed' : 'backup successful';
+    $status_text .= " ($retried_count guest(s) needed retries)"
+        if !$failed && $retried_count;
 
     if ($err) {
         if ($err =~ /\n/) {
@@ -540,7 +557,7 @@ sub send_notification {
     # Add backup-job metadata field in case this is a backup job.
     $fields->{'job-id'} = $job_id if $job_id;
 
-    my $severity = $failed ? "error" : "info";
+    my $severity = $failed ? "error" : $retried_count ? "warning" : "info";
     my $email_configured = $mailto && scalar(@$mailto);
 
     if (($mode eq 'auto' && $email_configured) || $mode eq 'legacy-sendmail') {
@@ -1048,7 +1065,9 @@ sub exec_backup_task {
         -d $task->{tmpdir}
             || die "unable to create temporary directory '$task->{tmpdir}'";
 
-        $logfd = IO::File->new(">$tmplog")
+        # keep the log of earlier attempts of this job
+        my $logmode = defined($task->{tmplog}) ? '>>' : '>';
+        $logfd = IO::File->new("${logmode}${tmplog}")
             || die "unable to create log file '$tmplog'";
 
         $task->{dumpdir} = $opts->{dumpdir};
@@ -1216,6 +1235,9 @@ sub exec_backup_task {
             debugmsg('info', "archive file size: $cs", $logfd);
         }
 
+        # The backup exists from here on, later failures must not trigger a retry
+        $task->{committed} = 1;
+
         # Mark as protected before pruning.
         if (my $storeid = $opts->{storage}) {
             my $volname =
@@ -1445,14 +1467,193 @@ sub exec_backup {
 
     my $starttime = time();
     my $errcount = 0;
+    my $retried_count = 0;
+
+    my $error_behavior = $opts->{'error-behavior'} // 'ignore';
+    if ($opts->{stdout} && $error_behavior ne 'ignore') {
+        log_warn(
+            "ignoring 'error-behavior' from vzdump.conf - retries are not possible with 'stdout'");
+        $error_behavior = 'ignore';
+    }
+
+    my $max_retries = $opts->{'max-retries'} // 5;
+    my $min_between_retry = 30;
+    my $max_wait = 60 * 30;
+
+    my $get_backoff = sub {
+        my ($retry) = @_;
+        return min($min_between_retry * 2**($retry - 1), $max_wait);
+    };
+
+    my $log_committed_failure = sub {
+        my ($vmid) = @_;
+        debugmsg(
+            'err',
+            "Backup of guest $vmid was created, but a later step failed - not retrying",
+            undef,
+            1,
+        );
+    };
+
+    my $log_retried_success = sub {
+        my ($vmid, $retries) = @_;
+        log_warn("Backup of guest $vmid succeeded after " . retries_text($retries));
+        $retried_count++;
+    };
+
     eval {
 
         $self->{'backup-provider'}->job_init($starttime) if $self->{'backup-provider'};
         $self->run_hook_script('job-start', undef, $job_start_fd);
 
+        my $failed_tasks = {};
+
         foreach my $task (@$tasklist) {
+            my $vmid = $task->{vmid};
+            my $initial_task = {%$task};
+
+            $task->{retries} = 0;
             $self->exec_backup_task($task);
-            $errcount += 1 if $task->{state} ne 'ok';
+
+            next if $task->{state} eq 'ok';
+
+            if ($error_behavior ne 'ignore' && $task->{committed}) {
+                $log_committed_failure->($vmid);
+                $errcount++;
+                next;
+            }
+
+            if ($error_behavior eq 'retry-immediately') {
+                for my $retry (1 .. $max_retries) {
+                    my $backoff = $get_backoff->($retry);
+
+                    debugmsg(
+                        'info',
+                        "Retrying backup for guest $vmid (retry $retry/$max_retries)"
+                            . " after ${backoff}s delay...",
+                        undef,
+                        1,
+                    );
+                    sleep($backoff);
+
+                    %$task = (%$initial_task, retries => $retry, tmplog => $task->{tmplog});
+                    $self->exec_backup_task($task);
+
+                    if ($task->{state} eq 'ok') {
+                        $log_retried_success->($vmid, $retry);
+                        last;
+                    }
+                    last if $task->{committed};
+                }
+
+            } elsif ($error_behavior eq 'retry') {
+                $failed_tasks->{$vmid} = {
+                    task => $task,
+                    initial_task => $initial_task,
+                    fail_time => time(),
+                    retries => 0,
+                };
+                next;
+            }
+
+            if ($task->{state} ne 'ok') {
+                if ($error_behavior eq 'retry-immediately') {
+                    if ($task->{committed}) {
+                        $log_committed_failure->($vmid);
+                    } else {
+                        debugmsg(
+                            'err',
+                            "Guest $vmid failed after " . retries_text($max_retries),
+                            undef,
+                            1,
+                        );
+                    }
+                }
+                $errcount++;
+            }
+        }
+
+        if ($error_behavior eq 'retry') {
+            while (%$failed_tasks) {
+                my $now = time();
+                my $min_sleep = $max_wait;
+                my $ready_to_run = [];
+
+                my @sorted_vmids = sort {
+                    $failed_tasks->{$a}->{fail_time} <=> $failed_tasks->{$b}->{fail_time}
+                        || $a <=> $b
+                } keys %$failed_tasks;
+
+                for my $vmid (@sorted_vmids) {
+                    my $fail_info = $failed_tasks->{$vmid};
+
+                    if ($fail_info->{retries} >= $max_retries) {
+                        debugmsg(
+                            'err',
+                            "Guest $vmid failed after " . retries_text($max_retries),
+                            undef,
+                            1,
+                        );
+                        $errcount++;
+                        delete $failed_tasks->{$vmid};
+                        next;
+                    }
+
+                    my $delay = $get_backoff->($fail_info->{retries} + 1);
+                    my $target_time = $fail_info->{fail_time} + $delay;
+                    my $wait_time = $target_time - $now;
+
+                    if ($wait_time > 0) {
+                        $min_sleep = $wait_time if $wait_time < $min_sleep;
+                    } else {
+                        push @$ready_to_run, $vmid;
+                    }
+                }
+
+                if (scalar(@$ready_to_run) == 0 && %$failed_tasks) {
+                    debugmsg(
+                        'info',
+                        "Waiting $min_sleep seconds before next backup retry...",
+                        undef,
+                        1,
+                    );
+                    sleep($min_sleep);
+                    next;
+                }
+
+                for my $vmid (@$ready_to_run) {
+                    my $fail_info = $failed_tasks->{$vmid};
+
+                    $fail_info->{retries}++;
+                    debugmsg(
+                        'info',
+                        "Retrying backup for guest $vmid"
+                            . " (retry $fail_info->{retries}/$max_retries)",
+                        undef,
+                        1,
+                    );
+
+                    my $task = $fail_info->{task};
+                    my $tmplog = $task->{tmplog};
+                    %$task = (
+                        %{ $fail_info->{initial_task} },
+                        retries => $fail_info->{retries},
+                        tmplog => $tmplog,
+                    );
+                    $self->exec_backup_task($task);
+
+                    if ($task->{state} eq 'ok') {
+                        $log_retried_success->($vmid, $fail_info->{retries});
+                        delete $failed_tasks->{$vmid};
+                    } elsif ($task->{committed}) {
+                        $log_committed_failure->($vmid);
+                        $errcount++;
+                        delete $failed_tasks->{$vmid};
+                    } else {
+                        $fail_info->{fail_time} = time();
+                    }
+                }
+            }
         }
 
         $self->{'backup-provider'}->job_cleanup() if $self->{'backup-provider'};
@@ -1472,6 +1673,13 @@ sub exec_backup {
     } else {
         if ($errcount) {
             debugmsg('info', "Backup job finished with errors", undef, 1);
+        } elsif ($retried_count) {
+            debugmsg(
+                'info',
+                "Backup job finished with warnings - $retried_count guest(s) needed retries",
+                undef,
+                1,
+            );
         } else {
             debugmsg('info', "Backup job finished successfully", undef, 1);
         }
@@ -1547,6 +1755,9 @@ sub verify_vzdump_parameters {
     raise_param_exc({ pool => "option conflicts with option 'vmid'" })
         if $param->{pool} && $param->{vmid};
 
+    raise_param_exc({ 'error-behavior' => "retries are not possible with option 'stdout'" })
+        if $param->{stdout} && ($param->{'error-behavior'} // 'ignore') ne 'ignore';
+
     $parse_prune_backups->($param, 'CLI parameters');
     parse_fleecing($param);
     parse_performance($param);
-- 
2.47.3





^ permalink raw reply related	[relevance 19%]

* [PATCH docs/guest-common/manager/storage/storage-plugin-examples v4 0/7] fix #6464: backup: add backup retry strategies
@ 2026-11-20 16:05 16% Jakob Klocker
  2026-11-20 16:05 19% ` [PATCH pve-manager v4 5/7] fix #6464: vzdump: add retry strategies for failed guest backups Jakob Klocker
  0 siblings, 1 reply; 15+ results
From: Jakob Klocker @ 2026-11-20 16:05 UTC (permalink / raw)
  To: pve-devel

This series introduces automatic backup retries for guest backups in
vzdump to better handle transient failures.

As suggested by @Thomas [0], three strategies were added:
- `retry`: Defers failed guests until all other guests have been
  processed, then retries them in the order they failed up to a
  configurable maximum retry count.
- `retry-immediately`: Immediately retries failed guests up to a
  configurable maximum retry count.
- `ignore`: Retains the existing behavior by ignoring failures.

The number of retries is set with the new `max-retries` option (1-10,
default 5). Between attempts, a backoff delay is applied that starts at
30 seconds, doubles with each retry and is capped at 30 minutes. For
`retry`, the delay is measured from the last failure of that guest. The
interval and cap are intentionally not configurable for now.

If a guest succeeds on a retry, no error is counted, but the task
finishes with a warning and the notification is sent with severity
`warning`. If it still fails after the last retry, the job finishes
with errors as before. The task log of a guest contains all attempts
of the current job.

Since a guest can now go through backup_init() and backup_cleanup()
several times within one job, the backup provider API documentation
and the directory example provider are updated accordingly.

The mobile UI does not offer the retry options yet. Manual backups
started there use the node defaults from /etc/vzdump.conf. Adding the
fields there could be done as a follow-up.

Testing info:
To simulate a transient failure, lock a guest before starting the
backup and unlock it while the job waits for the retry:
`qm set <VMID> -lock backup`
`qm unlock <VMID>`

Tested: no retries with 'ignore', successful retry with 'retry' and
'retry-immediately' (including ordering and the warning status),
exhausted retries with backoff, no retry after a failing backup-end
hook, and the --stdout cases (explicit retry strategy rejected,
max-retries alone accepted, retry strategy from vzdump.conf ignored
with a warning).

Changes since v3:
- backup provider API: document that backup_init() and backup_cleanup()
  can be called more than once for the same guest within a job
- backup provider example: reset per-guest state in backup_init(), so
  a retry does not inherit the 'failed' flag or the backing image of
  the failed attempt (preceded by a perltidy-only commit)
- clarify in the commit message and docs that the notification subject
  shows the number of retried guests, and the guest table the retries
  per guest
- cover letter: note the missing retry options in the mobile UI

Changes since v2 (thanks @Jonas):
- don't retry guests whose backup was already created (e.g. failing
  backup-end hook)
- with --stdout, reject an explicitly set retry strategy and ignore
  one inherited from vzdump.conf with a warning
- don't append the task log to a stale log of a previous job
- finish the task with warnings and notify with severity 'warning'
  for retried guests
- show the number of retried guests in the notification subject and
  each guest's retry count in the guest table
- UI: only preselect `retry` for new jobs
- UI: don't store max-retries unless set, show schema defaults in
  description
- UI: use node defaults from vzdump.conf in the manual backup window
- docs: document non-retried failures, --stdout restriction, warnings
  and UI defaults

Changes since v1 (thanks @Shan):
- add documentation for the new retry options to pve-docs
- fix typo in pve-manager commit message
- drop the `advanced` flag from the retry fields in the manual backup
  window, which has no advanced section

[0] https://bugzilla.proxmox.com/show_bug.cgi?id=6464#c5
Link: https://bugzilla.proxmox.com/show_bug.cgi?id=6464


pve-storage-plugin-examples:

Jakob Klocker (2):
  backup provider example: run proxmox-perltidy
  backup provider example: reset per-guest state in backup_init

 .../BackupProvider/Plugin/DirectoryExample.pm | 633 +++++++++---------
 1 file changed, 328 insertions(+), 305 deletions(-)


pve-storage:

Jakob Klocker (1):
  backup provider api: document repeated backup_init() calls on retries

 src/PVE/BackupProvider/Plugin/Base.pm | 12 ++++++++++++
 1 file changed, 12 insertions(+)


pve-guest-common:

Jakob Klocker (1):
  vzdump: add error-behavior and max-retries options

 src/PVE/VZDump/Common.pm | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)


pve-manager:

Jakob Klocker (2):
  fix #6464: vzdump: add retry strategies for failed guest backups
  ui: backup: add error behavior and retry options

 PVE/VZDump.pm                               | 219 +++++++++++++++++++-
 www/manager6/dc/Backup.js                   |   2 +-
 www/manager6/panel/BackupAdvancedOptions.js |  52 +++++
 www/manager6/window/Backup.js               |  56 ++++-
 4 files changed, 323 insertions(+), 6 deletions(-)


pve-docs:

Jakob Klocker (1):
  vzdump: document backup retry options

 vzdump.adoc | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)


Summary over all repositories:
  8 files changed, 747 insertions(+), 311 deletions(-)

-- 
Generated by murpp 0.12.0




^ permalink raw reply	[relevance 16%]

* superseded: [PATCH docs/guest-common/manager v2 0/4] fix #6464: backup: add backup retry strategies
  2026-11-11  9:34 17% [PATCH docs/guest-common/manager v2 0/4] " Jakob Klocker
  2026-11-11  9:34 19% ` [PATCH pve-manager v2 2/4] fix #6464: vzdump: add retry strategies for failed guest backups Jakob Klocker
  2026-11-11 15:40 11% ` [PATCH docs/guest-common/manager v2 0/4] fix #6464: backup: add backup retry strategies Jonas Theisen
@ 2026-11-16 10:16  7% ` Jakob Klocker
  2 siblings, 0 replies; 15+ results
From: Jakob Klocker @ 2026-11-16 10:16 UTC (permalink / raw)
  To: Jakob Klocker, pve-devel

Superseded-by: https://lore.proxmox.com/all/20261116101344.140523-1-j.klocker@proxmox.com/T/#u




^ permalink raw reply	[relevance 7%]

* [PATCH pve-manager v3 2/4] fix #6464: vzdump: add retry strategies for failed guest backups
  2026-11-16 10:13 17% [PATCH docs/guest-common/manager v3 " Jakob Klocker
@ 2026-11-16 10:13 19% ` Jakob Klocker
  2026-11-20 16:09  7% ` superseded: [PATCH docs/guest-common/manager v3 0/4] fix #6464: backup: add backup retry strategies Jakob Klocker
  1 sibling, 0 replies; 15+ results
From: Jakob Klocker @ 2026-11-16 10:13 UTC (permalink / raw)
  To: pve-devel

Add the `error-behavior` and `max-retries` options to automatically
retry failed guest backups, which helps with transient failures.

Supported retry strategies:
- `ignore`: Preserves current behavior (no retries, default).
- `retry-immediately`: Retries the guest inline after failure.
- `retry`: Defers failed guests until all other guests have been
  processed, then retries them in the order they failed.

A guest is retried at most `max-retries` times. Between attempts, the
delay starts at 30 seconds and doubles with each retry, capped at 30
minutes as suggested on bugzilla [0]. If a guest still fails after the
last retry, it is counted as an error and the job finishes with errors.
If a retry succeeds, the task finishes with a warning and the
notification is sent with severity `warning`, showing the number of
retries in the subject and guest table.

Guests whose archive was already created (e.g. failing backup-end hook)
are not retried, to avoid duplicate archives and repeated pruning.

Retries are not possible with --stdout, as a retry would corrupt the
stream. Setting `error-behavior` to a retry strategy together with
--stdout is rejected, and a retry strategy from /etc/vzdump.conf is
ignored with a warning.

The task log is kept across retries and contains all attempts.

[0]: https://bugzilla.proxmox.com/show_bug.cgi?id=6464#c5
Link: https://bugzilla.proxmox.com/show_bug.cgi?id=6464

Signed-off-by: Jakob Klocker <j.klocker@proxmox.com>
---
 PVE/VZDump.pm | 219 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 215 insertions(+), 4 deletions(-)

diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index d2861f9e..d0f98a13 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -10,6 +10,7 @@ use File::Path;
 use IO::File;
 use IO::Select;
 use IPC::Open3;
+use List::Util qw(min);
 use POSIX qw(strftime);
 use Time::Local;
 
@@ -20,6 +21,7 @@ use PVE::HA::Config;
 use PVE::HA::Env::PVE2;
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::Notify;
+use PVE::RESTEnvironment qw(log_warn);
 use PVE::RPCEnvironment;
 use PVE::Storage;
 use PVE::VZDump::Common;
@@ -395,6 +397,11 @@ my sub read_backup_task_logs {
     return $task_logs;
 }
 
+my sub retries_text {
+    my ($count) = @_;
+    return $count == 1 ? '1 retry' : "$count retries";
+}
+
 my sub build_guest_table {
     my ($task_list) = @_;
 
@@ -436,11 +443,18 @@ my sub build_guest_table {
         my $successful = $task->{state} eq 'ok';
         my $size = $successful ? $task->{size} : 0;
         my $filename = $successful ? $task->{target} : undef;
+
+        my $status = $task->{state};
+        my $retries = $task->{retries};
+        if ($successful && $retries) {
+            $status .= " (after " . retries_text($retries) . ")";
+        }
+
         push @{ $table->{data} },
             {
                 "vmid" => int($task->{vmid}),
                 "name" => $task->{hostname},
-                "status" => $task->{state},
+                "status" => $status,
                 "time" => int($task->{backuptime}),
                 "size" => int($size),
                 "filename" => $filename,
@@ -502,8 +516,11 @@ sub send_notification {
     my ($error_count, $total_size) = aggregate_task_statistics($tasklist);
 
     my $failed = ($error_count || $err);
+    my $retried_count = grep { $_->{state} eq 'ok' && $_->{retries} } @$tasklist;
 
     my $status_text = $failed ? 'backup failed' : 'backup successful';
+    $status_text .= " ($retried_count guest(s) needed retries)"
+        if !$failed && $retried_count;
 
     if ($err) {
         if ($err =~ /\n/) {
@@ -540,7 +557,7 @@ sub send_notification {
     # Add backup-job metadata field in case this is a backup job.
     $fields->{'job-id'} = $job_id if $job_id;
 
-    my $severity = $failed ? "error" : "info";
+    my $severity = $failed ? "error" : $retried_count ? "warning" : "info";
     my $email_configured = $mailto && scalar(@$mailto);
 
     if (($mode eq 'auto' && $email_configured) || $mode eq 'legacy-sendmail') {
@@ -1048,7 +1065,9 @@ sub exec_backup_task {
         -d $task->{tmpdir}
             || die "unable to create temporary directory '$task->{tmpdir}'";
 
-        $logfd = IO::File->new(">$tmplog")
+        # keep the log of earlier attempts of this job
+        my $logmode = defined($task->{tmplog}) ? '>>' : '>';
+        $logfd = IO::File->new("${logmode}${tmplog}")
             || die "unable to create log file '$tmplog'";
 
         $task->{dumpdir} = $opts->{dumpdir};
@@ -1216,6 +1235,9 @@ sub exec_backup_task {
             debugmsg('info', "archive file size: $cs", $logfd);
         }
 
+        # The backup exists from here on, later failures must not trigger a retry
+        $task->{committed} = 1;
+
         # Mark as protected before pruning.
         if (my $storeid = $opts->{storage}) {
             my $volname =
@@ -1445,14 +1467,193 @@ sub exec_backup {
 
     my $starttime = time();
     my $errcount = 0;
+    my $retried_count = 0;
+
+    my $error_behavior = $opts->{'error-behavior'} // 'ignore';
+    if ($opts->{stdout} && $error_behavior ne 'ignore') {
+        log_warn(
+            "ignoring 'error-behavior' from vzdump.conf - retries are not possible with 'stdout'");
+        $error_behavior = 'ignore';
+    }
+
+    my $max_retries = $opts->{'max-retries'} // 5;
+    my $min_between_retry = 30;
+    my $max_wait = 60 * 30;
+
+    my $get_backoff = sub {
+        my ($retry) = @_;
+        return min($min_between_retry * 2**($retry - 1), $max_wait);
+    };
+
+    my $log_committed_failure = sub {
+        my ($vmid) = @_;
+        debugmsg(
+            'err',
+            "Backup of guest $vmid was created, but a later step failed - not retrying",
+            undef,
+            1,
+        );
+    };
+
+    my $log_retried_success = sub {
+        my ($vmid, $retries) = @_;
+        log_warn("Backup of guest $vmid succeeded after " . retries_text($retries));
+        $retried_count++;
+    };
+
     eval {
 
         $self->{'backup-provider'}->job_init($starttime) if $self->{'backup-provider'};
         $self->run_hook_script('job-start', undef, $job_start_fd);
 
+        my $failed_tasks = {};
+
         foreach my $task (@$tasklist) {
+            my $vmid = $task->{vmid};
+            my $initial_task = {%$task};
+
+            $task->{retries} = 0;
             $self->exec_backup_task($task);
-            $errcount += 1 if $task->{state} ne 'ok';
+
+            next if $task->{state} eq 'ok';
+
+            if ($error_behavior ne 'ignore' && $task->{committed}) {
+                $log_committed_failure->($vmid);
+                $errcount++;
+                next;
+            }
+
+            if ($error_behavior eq 'retry-immediately') {
+                for my $retry (1 .. $max_retries) {
+                    my $backoff = $get_backoff->($retry);
+
+                    debugmsg(
+                        'info',
+                        "Retrying backup for guest $vmid (retry $retry/$max_retries)"
+                            . " after ${backoff}s delay...",
+                        undef,
+                        1,
+                    );
+                    sleep($backoff);
+
+                    %$task = (%$initial_task, retries => $retry, tmplog => $task->{tmplog});
+                    $self->exec_backup_task($task);
+
+                    if ($task->{state} eq 'ok') {
+                        $log_retried_success->($vmid, $retry);
+                        last;
+                    }
+                    last if $task->{committed};
+                }
+
+            } elsif ($error_behavior eq 'retry') {
+                $failed_tasks->{$vmid} = {
+                    task => $task,
+                    initial_task => $initial_task,
+                    fail_time => time(),
+                    retries => 0,
+                };
+                next;
+            }
+
+            if ($task->{state} ne 'ok') {
+                if ($error_behavior eq 'retry-immediately') {
+                    if ($task->{committed}) {
+                        $log_committed_failure->($vmid);
+                    } else {
+                        debugmsg(
+                            'err',
+                            "Guest $vmid failed after " . retries_text($max_retries),
+                            undef,
+                            1,
+                        );
+                    }
+                }
+                $errcount++;
+            }
+        }
+
+        if ($error_behavior eq 'retry') {
+            while (%$failed_tasks) {
+                my $now = time();
+                my $min_sleep = $max_wait;
+                my $ready_to_run = [];
+
+                my @sorted_vmids = sort {
+                    $failed_tasks->{$a}->{fail_time} <=> $failed_tasks->{$b}->{fail_time}
+                        || $a <=> $b
+                } keys %$failed_tasks;
+
+                for my $vmid (@sorted_vmids) {
+                    my $fail_info = $failed_tasks->{$vmid};
+
+                    if ($fail_info->{retries} >= $max_retries) {
+                        debugmsg(
+                            'err',
+                            "Guest $vmid failed after " . retries_text($max_retries),
+                            undef,
+                            1,
+                        );
+                        $errcount++;
+                        delete $failed_tasks->{$vmid};
+                        next;
+                    }
+
+                    my $delay = $get_backoff->($fail_info->{retries} + 1);
+                    my $target_time = $fail_info->{fail_time} + $delay;
+                    my $wait_time = $target_time - $now;
+
+                    if ($wait_time > 0) {
+                        $min_sleep = $wait_time if $wait_time < $min_sleep;
+                    } else {
+                        push @$ready_to_run, $vmid;
+                    }
+                }
+
+                if (scalar(@$ready_to_run) == 0 && %$failed_tasks) {
+                    debugmsg(
+                        'info',
+                        "Waiting $min_sleep seconds before next backup retry...",
+                        undef,
+                        1,
+                    );
+                    sleep($min_sleep);
+                    next;
+                }
+
+                for my $vmid (@$ready_to_run) {
+                    my $fail_info = $failed_tasks->{$vmid};
+
+                    $fail_info->{retries}++;
+                    debugmsg(
+                        'info',
+                        "Retrying backup for guest $vmid"
+                            . " (retry $fail_info->{retries}/$max_retries)",
+                        undef,
+                        1,
+                    );
+
+                    my $task = $fail_info->{task};
+                    my $tmplog = $task->{tmplog};
+                    %$task = (
+                        %{ $fail_info->{initial_task} },
+                        retries => $fail_info->{retries},
+                        tmplog => $tmplog,
+                    );
+                    $self->exec_backup_task($task);
+
+                    if ($task->{state} eq 'ok') {
+                        $log_retried_success->($vmid, $fail_info->{retries});
+                        delete $failed_tasks->{$vmid};
+                    } elsif ($task->{committed}) {
+                        $log_committed_failure->($vmid);
+                        $errcount++;
+                        delete $failed_tasks->{$vmid};
+                    } else {
+                        $fail_info->{fail_time} = time();
+                    }
+                }
+            }
         }
 
         $self->{'backup-provider'}->job_cleanup() if $self->{'backup-provider'};
@@ -1472,6 +1673,13 @@ sub exec_backup {
     } else {
         if ($errcount) {
             debugmsg('info', "Backup job finished with errors", undef, 1);
+        } elsif ($retried_count) {
+            debugmsg(
+                'info',
+                "Backup job finished with warnings - $retried_count guest(s) needed retries",
+                undef,
+                1,
+            );
         } else {
             debugmsg('info', "Backup job finished successfully", undef, 1);
         }
@@ -1547,6 +1755,9 @@ sub verify_vzdump_parameters {
     raise_param_exc({ pool => "option conflicts with option 'vmid'" })
         if $param->{pool} && $param->{vmid};
 
+    raise_param_exc({ 'error-behavior' => "retries are not possible with option 'stdout'" })
+        if $param->{stdout} && ($param->{'error-behavior'} // 'ignore') ne 'ignore';
+
     $parse_prune_backups->($param, 'CLI parameters');
     parse_fleecing($param);
     parse_performance($param);
-- 
2.47.3





^ permalink raw reply related	[relevance 19%]

* [PATCH docs/guest-common/manager v3 0/4] fix #6464: backup: add backup retry strategies
@ 2026-11-16 10:13 17% Jakob Klocker
  2026-11-16 10:13 19% ` [PATCH pve-manager v3 2/4] fix #6464: vzdump: add retry strategies for failed guest backups Jakob Klocker
  2026-11-20 16:09  7% ` superseded: [PATCH docs/guest-common/manager v3 0/4] fix #6464: backup: add backup retry strategies Jakob Klocker
  0 siblings, 2 replies; 15+ results
From: Jakob Klocker @ 2026-11-16 10:13 UTC (permalink / raw)
  To: pve-devel

This series introduces automatic backup retries for guest backups in
vzdump to better handle transient failures.

As suggested by @Thomas [0], three strategies were added:
- `retry`: Defers failed guests until all other guests have been
  processed, then retries them in the order they failed up to a
  configurable maximum retry count.
- `retry-immediately`: Immediately retries failed guests up to a
  configurable maximum retry count.
- `ignore`: Retains the existing behavior by ignoring failures.

The number of retries is set with the new `max-retries` option (1-10,
default 5). Between attempts, a backoff delay is applied that starts at
30 seconds, doubles with each retry and is capped at 30 minutes. For
`retry`, the delay is measured from the last failure of that guest. The
interval and cap are intentionally not configurable for now.

If a guest succeeds on a retry, no error is counted, but the task
finishes with a warning and the notification is sent with severity
`warning`. If it still fails after the last retry, the job finishes
with errors as before. The task log of a guest contains all attempts
of the current job.

Testing info:
When testing I'd suggest to fail the backup by locking and
unlocking the guest with following commands:
`qm set <VMID> -lock backup`
`qm unlock <VMID>`

Changes since v2 (thanks @Jonas)
- don't retry guests whose backup was already created (e.g. failing
  backup-end hook)
- with --stdout, reject an explicitly set retry strategy and ignore
  one inherited from vzdump.conf with a warning
- don't append the task log to a stale log of a previous job
- finish the task with warnings and notify with severity 'warning'
  for retried guests
- show the number of retries in the notification subject and guest
  table
- UI: only preselect `retry` for new jobs
- UI: don't store max-retries unless set, show schema defaults in
  description
- UI: use node defaults from vzdump.conf in the manual backup window
- docs: document non-retried failures, --stdout restriction, warnings
  and UI defaults

Changes since v1 (thanks @Shan):
- add documentation for the new retry options to pve-docs
- fix typo in pve-manager commit message
- drop the `advanced` flag from the retry fields in the manual backup
  window, which has no advanced section

[0] https://bugzilla.proxmox.com/show_bug.cgi?id=6464#c5
Link: https://bugzilla.proxmox.com/show_bug.cgi?id=6464


pve-guest-common:

Jakob Klocker (1):
  vzdump: add error-behavior and max-retries options

 src/PVE/VZDump/Common.pm | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)


pve-manager:

Jakob Klocker (2):
  fix #6464: vzdump: add retry strategies for failed guest backups
  ui: backup: add error behavior and retry options

 PVE/VZDump.pm                               | 219 +++++++++++++++++++-
 www/manager6/dc/Backup.js                   |   2 +-
 www/manager6/panel/BackupAdvancedOptions.js |  52 +++++
 www/manager6/window/Backup.js               |  56 ++++-
 4 files changed, 323 insertions(+), 6 deletions(-)


pve-docs:

Jakob Klocker (1):
  vzdump: document backup retry options

 vzdump.adoc | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)


Summary over all repositories:
  6 files changed, 406 insertions(+), 6 deletions(-)

-- 
Generated by murpp 0.12.0




^ permalink raw reply	[relevance 17%]

* Re: [PATCH docs/guest-common/manager v2 0/4] fix #6464: backup: add backup retry strategies
  2026-11-11 15:40 11% ` [PATCH docs/guest-common/manager v2 0/4] fix #6464: backup: add backup retry strategies Jonas Theisen
@ 2026-11-12 10:11 10%   ` Jakob Klocker
  0 siblings, 0 replies; 15+ results
From: Jakob Klocker @ 2026-11-12 10:11 UTC (permalink / raw)
  To: Jonas Theisen, pve-devel

On Wed Nov 11, 2026 at 4:40 PM CET, Jonas Theisen wrote:
> On 11/11/26 10:35, Jakob Klocker wrote:
>> <snip>
>>
>> If a guest succeeds on a retry, it is reported as successful in the
>> notification and no error is counted. If it still fails after the last
>> retry, the job finishes with errors as before. Task logging has been
>> switched to append mode so the log contains the complete transcript of
>> all attempts.
>
> I personally would prefer if a transient failure would still be
> reported as a warning. Retries are good to not miss the backup
> completely but it still in most cases means something is wrong.

A warning is already logged in the task log, but I'll also include one 
in the notification and the task status, so it's more obvious that
something went wrong.

>> I kept the retry options in the advanced tab of the backup job window,
>> but I'm not sure whether they should be moved to the general tab.
>> Opinions on this are appreciated.
>
> A more general issue is the combination of retries with the --stdout
> parameter, where the tar gets written to a stdout instead of a file.
> The resulting stream gets corrupted by a retry so probably the CLI
> should just bail in that combination.

Thanks for that find, I'll make sure to fix this in the next version.

>>
>> Testing info:
>> When testing I'd suggest to fail the backup by locking and
>> unlocking the guest with following commands:
>> `qm set <VMID> -lock backup`
>> `qm unlock <VMID>`
>
> I also tested this in combination with an unreachable PBS by just
> yanking out the connection on the PBS side.
> This caused the backup task to fail even before the retries since
> it could not activate the storage.
> Since i assume this is one of the more common failure modes
> i think that should be covered by a retry.

As discussed off list, I'd keep the current behavior for this series.
The retry is intended for transient failures that happen while a
backup is running, where a single hiccup would otherwise fail a guest
that was already in progress. The documentation added by this series
also states that errors preventing the job from starting are not
retried.

Storage activation happens once per job, before any guest is backed
up, so retrying there would be a separate mechanism. With
both in place, the delays would stack, making the worstcase runtime
hard to predict. 


Appreciate the feedback!
>> <snip>





^ permalink raw reply	[relevance 10%]

* Re: [PATCH docs/guest-common/manager v2 0/4] fix #6464: backup: add backup retry strategies
  2026-11-11  9:34 17% [PATCH docs/guest-common/manager v2 0/4] " Jakob Klocker
  2026-11-11  9:34 19% ` [PATCH pve-manager v2 2/4] fix #6464: vzdump: add retry strategies for failed guest backups Jakob Klocker
@ 2026-11-11 15:40 11% ` Jonas Theisen
  2026-11-12 10:11 10%   ` Jakob Klocker
  2026-11-16 10:16  7% ` superseded: " Jakob Klocker
  2 siblings, 1 reply; 15+ results
From: Jonas Theisen @ 2026-11-11 15:40 UTC (permalink / raw)
  To: Jakob Klocker, pve-devel

On 11/11/26 10:35, Jakob Klocker wrote:
> <snip>
>
> If a guest succeeds on a retry, it is reported as successful in the
> notification and no error is counted. If it still fails after the last
> retry, the job finishes with errors as before. Task logging has been
> switched to append mode so the log contains the complete transcript of
> all attempts.

I personally would prefer if a transient failure would still be
reported as a warning. Retries are good to not miss the backup
completely but it still in most cases means something is wrong.
> I kept the retry options in the advanced tab of the backup job window,
> but I'm not sure whether they should be moved to the general tab.
> Opinions on this are appreciated.

A more general issue is the combination of retries with the --stdout
parameter, where the tar gets written to a stdout instead of a file.
The resulting stream gets corrupted by a retry so probably the CLI
should just bail in that combination.
>
> Testing info:
> When testing I'd suggest to fail the backup by locking and
> unlocking the guest with following commands:
> `qm set <VMID> -lock backup`
> `qm unlock <VMID>`

I also tested this in combination with an unreachable PBS by just
yanking out the connection on the PBS side.
This caused the backup task to fail even before the retries since
it could not activate the storage.
Since i assume this is one of the more common failure modes
i think that should be covered by a retry.
> <snip>





^ permalink raw reply	[relevance 11%]

* Re: [PATCH pve-manager v2 2/4] fix #6464: vzdump: add retry strategies for failed guest backups
  2026-11-11  9:34 19% ` [PATCH pve-manager v2 2/4] fix #6464: vzdump: add retry strategies for failed guest backups Jakob Klocker
@ 2026-11-11 15:40 10%   ` Jonas Theisen
  0 siblings, 0 replies; 15+ results
From: Jonas Theisen @ 2026-11-11 15:40 UTC (permalink / raw)
  To: Jakob Klocker, pve-devel

On 11/11/26 10:35, Jakob Klocker wrote:
> <snip>
>
> diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
> index 56d2aea3..e4aa303d 100644
> --- a/PVE/VZDump.pm
> +++ b/PVE/VZDump.pm
> @@ -10,6 +10,7 @@ use File::Path;
>   use IO::File;
>   use IO::Select;
>   use IPC::Open3;
> +use List::Util qw(min);
>   use POSIX qw(strftime);
>   use Time::Local;
>   
> @@ -1048,7 +1049,8 @@ sub exec_backup_task {
>           -d $task->{tmpdir}
>               || die "unable to create temporary directory '$task->{tmpdir}'";
>   
> -        $logfd = IO::File->new(">$tmplog")
> +        my $logmode = $task->{retries} ? '>>' : '>';
> +        $logfd = IO::File->new("${logmode}${tmplog}")

In case the first backup run fails before opening its backup log
the retry's log gets appended to an older previous log file.
Maybe cleanup the $tmplog once per job to avoid appending
to a remaining log file?
>               || die "unable to create log file '$tmplog'";
>   
>           $task->{dumpdir} = $opts->{dumpdir};
>
> <snip>





^ permalink raw reply	[relevance 10%]

* superseded: [PATCH guest-common/manager 0/3] fix #6464: backup: add backup retry strategies
  2026-11-02 11:58 17% [PATCH guest-common/manager 0/3] fix #6464: backup: add backup retry strategies Jakob Klocker
  2026-11-02 11:58 19% ` [PATCH pve-manager 2/3] fix #6464: vzdump: add retry strategies for failed guest backups Jakob Klocker
@ 2026-11-11  9:36  7% ` Jakob Klocker
  1 sibling, 0 replies; 15+ results
From: Jakob Klocker @ 2026-11-11  9:36 UTC (permalink / raw)
  To: Jakob Klocker, pve-devel

Superseded-by: https://lore.proxmox.com/all/20261111093407.109872-1-j.klocker@proxmox.com/T/#u




^ permalink raw reply	[relevance 7%]

* [PATCH pve-manager v2 2/4] fix #6464: vzdump: add retry strategies for failed guest backups
  2026-11-11  9:34 17% [PATCH docs/guest-common/manager v2 0/4] " Jakob Klocker
@ 2026-11-11  9:34 19% ` Jakob Klocker
  2026-11-11 15:40 10%   ` Jonas Theisen
  2026-11-11 15:40 11% ` [PATCH docs/guest-common/manager v2 0/4] fix #6464: backup: add backup retry strategies Jonas Theisen
  2026-11-16 10:16  7% ` superseded: " Jakob Klocker
  2 siblings, 1 reply; 15+ results
From: Jakob Klocker @ 2026-11-11  9:34 UTC (permalink / raw)
  To: pve-devel

Add the `error-behavior` and `max-retries` options to automatically
retry failed guest backups, which helps with transient failures.

Supported retry strategies:
- `ignore`: Preserves current behavior (no retries, default).
- `retry-immediately`: Retries the guest inline after
  failure.
- `retry`: Defers failed guests until all other guests have been
processed, then retries them in the order they failed.

A guest is retried at most `max-retries` times. Between attempts, the
delay starts at 30 seconds and doubles with each retry, capped at 30
minutes as suggested on bugzilla [0]. If a guest still fails after the
last retry, it is counted as an error and the job finishes with errors.
If a retry succeeds, the guest is reported as successful in the
notifications and no error is counted.

The task log is opened in append mode for retries, so the log contains
the complete transcript of all attempts.

[0]: https://bugzilla.proxmox.com/show_bug.cgi?id=6464#c5
Link: https://bugzilla.proxmox.com/show_bug.cgi?id=6464

Signed-off-by: Jakob Klocker <j.klocker@proxmox.com>
---
 PVE/VZDump.pm | 131 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 129 insertions(+), 2 deletions(-)

diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index 56d2aea3..e4aa303d 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -10,6 +10,7 @@ use File::Path;
 use IO::File;
 use IO::Select;
 use IPC::Open3;
+use List::Util qw(min);
 use POSIX qw(strftime);
 use Time::Local;
 
@@ -1048,7 +1049,8 @@ sub exec_backup_task {
         -d $task->{tmpdir}
             || die "unable to create temporary directory '$task->{tmpdir}'";
 
-        $logfd = IO::File->new(">$tmplog")
+        my $logmode = $task->{retries} ? '>>' : '>';
+        $logfd = IO::File->new("${logmode}${tmplog}")
             || die "unable to create log file '$tmplog'";
 
         $task->{dumpdir} = $opts->{dumpdir};
@@ -1435,14 +1437,139 @@ sub exec_backup {
 
     my $starttime = time();
     my $errcount = 0;
+
+    my $error_behavior = $opts->{'error-behavior'} // 'ignore';
+    my $max_retries = $opts->{'max-retries'} // 5;
+    my $min_between_retry = 30;
+    my $max_wait = 60 * 30;
+
+    my $get_backoff = sub {
+        my ($retry) = @_;
+        return min($min_between_retry * 2**($retry - 1), $max_wait);
+    };
+
     eval {
 
         $self->{'backup-provider'}->job_init($starttime) if $self->{'backup-provider'};
         $self->run_hook_script('job-start', undef, $job_start_fd);
 
+        my $failed_tasks = {};
+
         foreach my $task (@$tasklist) {
+            my $vmid = $task->{vmid};
+            my $initial_task = {%$task};
+
+            $task->{retries} = 0;
             $self->exec_backup_task($task);
-            $errcount += 1 if $task->{state} ne 'ok';
+
+            next if $task->{state} eq 'ok';
+
+            if ($error_behavior eq 'retry-immediately') {
+                for my $retry (1 .. $max_retries) {
+                    my $backoff = $get_backoff->($retry);
+
+                    debugmsg(
+                        'info',
+                        "Retrying backup for guest $vmid (attempt $retry/$max_retries) after ${backoff}s delay...",
+                        undef,
+                        1,
+                    );
+                    sleep($backoff);
+
+                    %$task = (%$initial_task, retries => $retry);
+                    $self->exec_backup_task($task);
+
+                    last if $task->{state} eq 'ok';
+                }
+
+            } elsif ($error_behavior eq 'retry') {
+                $failed_tasks->{$vmid} = {
+                    task => $task,
+                    initial_task => $initial_task,
+                    fail_time => time(),
+                    retries => 0,
+                };
+                next;
+            }
+
+            if ($task->{state} ne 'ok') {
+                debugmsg('err', "Guest $vmid failed after $max_retries retries.", undef, 1)
+                    if $error_behavior eq 'retry-immediately';
+                $errcount++;
+            }
+        }
+
+        if ($error_behavior eq 'retry') {
+            while (keys %$failed_tasks > 0) {
+                my $now = time();
+                my $min_sleep = $max_wait;
+                my $ready_to_run = [];
+
+                my @sorted_vmids = sort {
+                    $failed_tasks->{$a}->{fail_time} <=> $failed_tasks->{$b}->{fail_time}
+                        || $a <=> $b
+                } keys %$failed_tasks;
+
+                foreach my $vmid (@sorted_vmids) {
+                    my $fail_info = $failed_tasks->{$vmid};
+
+                    if ($fail_info->{retries} >= $max_retries) {
+                        debugmsg(
+                            'err',
+                            "Guest $vmid failed after $max_retries retries.",
+                            undef,
+                            1,
+                        );
+                        $errcount++;
+                        delete $failed_tasks->{$vmid};
+                        next;
+                    }
+
+                    my $delay = $get_backoff->($fail_info->{retries} + 1);
+                    my $target_time = $fail_info->{fail_time} + $delay;
+                    my $wait_time = $target_time - $now;
+
+                    if ($wait_time > 0) {
+                        $min_sleep = $wait_time if $wait_time < $min_sleep;
+                    } else {
+                        push @$ready_to_run, $vmid;
+                    }
+                }
+
+                if (scalar(@$ready_to_run) == 0 && keys %$failed_tasks > 0) {
+                    debugmsg(
+                        'info',
+                        "Waiting $min_sleep seconds before next backup retry...",
+                        undef,
+                        1,
+                    );
+                    sleep($min_sleep);
+                    next;
+                }
+
+                foreach my $vmid (@$ready_to_run) {
+                    my $fail_info = $failed_tasks->{$vmid};
+
+                    $fail_info->{retries}++;
+                    debugmsg(
+                        'info',
+                        "Retrying backup for guest $vmid (attempt $fail_info->{retries}/$max_retries)",
+                        undef,
+                        1,
+                    );
+
+                    my $task = $fail_info->{task};
+                    %$task =
+                        (%{ $fail_info->{initial_task} }, retries => $fail_info->{retries});
+                    $self->exec_backup_task($task);
+
+                    if ($task->{state} eq 'ok') {
+                        delete $failed_tasks->{$vmid};
+                    } else {
+                        $fail_info->{fail_time} = time();
+                    }
+                }
+            }
         }
 
         $self->{'backup-provider'}->job_cleanup() if $self->{'backup-provider'};
-- 
2.47.3





^ permalink raw reply related	[relevance 19%]

* [PATCH docs/guest-common/manager v2 0/4] fix #6464: backup: add backup retry strategies
@ 2026-11-11  9:34 17% Jakob Klocker
  2026-11-11  9:34 19% ` [PATCH pve-manager v2 2/4] fix #6464: vzdump: add retry strategies for failed guest backups Jakob Klocker
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ results
From: Jakob Klocker @ 2026-11-11  9:34 UTC (permalink / raw)
  To: pve-devel

This series introduces automatic backup retries for guest backups in
vzdump to better handle transient failures.

As suggested by @Thomas [0], three strategies were added:
- `retry-immediately`: Immediately retries failed guests up to a
  configurable maximum retry count.
- `retry`: Defers failed guests and retries them at the end of the job
  up to the configurable maximum retry count.
- `ignore`: Retains the existing behavior by ignoring failures.

The number of retries is set with the new `max-retries` option (1-10,
default 5). Between attempts, a backoff delay is applied that starts at
30 seconds, doubles with each retry and is capped at 30 minutes. For
`retry`, the delay is measured from the last failure of that guest. The
interval and cap are intentionally not configurable for now.

If a guest succeeds on a retry, it is reported as successful in the
notification and no error is counted. If it still fails after the last
retry, the job finishes with errors as before. Task logging has been
switched to append mode so the log contains the complete transcript of
all attempts.

I kept the retry options in the advanced tab of the backup job window,
but I'm not sure whether they should be moved to the general tab.
Opinions on this are appreciated.

Testing info:
When testing I'd suggest to fail the backup by locking and
unlocking the guest with following commands:
`qm set <VMID> -lock backup`
`qm unlock <VMID>`

Changes since v1 (thanks @Shan):
- add documentation for the new retry options to pve-docs
- fix typo in pve-manager commit message
- drop the `advanced` flag from the retry fields in the manual backup
  window, which has no advanced section

[0] https://bugzilla.proxmox.com/show_bug.cgi?id=6464#c5
Link: https://bugzilla.proxmox.com/show_bug.cgi?id=6464


pve-guest-common:

Jakob Klocker (1):
  vzdump: add error-behavior and max-retries options

 src/PVE/VZDump/Common.pm | 15 +++++++++++++++
 1 file changed, 15 insertions(+)


pve-manager:

Jakob Klocker (2):
  fix #6464: vzdump: add retry strategies for failed guest backups
  ui: backup: add error behavior and retry options

 PVE/VZDump.pm                               | 131 +++++++++++++++++++-
 www/manager6/dc/Backup.js                   |   2 +-
 www/manager6/panel/BackupAdvancedOptions.js |  52 ++++++++
 www/manager6/window/Backup.js               |  45 ++++++-
 4 files changed, 226 insertions(+), 4 deletions(-)


pve-docs:

Jakob Klocker (1):
  vzdump: document backup retry options

 vzdump.adoc | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)


Summary over all repositories:
  6 files changed, 290 insertions(+), 4 deletions(-)

-- 
Generated by murpp 0.12.0




^ permalink raw reply	[relevance 17%]

* [PATCH pve-manager 2/3] fix #6464: vzdump: add retry strategies for failed guest backups
  2026-11-02 11:58 17% [PATCH guest-common/manager 0/3] fix #6464: backup: add backup retry strategies Jakob Klocker
@ 2026-11-02 11:58 19% ` Jakob Klocker
  2026-11-11  9:36  7% ` superseded: [PATCH guest-common/manager 0/3] fix #6464: backup: add backup retry strategies Jakob Klocker
  1 sibling, 0 replies; 15+ results
From: Jakob Klocker @ 2026-11-02 11:58 UTC (permalink / raw)
  To: pve-devel

Add the `error-behavior` and `max-retries` options to automatically
retry failed guest backups, which helps with transient failures.

Supported retry strategies:
- `ignore`: Preserves current behavior (no retries, default).
- `retry-immediately`: Retries the guest inline after
  failure.
- `retry`: Defers failed guests until all other guests have been
processed, then retries them in the order they failed.

A guest is retried at most `max-retries` times. Between attempts, the
delay starts at 30 seconds and dobules with each retry, capped at 30
minutes as suggested on bugzilla [0]. If a guest still fails after the
last retry, it is counted as an error and the job finishes with errors.
If a retry succeeds, the guest is reported as successful in the
notifications and no error is counted.

The task log is opened in append mode for retries, so the log contains
the complete transcript of all attempts.

[0]: https://bugzilla.proxmox.com/show_bug.cgi?id=6464#c5
Link: https://bugzilla.proxmox.com/show_bug.cgi?id=6464

Signed-off-by: Jakob Klocker <j.klocker@proxmox.com>
---
 PVE/VZDump.pm | 131 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 129 insertions(+), 2 deletions(-)

diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index defe9e0a..6199b7ff 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -10,6 +10,7 @@ use File::Path;
 use IO::File;
 use IO::Select;
 use IPC::Open3;
+use List::Util qw(min);
 use POSIX qw(strftime);
 use Time::Local;
 
@@ -1047,7 +1048,8 @@ sub exec_backup_task {
         -d $task->{tmpdir}
             || die "unable to create temporary directory '$task->{tmpdir}'";
 
-        $logfd = IO::File->new(">$tmplog")
+        my $logmode = $task->{retries} ? '>>' : '>';
+        $logfd = IO::File->new("${logmode}${tmplog}")
             || die "unable to create log file '$tmplog'";
 
         $task->{dumpdir} = $opts->{dumpdir};
@@ -1434,14 +1436,139 @@ sub exec_backup {
 
     my $starttime = time();
     my $errcount = 0;
+
+    my $error_behavior = $opts->{'error-behavior'} // 'ignore';
+    my $max_retries = $opts->{'max-retries'} // 5;
+    my $min_between_retry = 30;
+    my $max_wait = 60 * 30;
+
+    my $get_backoff = sub {
+        my ($retry) = @_;
+        return min($min_between_retry * 2**($retry - 1), $max_wait);
+    };
+
     eval {
 
         $self->{'backup-provider'}->job_init($starttime) if $self->{'backup-provider'};
         $self->run_hook_script('job-start', undef, $job_start_fd);
 
+        my $failed_tasks = {};
+
         foreach my $task (@$tasklist) {
+            my $vmid = $task->{vmid};
+            my $initial_task = {%$task};
+
+            $task->{retries} = 0;
             $self->exec_backup_task($task);
-            $errcount += 1 if $task->{state} ne 'ok';
+
+            next if $task->{state} eq 'ok';
+
+            if ($error_behavior eq 'retry-immediately') {
+                for my $retry (1 .. $max_retries) {
+                    my $backoff = $get_backoff->($retry);
+
+                    debugmsg(
+                        'info',
+                        "Retrying backup for guest $vmid (attempt $retry/$max_retries) after ${backoff}s delay...",
+                        undef,
+                        1,
+                    );
+                    sleep($backoff);
+
+                    %$task = (%$initial_task, retries => $retry);
+                    $self->exec_backup_task($task);
+
+                    last if $task->{state} eq 'ok';
+                }
+
+            } elsif ($error_behavior eq 'retry') {
+                $failed_tasks->{$vmid} = {
+                    task => $task,
+                    initial_task => $initial_task,
+                    fail_time => time(),
+                    retries => 0,
+                };
+                next;
+            }
+
+            if ($task->{state} ne 'ok') {
+                debugmsg('err', "Guest $vmid failed after $max_retries retries.", undef, 1)
+                    if $error_behavior eq 'retry-immediately';
+                $errcount++;
+            }
+        }
+
+        if ($error_behavior eq 'retry') {
+            while (keys %$failed_tasks > 0) {
+                my $now = time();
+                my $min_sleep = $max_wait;
+                my $ready_to_run = [];
+
+                my @sorted_vmids = sort {
+                    $failed_tasks->{$a}->{fail_time} <=> $failed_tasks->{$b}->{fail_time}
+                        || $a <=> $b
+                } keys %$failed_tasks;
+
+                foreach my $vmid (@sorted_vmids) {
+                    my $fail_info = $failed_tasks->{$vmid};
+
+                    if ($fail_info->{retries} >= $max_retries) {
+                        debugmsg(
+                            'err',
+                            "Guest $vmid failed after $max_retries retries.",
+                            undef,
+                            1,
+                        );
+                        $errcount++;
+                        delete $failed_tasks->{$vmid};
+                        next;
+                    }
+
+                    my $delay = $get_backoff->($fail_info->{retries} + 1);
+                    my $target_time = $fail_info->{fail_time} + $delay;
+                    my $wait_time = $target_time - $now;
+
+                    if ($wait_time > 0) {
+                        $min_sleep = $wait_time if $wait_time < $min_sleep;
+                    } else {
+                        push @$ready_to_run, $vmid;
+                    }
+                }
+
+                if (scalar(@$ready_to_run) == 0 && keys %$failed_tasks > 0) {
+                    debugmsg(
+                        'info',
+                        "Waiting $min_sleep seconds before next backup retry...",
+                        undef,
+                        1,
+                    );
+                    sleep($min_sleep);
+                    next;
+                }
+
+                foreach my $vmid (@$ready_to_run) {
+                    my $fail_info = $failed_tasks->{$vmid};
+
+                    $fail_info->{retries}++;
+                    debugmsg(
+                        'info',
+                        "Retrying backup for guest $vmid (attempt $fail_info->{retries}/$max_retries)",
+                        undef,
+                        1,
+                    );
+
+                    my $task = $fail_info->{task};
+                    %$task =
+                        (%{ $fail_info->{initial_task} }, retries => $fail_info->{retries});
+                    $self->exec_backup_task($task);
+
+                    if ($task->{state} eq 'ok') {
+                        delete $failed_tasks->{$vmid};
+                    } else {
+                        $fail_info->{fail_time} = time();
+                    }
+                }
+            }
         }
 
         $self->{'backup-provider'}->job_cleanup() if $self->{'backup-provider'};
-- 
2.47.3





^ permalink raw reply related	[relevance 19%]

* [PATCH guest-common/manager 0/3] fix #6464: backup: add backup retry strategies
@ 2026-11-02 11:58 17% Jakob Klocker
  2026-11-02 11:58 19% ` [PATCH pve-manager 2/3] fix #6464: vzdump: add retry strategies for failed guest backups Jakob Klocker
  2026-11-11  9:36  7% ` superseded: [PATCH guest-common/manager 0/3] fix #6464: backup: add backup retry strategies Jakob Klocker
  0 siblings, 2 replies; 15+ results
From: Jakob Klocker @ 2026-11-02 11:58 UTC (permalink / raw)
  To: pve-devel

This series introduces automatic backup retries for guest backups in
vzdump to better handle transient failures.

As suggested by @Thomas [0], three strategies were added:
- `retry-immediately`: Immediately retries failed guests up to a
  configurable maximum retry count.
- `retry`: Defers failed guests and retries them at the end of the job
  up to the configurable maximum retry count.
- `ignore`: Retains the existing behavior by ignoring failures.

The number of retries is set with the new `max-retries` option (1-10,
default 5). Between attempts, a backoff delay is applied that starts at
30 seconds, doubles with each retry and is capped at 30 minutes. For
`retry`, the delay is measured from the last failure of that guest. The
interval and cap are intentionally not configurable for now.

If a guest succeeds on a retry, it is reported as successful in the
notification and no error is counted. If it still fails after the last
retry, the job finishes with errors as before. Task logging has been
switched to append mode so the log contains the complete transcript of
all attempts.

I kept the retry options in the advanced tab of the backup job window,
but I'm not sure whether they should be moved to the general tab. 
Opinions on this are appreciated.

Testing info:
When testing I'd suggest to fail the backup by locking and
unlocking the guest with following commands:
`qm set <VMID> -lock backup`
`qm unlock <VMID>`

[0] https://bugzilla.proxmox.com/show_bug.cgi?id=6464#c5
Link: https://bugzilla.proxmox.com/show_bug.cgi?id=6464


pve-guest-common:

Jakob Klocker (1):
  vzdump: add error-behavior and max-retries options

 src/PVE/VZDump/Common.pm | 15 +++++++++++++++
 1 file changed, 15 insertions(+)


pve-manager:

Jakob Klocker (2):
  fix #6464: vzdump: add retry strategies for failed guest backups
  ui: backup: add error behavior and retry options

 PVE/VZDump.pm                               | 131 +++++++++++++++++++-
 www/manager6/dc/Backup.js                   |   2 +-
 www/manager6/panel/BackupAdvancedOptions.js |  52 ++++++++
 www/manager6/window/Backup.js               |  47 ++++++-
 4 files changed, 228 insertions(+), 4 deletions(-)


Summary over all repositories:
  5 files changed, 243 insertions(+), 4 deletions(-)

-- 
Generated by murpp 0.12.0




^ permalink raw reply	[relevance 17%]

Results 1-15 of 15 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2026-11-02 11:58 17% [PATCH guest-common/manager 0/3] fix #6464: backup: add backup retry strategies Jakob Klocker
2026-11-02 11:58 19% ` [PATCH pve-manager 2/3] fix #6464: vzdump: add retry strategies for failed guest backups Jakob Klocker
2026-11-11  9:36  7% ` superseded: [PATCH guest-common/manager 0/3] fix #6464: backup: add backup retry strategies Jakob Klocker
2026-11-11  9:34 17% [PATCH docs/guest-common/manager v2 0/4] " Jakob Klocker
2026-11-11  9:34 19% ` [PATCH pve-manager v2 2/4] fix #6464: vzdump: add retry strategies for failed guest backups Jakob Klocker
2026-11-11 15:40 10%   ` Jonas Theisen
2026-11-11 15:40 11% ` [PATCH docs/guest-common/manager v2 0/4] fix #6464: backup: add backup retry strategies Jonas Theisen
2026-11-12 10:11 10%   ` Jakob Klocker
2026-11-16 10:16  7% ` superseded: " Jakob Klocker
2026-11-16 10:13 17% [PATCH docs/guest-common/manager v3 " Jakob Klocker
2026-11-16 10:13 19% ` [PATCH pve-manager v3 2/4] fix #6464: vzdump: add retry strategies for failed guest backups Jakob Klocker
2026-11-20 16:09  7% ` superseded: [PATCH docs/guest-common/manager v3 0/4] fix #6464: backup: add backup retry strategies Jakob Klocker
2026-11-20 16:05 16% [PATCH docs/guest-common/manager/storage/storage-plugin-examples v4 0/7] " Jakob Klocker
2026-11-20 16:05 19% ` [PATCH pve-manager v4 5/7] fix #6464: vzdump: add retry strategies for failed guest backups Jakob Klocker
2026-11-21 21:42  9%   ` 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