* [pve-devel] [PATCH v3 manager] close #3476: vzdump: add job-init hook
@ 2022-01-18 8:21 Fabian Ebner
2022-01-18 11:22 ` [pve-devel] applied: " Fabian Grünbichler
0 siblings, 1 reply; 2+ messages in thread
From: Fabian Ebner @ 2022-01-18 8:21 UTC (permalink / raw)
To: pve-devel
which allows users to prepare the backup storage for activation (e.g.
by waking up a remote node).
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Acked-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
Changes from v2:
* Fix wording in comment.
* More complete example commands in dummy hook script.
PVE/VZDump.pm | 17 ++++++++++++++++-
vzdump-hook-script.pl | 12 +++++++++++-
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index b5a5fadd..65867325 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -497,6 +497,13 @@ sub new {
$opts->{storage} = 'local';
}
+ $self->{job_init_log} = '';
+ open my $job_init_fd, '>', \$self->{job_init_log};
+ $self->run_hook_script('job-init', undef, $job_init_fd);
+ close $job_init_fd;
+
+ PVE::Cluster::cfs_update(); # Pick up possible changes made by the hook script.
+
my $errors = '';
if ($opts->{storage}) {
@@ -1194,7 +1201,15 @@ sub exec_backup {
my $totaltime = time() - $starttime;
- eval { $self->sendmail ($tasklist, $totaltime, undef, $job_start_log, $job_end_log); };
+ eval {
+ $self->sendmail(
+ $tasklist,
+ $totaltime,
+ undef,
+ $self->{job_init_log} . $job_start_log,
+ $job_end_log,
+ );
+ };
debugmsg ('err', $@) if $@;
die $err if $err;
diff --git a/vzdump-hook-script.pl b/vzdump-hook-script.pl
index 60edbc04..4d530cef 100755
--- a/vzdump-hook-script.pl
+++ b/vzdump-hook-script.pl
@@ -11,11 +11,13 @@ print "HOOK: " . join (' ', @ARGV) . "\n";
my $phase = shift;
-if ($phase eq 'job-start' ||
+if ($phase eq 'job-init' ||
+ $phase eq 'job-start' ||
$phase eq 'job-end' ||
$phase eq 'job-abort') {
# undef for Proxmox Backup Server storages
+ # undef in phase 'job-init' except when --dumpdir is used directly
my $dumpdir = $ENV{DUMPDIR};
# undef when --dumpdir is used directly
@@ -26,6 +28,14 @@ if ($phase eq 'job-start' ||
print "storeid=$storeid;" if defined($storeid);
print "\n";
+ # example: wake up remote storage node and enable storage
+ if ($phase eq 'job-init') {
+ #system("wakeonlan AA:BB:CC:DD:EE:FF");
+ #sleep(30);
+ #system ("/sbin/pvesm set $storeid --disable 0") == 0 ||
+ # die "enabling storage $storeid failed";
+ }
+
# do what you want
} elsif ($phase eq 'backup-start' ||
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pve-devel] applied: [PATCH v3 manager] close #3476: vzdump: add job-init hook
2022-01-18 8:21 [pve-devel] [PATCH v3 manager] close #3476: vzdump: add job-init hook Fabian Ebner
@ 2022-01-18 11:22 ` Fabian Grünbichler
0 siblings, 0 replies; 2+ messages in thread
From: Fabian Grünbichler @ 2022-01-18 11:22 UTC (permalink / raw)
To: Proxmox VE development discussion
thanks!
On January 18, 2022 9:21 am, Fabian Ebner wrote:
> which allows users to prepare the backup storage for activation (e.g.
> by waking up a remote node).
>
> Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> Acked-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
> ---
>
> Changes from v2:
> * Fix wording in comment.
> * More complete example commands in dummy hook script.
>
> PVE/VZDump.pm | 17 ++++++++++++++++-
> vzdump-hook-script.pl | 12 +++++++++++-
> 2 files changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
> index b5a5fadd..65867325 100644
> --- a/PVE/VZDump.pm
> +++ b/PVE/VZDump.pm
> @@ -497,6 +497,13 @@ sub new {
> $opts->{storage} = 'local';
> }
>
> + $self->{job_init_log} = '';
> + open my $job_init_fd, '>', \$self->{job_init_log};
> + $self->run_hook_script('job-init', undef, $job_init_fd);
> + close $job_init_fd;
> +
> + PVE::Cluster::cfs_update(); # Pick up possible changes made by the hook script.
> +
> my $errors = '';
>
> if ($opts->{storage}) {
> @@ -1194,7 +1201,15 @@ sub exec_backup {
>
> my $totaltime = time() - $starttime;
>
> - eval { $self->sendmail ($tasklist, $totaltime, undef, $job_start_log, $job_end_log); };
> + eval {
> + $self->sendmail(
> + $tasklist,
> + $totaltime,
> + undef,
> + $self->{job_init_log} . $job_start_log,
> + $job_end_log,
> + );
> + };
> debugmsg ('err', $@) if $@;
>
> die $err if $err;
> diff --git a/vzdump-hook-script.pl b/vzdump-hook-script.pl
> index 60edbc04..4d530cef 100755
> --- a/vzdump-hook-script.pl
> +++ b/vzdump-hook-script.pl
> @@ -11,11 +11,13 @@ print "HOOK: " . join (' ', @ARGV) . "\n";
>
> my $phase = shift;
>
> -if ($phase eq 'job-start' ||
> +if ($phase eq 'job-init' ||
> + $phase eq 'job-start' ||
> $phase eq 'job-end' ||
> $phase eq 'job-abort') {
>
> # undef for Proxmox Backup Server storages
> + # undef in phase 'job-init' except when --dumpdir is used directly
> my $dumpdir = $ENV{DUMPDIR};
>
> # undef when --dumpdir is used directly
> @@ -26,6 +28,14 @@ if ($phase eq 'job-start' ||
> print "storeid=$storeid;" if defined($storeid);
> print "\n";
>
> + # example: wake up remote storage node and enable storage
> + if ($phase eq 'job-init') {
> + #system("wakeonlan AA:BB:CC:DD:EE:FF");
> + #sleep(30);
> + #system ("/sbin/pvesm set $storeid --disable 0") == 0 ||
> + # die "enabling storage $storeid failed";
> + }
> +
> # do what you want
>
> } elsif ($phase eq 'backup-start' ||
> --
> 2.30.2
>
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-18 11:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-18 8:21 [pve-devel] [PATCH v3 manager] close #3476: vzdump: add job-init hook Fabian Ebner
2022-01-18 11:22 ` [pve-devel] applied: " Fabian Grünbichler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox