* [pbs-devel] [PATCH proxmox 1/1] pbs-api-types: add 'unmount-on-done' field to sync job config
2025-10-14 11:53 [pbs-devel] [PATCH proxmox{, -backup} 0/4] unmount datastores after sync job Hannes Laimer
@ 2025-10-14 11:53 ` Hannes Laimer
2025-10-14 11:53 ` [pbs-devel] [PATCH proxmox-backup 1/3] api: syncjob: correctly update/delete 'unmount-on-done' field Hannes Laimer
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Hannes Laimer @ 2025-10-14 11:53 UTC (permalink / raw)
To: pbs-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
pbs-api-types/src/jobs.rs | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/pbs-api-types/src/jobs.rs b/pbs-api-types/src/jobs.rs
index 3eb61cde..3284a4c8 100644
--- a/pbs-api-types/src/jobs.rs
+++ b/pbs-api-types/src/jobs.rs
@@ -538,6 +538,8 @@ pub const SYNC_VERIFIED_ONLY_SCHEMA: Schema =
BooleanSchema::new("Only synchronize verified backup snapshots, exclude others.").schema();
pub const RUN_SYNC_ON_MOUNT_SCHEMA: Schema =
BooleanSchema::new("Run this job when a relevant datastore is mounted.").schema();
+pub const UNMOUNT_ON_SYNC_DONE_SCHEMA: Schema =
+ BooleanSchema::new("Unmount involved removable datastore after sync job finishes.").schema();
#[api(
properties: {
@@ -609,6 +611,10 @@ pub const RUN_SYNC_ON_MOUNT_SCHEMA: Schema =
schema: RUN_SYNC_ON_MOUNT_SCHEMA,
optional: true,
},
+ "unmount-on-done": {
+ schema: UNMOUNT_ON_SYNC_DONE_SCHEMA,
+ optional: true,
+ },
"sync-direction": {
type: SyncDirection,
optional: true,
@@ -655,6 +661,8 @@ pub struct SyncJobConfig {
#[serde(skip_serializing_if = "Option::is_none")]
pub run_on_mount: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
+ pub unmount_on_done: Option<bool>,
+ #[serde(skip_serializing_if = "Option::is_none")]
pub sync_direction: Option<SyncDirection>,
}
--
2.47.3
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [pbs-devel] [PATCH proxmox-backup 1/3] api: syncjob: correctly update/delete 'unmount-on-done' field
2025-10-14 11:53 [pbs-devel] [PATCH proxmox{, -backup} 0/4] unmount datastores after sync job Hannes Laimer
2025-10-14 11:53 ` [pbs-devel] [PATCH proxmox 1/1] pbs-api-types: add 'unmount-on-done' field to sync job config Hannes Laimer
@ 2025-10-14 11:53 ` Hannes Laimer
2025-10-14 11:53 ` [pbs-devel] [PATCH proxmox-backup 2/3] api: datastore: unmount datastore after sync if configured Hannes Laimer
2025-10-14 11:53 ` [pbs-devel] [PATCH proxmox-backup 3/3] ui: add 'unmount-on-done' field to SyncJobEdit window Hannes Laimer
3 siblings, 0 replies; 7+ messages in thread
From: Hannes Laimer @ 2025-10-14 11:53 UTC (permalink / raw)
To: pbs-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
src/api2/config/sync.rs | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/api2/config/sync.rs b/src/api2/config/sync.rs
index 358409b5..ab68391c 100644
--- a/src/api2/config/sync.rs
+++ b/src/api2/config/sync.rs
@@ -341,6 +341,8 @@ pub enum DeletableProperty {
VerifiedOnly,
/// Delete the run_on_mount property,
RunOnMount,
+ /// Delete the unmount_on_done property,
+ UnmountOnDone,
/// Delete the sync_direction property,
SyncDirection,
}
@@ -463,6 +465,9 @@ pub fn update_sync_job(
DeletableProperty::RunOnMount => {
data.run_on_mount = None;
}
+ DeletableProperty::UnmountOnDone => {
+ data.unmount_on_done = None;
+ }
DeletableProperty::SyncDirection => {
data.sync_direction = None;
}
@@ -515,6 +520,9 @@ pub fn update_sync_job(
if let Some(run_on_mount) = update.run_on_mount {
data.run_on_mount = Some(run_on_mount);
}
+ if let Some(unmount_on_done) = update.unmount_on_done {
+ data.unmount_on_done = Some(unmount_on_done);
+ }
if let Some(sync_direction) = update.sync_direction {
data.sync_direction = Some(sync_direction);
}
--
2.47.3
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [pbs-devel] [PATCH proxmox-backup 2/3] api: datastore: unmount datastore after sync if configured
2025-10-14 11:53 [pbs-devel] [PATCH proxmox{, -backup} 0/4] unmount datastores after sync job Hannes Laimer
2025-10-14 11:53 ` [pbs-devel] [PATCH proxmox 1/1] pbs-api-types: add 'unmount-on-done' field to sync job config Hannes Laimer
2025-10-14 11:53 ` [pbs-devel] [PATCH proxmox-backup 1/3] api: syncjob: correctly update/delete 'unmount-on-done' field Hannes Laimer
@ 2025-10-14 11:53 ` Hannes Laimer
2025-10-14 15:31 ` Shannon Sterz
2025-10-14 11:53 ` [pbs-devel] [PATCH proxmox-backup 3/3] ui: add 'unmount-on-done' field to SyncJobEdit window Hannes Laimer
3 siblings, 1 reply; 7+ messages in thread
From: Hannes Laimer @ 2025-10-14 11:53 UTC (permalink / raw)
To: pbs-devel
When a sync job is triggered by the mounting of a datastore, we now check
whether it should also be unmounted automatically afterwards. This is only
done for jobs triggered by mounting.
We do not do this for manually started or scheduled sync jobs, as those
run in the proxy process and therefore cannot call the privileged API
endpoint for unmounting.
The task that starts sync jobs on mount runs in the API process (where the
mounting occurs), so in that privileged context, we can also perform the
unmounting.
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
src/api2/admin/datastore.rs | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs
index 643d1694..7e3cec22 100644
--- a/src/api2/admin/datastore.rs
+++ b/src/api2/admin/datastore.rs
@@ -2430,6 +2430,7 @@ pub fn do_mount_device(datastore: DataStoreConfig) -> Result<bool, Error> {
async fn do_sync_jobs(
jobs_to_run: Vec<SyncJobConfig>,
+ store: String,
worker: Arc<WorkerTask>,
) -> Result<(), Error> {
let count = jobs_to_run.len();
@@ -2442,6 +2443,8 @@ async fn do_sync_jobs(
.join(", ")
);
+ let mut unmount_on_done = false;
+
let client = crate::client_helpers::connect_to_localhost()
.context("Failed to connect to localhost for starting sync jobs")?;
for (i, job_config) in jobs_to_run.into_iter().enumerate() {
@@ -2484,7 +2487,21 @@ async fn do_sync_jobs(
}
}
}
+ unmount_on_done = unmount_on_done || job_config.unmount_on_done.unwrap_or_default();
+ }
+ if unmount_on_done {
+ match client
+ .post(
+ format!("api2/json/admin/datastore/{store}/unmount").as_str(),
+ None,
+ )
+ .await
+ {
+ Ok(_) => info!("triggered unmounting successfully"),
+ Err(err) => warn!("could not unmount: {err}"),
+ };
}
+
Ok(())
}
@@ -2566,10 +2583,10 @@ pub fn mount(store: String, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Er
info!("starting {} sync jobs", jobs_to_run.len());
let _ = WorkerTask::spawn(
"mount-sync-jobs",
- Some(store),
+ Some(store.clone()),
auth_id.to_string(),
false,
- move |worker| async move { do_sync_jobs(jobs_to_run, worker).await },
+ move |worker| async move { do_sync_jobs(jobs_to_run, store, worker).await },
);
}
Ok(())
--
2.47.3
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [pbs-devel] [PATCH proxmox-backup 2/3] api: datastore: unmount datastore after sync if configured
2025-10-14 11:53 ` [pbs-devel] [PATCH proxmox-backup 2/3] api: datastore: unmount datastore after sync if configured Hannes Laimer
@ 2025-10-14 15:31 ` Shannon Sterz
0 siblings, 0 replies; 7+ messages in thread
From: Shannon Sterz @ 2025-10-14 15:31 UTC (permalink / raw)
To: Hannes Laimer; +Cc: Proxmox Backup Server development discussion
On Tue Oct 14, 2025 at 1:53 PM CEST, Hannes Laimer wrote:
> When a sync job is triggered by the mounting of a datastore, we now check
> whether it should also be unmounted automatically afterwards. This is only
> done for jobs triggered by mounting.
>
> We do not do this for manually started or scheduled sync jobs, as those
> run in the proxy process and therefore cannot call the privileged API
> endpoint for unmounting.
>
> The task that starts sync jobs on mount runs in the API process (where the
> mounting occurs), so in that privileged context, we can also perform the
> unmounting.
>
> Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
> ---
> src/api2/admin/datastore.rs | 21 +++++++++++++++++++--
> 1 file changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs
> index 643d1694..7e3cec22 100644
> --- a/src/api2/admin/datastore.rs
> +++ b/src/api2/admin/datastore.rs
> @@ -2430,6 +2430,7 @@ pub fn do_mount_device(datastore: DataStoreConfig) -> Result<bool, Error> {
>
> async fn do_sync_jobs(
> jobs_to_run: Vec<SyncJobConfig>,
> + store: String,
> worker: Arc<WorkerTask>,
> ) -> Result<(), Error> {
> let count = jobs_to_run.len();
> @@ -2442,6 +2443,8 @@ async fn do_sync_jobs(
> .join(", ")
> );
>
> + let mut unmount_on_done = false;
> +
> let client = crate::client_helpers::connect_to_localhost()
> .context("Failed to connect to localhost for starting sync jobs")?;
> for (i, job_config) in jobs_to_run.into_iter().enumerate() {
> @@ -2484,7 +2487,21 @@ async fn do_sync_jobs(
> }
> }
> }
> + unmount_on_done = unmount_on_done || job_config.unmount_on_done.unwrap_or_default();
this could be:
unmount_on_done |= job_config.unmount_on_done.unwrap_or_default();
> + }
> + if unmount_on_done {
> + match client
> + .post(
> + format!("api2/json/admin/datastore/{store}/unmount").as_str(),
> + None,
> + )
> + .await
> + {
> + Ok(_) => info!("triggered unmounting successfully"),
> + Err(err) => warn!("could not unmount: {err}"),
> + };
> }
> +
> Ok(())
> }
>
> @@ -2566,10 +2583,10 @@ pub fn mount(store: String, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Er
> info!("starting {} sync jobs", jobs_to_run.len());
> let _ = WorkerTask::spawn(
> "mount-sync-jobs",
> - Some(store),
> + Some(store.clone()),
> auth_id.to_string(),
> false,
> - move |worker| async move { do_sync_jobs(jobs_to_run, worker).await },
> + move |worker| async move { do_sync_jobs(jobs_to_run, store, worker).await },
> );
> }
> Ok(())
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [pbs-devel] [PATCH proxmox-backup 3/3] ui: add 'unmount-on-done' field to SyncJobEdit window
2025-10-14 11:53 [pbs-devel] [PATCH proxmox{, -backup} 0/4] unmount datastores after sync job Hannes Laimer
` (2 preceding siblings ...)
2025-10-14 11:53 ` [pbs-devel] [PATCH proxmox-backup 2/3] api: datastore: unmount datastore after sync if configured Hannes Laimer
@ 2025-10-14 11:53 ` Hannes Laimer
2025-10-14 15:31 ` Shannon Sterz
3 siblings, 1 reply; 7+ messages in thread
From: Hannes Laimer @ 2025-10-14 11:53 UTC (permalink / raw)
To: pbs-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
www/window/SyncJobEdit.js | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/www/window/SyncJobEdit.js b/www/window/SyncJobEdit.js
index 14ffddcd..00e6ed2e 100644
--- a/www/window/SyncJobEdit.js
+++ b/www/window/SyncJobEdit.js
@@ -122,6 +122,7 @@ Ext.define('PBS.window.SyncJobEdit', {
}
if (!me.isCreate) {
PBS.Utils.delete_if_default(values, 'run-on-mount', false);
+ PBS.Utils.delete_if_default(values, 'unmount-on-done', false);
PBS.Utils.delete_if_default(values, 'rate-in');
PBS.Utils.delete_if_default(values, 'rate-out');
PBS.Utils.delete_if_default(values, 'remote');
@@ -499,8 +500,30 @@ Ext.define('PBS.window.SyncJobEdit', {
'Run this job when a relevant removable datastore gets mounted.',
),
},
+ listeners: {
+ change: function (field, runOnMount) {
+ let me = this;
+ let view = me.up('pbsSyncJobEdit');
+ let unmountOnDoneCb = view.down('field[name=unmount-on-done]');
+ unmountOnDoneCb.setDisabled(!runOnMount);
+ },
+ },
+ uncheckedValue: false,
+ value: false,
+ },
+ {
+ xtype: 'proxmoxcheckbox',
+ name: 'unmount-on-done',
+ fieldLabel: gettext('Unmount when done'),
+ autoEl: {
+ tag: 'div',
+ 'data-qtip': gettext(
+ 'Unmount relevant removable datastore onmce sync job finishes.',
+ ),
+ },
uncheckedValue: false,
value: false,
+ disabled: true,
},
],
},
--
2.47.3
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [pbs-devel] [PATCH proxmox-backup 3/3] ui: add 'unmount-on-done' field to SyncJobEdit window
2025-10-14 11:53 ` [pbs-devel] [PATCH proxmox-backup 3/3] ui: add 'unmount-on-done' field to SyncJobEdit window Hannes Laimer
@ 2025-10-14 15:31 ` Shannon Sterz
0 siblings, 0 replies; 7+ messages in thread
From: Shannon Sterz @ 2025-10-14 15:31 UTC (permalink / raw)
To: Hannes Laimer; +Cc: Proxmox Backup Server development discussion
On Tue Oct 14, 2025 at 1:53 PM CEST, Hannes Laimer wrote:
> Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
> ---
> www/window/SyncJobEdit.js | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
> diff --git a/www/window/SyncJobEdit.js b/www/window/SyncJobEdit.js
> index 14ffddcd..00e6ed2e 100644
> --- a/www/window/SyncJobEdit.js
> +++ b/www/window/SyncJobEdit.js
> @@ -122,6 +122,7 @@ Ext.define('PBS.window.SyncJobEdit', {
> }
> if (!me.isCreate) {
> PBS.Utils.delete_if_default(values, 'run-on-mount', false);
> + PBS.Utils.delete_if_default(values, 'unmount-on-done', false);
> PBS.Utils.delete_if_default(values, 'rate-in');
> PBS.Utils.delete_if_default(values, 'rate-out');
> PBS.Utils.delete_if_default(values, 'remote');
> @@ -499,8 +500,30 @@ Ext.define('PBS.window.SyncJobEdit', {
> 'Run this job when a relevant removable datastore gets mounted.',
> ),
> },
> + listeners: {
> + change: function (field, runOnMount) {
> + let me = this;
> + let view = me.up('pbsSyncJobEdit');
> + let unmountOnDoneCb = view.down('field[name=unmount-on-done]');
> + unmountOnDoneCb.setDisabled(!runOnMount);
> + },
> + },
> + uncheckedValue: false,
> + value: false,
> + },
> + {
> + xtype: 'proxmoxcheckbox',
> + name: 'unmount-on-done',
> + fieldLabel: gettext('Unmount when done'),
> + autoEl: {
> + tag: 'div',
> + 'data-qtip': gettext(
> + 'Unmount relevant removable datastore onmce sync job finishes.',
got a typo there: once, not onmce :)
> + ),
> + },
> uncheckedValue: false,
> value: false,
> + disabled: true,
> },
> ],
> },
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 7+ messages in thread