[pve-devel] [PATCH pve-container 1/1] Add pre/post-restore hooks to CTs

Stefan Hanreich s.hanreich at proxmox.com
Thu Nov 10 16:33:40 CET 2022


Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
---
 src/PVE/API2/LXC.pm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 79aecaa..0e8cb95 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -380,6 +380,9 @@ __PACKAGE__->register_method({
 		my $orig_mp_param; # only used if $restore
 		if ($restore) {
 		    die "can't overwrite running container\n" if PVE::LXC::check_running($vmid);
+
+		    PVE::GuestHelpers::exec_hookscript($old_conf, $vmid, 'pre-restore', 1);
+
 		    if ($archive ne '-') {
 			my $orig_conf;
 			print "recovering backed-up configuration from '$archive'\n";
@@ -505,6 +508,10 @@ __PACKAGE__->register_method({
 
 	    PVE::API2::LXC::Status->vm_start({ vmid => $vmid, node => $node })
 		if $start_after_create;
+
+	    if ($restore) {
+		PVE::GuestHelpers::exec_hookscript($conf, $vmid, 'post-restore');
+	    }
 	};
 
 	my $workername = $restore ? 'vzrestore' : 'vzcreate';
-- 
2.30.2





More information about the pve-devel mailing list