all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [RFC v2 pve-container pve-manager 3/3] ui: lxc restore: add selective mountpoint restore
Date: Mon, 23 Oct 2023 13:18:35 +0200	[thread overview]
Message-ID: <20231023111835.238407-4-c.ebner@proxmox.com> (raw)
In-Reply-To: <20231023111835.238407-1-c.ebner@proxmox.com>

Adds a grid to the lxc backup restore window allowing the user to select
mountpoints which should be included/excluded from a restore.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---

changes since v1:
    not present in v1

 www/manager6/Makefile                     |  1 +
 www/manager6/grid/BackupRestoreTargets.js | 37 +++++++++++++++++++++++
 www/manager6/window/Restore.js            | 34 +++++++++++++++++++++
 3 files changed, 72 insertions(+)
 create mode 100644 www/manager6/grid/BackupRestoreTargets.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 17e0ad05..c096a8be 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -88,6 +88,7 @@ JSSRC= 							\
 	form/TagEdit.js					\
 	form/MultiFileButton.js				\
 	grid/BackupView.js				\
+	grid/BackupRestoreTargets.js			\
 	grid/FirewallAliases.js				\
 	grid/FirewallOptions.js				\
 	grid/FirewallRules.js				\
diff --git a/www/manager6/grid/BackupRestoreTargets.js b/www/manager6/grid/BackupRestoreTargets.js
new file mode 100644
index 00000000..b811989e
--- /dev/null
+++ b/www/manager6/grid/BackupRestoreTargets.js
@@ -0,0 +1,37 @@
+Ext.define('PVE.BackupRestoreTargets', {
+    extend: 'Ext.grid.Panel',
+    alias: 'widget.pveBackupRestoreTargets',
+    store: {
+	fields: [
+	    {
+		name: 'restore',
+		type: 'boolean',
+	    },
+	    {
+		name: 'target',
+		type: 'string',
+	    },
+	],
+    },
+
+    getMountpoints: function() {
+	return this.store.getData();
+    },
+
+    setMountpoints: function(mountpoints) {
+	this.store.loadData(mountpoints);
+    },
+
+    columns: [
+	{
+	    text: gettext('Mountpoint'),
+	    dataIndex: 'mountpoint',
+	    flex: 1,
+	},
+	{
+	    text: gettext('Restore'),
+	    dataIndex: 'restore',
+	    xtype: 'checkcolumn',
+	},
+    ],
+});
diff --git a/www/manager6/window/Restore.js b/www/manager6/window/Restore.js
index 36aecc39..85e382fb 100644
--- a/www/manager6/window/Restore.js
+++ b/www/manager6/window/Restore.js
@@ -67,6 +67,13 @@ Ext.define('PVE.window.Restore', {
 		    params.unprivileged = values.unprivileged;
 		}
 		confirmMsg = Proxmox.Utils.format_task_description('vzrestore', params.vmid);
+		let viewModel = view.getViewModel();
+		let excludes = viewModel.get('mountpoints')
+		    .filter(mp => mp.restore === false)
+		    .map(mp => mp.mountpoint);
+		if (excludes.length > 0) {
+		    params['exclude-mps'] = excludes.join(',');
+		}
 	    } else if (view.vmtype === 'qemu') {
 		params.archive = view.volid;
 		confirmMsg = Proxmox.Utils.format_task_description('qmrestore', params.vmid);
@@ -111,6 +118,7 @@ Ext.define('PVE.window.Restore', {
 
 	afterRender: function() {
 	    let view = this.getView();
+	    let viewModel = view.getViewModel();
 
 	    Proxmox.Utils.API2Request({
 		url: `/nodes/${view.nodename}/vzdump/extractconfig`,
@@ -123,6 +131,7 @@ Ext.define('PVE.window.Restore', {
 		success: function(response, options) {
 		    let allStoragesAvailable = true;
 
+		    let mountpoints = [];
 		    response.result.data.split('\n').forEach(line => {
 			let [_, key, value] = line.match(/^([^:]+):\s*(\S+)\s*$/) ?? [];
 
@@ -139,8 +148,14 @@ Ext.define('PVE.window.Restore', {
 			    view.lookupReference('nameField').setEmptyText(value);
 			} else if (key === 'memory' || key === 'cores' || key === 'sockets') {
 			    view.lookupReference(`${key}Field`).setEmptyText(value);
+			} else if (key.match(/mp\d+/) && value.includes('backup=1')) {
+			    mountpoints.push({
+				'mountpoint': key,
+				'restore': true,
+			    });
 			}
 		    });
+		    viewModel.set('mountpoints', mountpoints);
 
 		    if (!allStoragesAvailable) {
 			let storagesel = view.down('pveStorageSelector[name=storage]');
@@ -152,6 +167,12 @@ Ext.define('PVE.window.Restore', {
 	},
     },
 
+    viewModel: {
+	config: {
+	    mountpoints: [],
+	},
+    },
+
     initComponent: function() {
 	let me = this;
 
@@ -354,6 +375,19 @@ Ext.define('PVE.window.Restore', {
 	    ],
 	});
 
+	if (me.vmtype === 'lxc') {
+	    items.push({
+		title: `${gettext('Restore Mountpoints')}:`,
+		name: 'mountpointRestoreTargets',
+		xtype: 'pveBackupRestoreTargets',
+		hidden: true, // Hide until config loaded
+		bind: {
+		    mountpoints: '{mountpoints}',
+		    hidden: '{!mountpoints.length}',
+		},
+	    });
+	}
+
 	let title = gettext('Restore') + ": " + (me.vmtype === 'lxc' ? 'CT' : 'VM');
 	if (me.vmid) {
 	    title = `${gettext('Overwrite')} ${title} ${me.vmid}`;
-- 
2.39.2





  parent reply	other threads:[~2023-10-23 11:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-23 11:18 [pve-devel] [RFC v2 pve-container pve-manager 0/3] add partial restore Christian Ebner
2023-10-23 11:18 ` [pve-devel] [RFC v2 pve-container pve-manager 1/3] backup: do not delete not backed-up mps on restore Christian Ebner
2023-10-23 11:18 ` [pve-devel] [RFC v2 pve-container pve-manager 2/3] api: allow to exclude mountpoins from restore Christian Ebner
2023-10-23 11:18 ` Christian Ebner [this message]
2023-10-23 12:47 ` [pve-devel] [RFC v2 pve-container pve-manager 0/3] add partial restore Fiona Ebner
2023-10-23 13:03   ` Christian Ebner

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=20231023111835.238407-4-c.ebner@proxmox.com \
    --to=c.ebner@proxmox.com \
    --cc=pve-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal