* [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
` (3 subsequent siblings)
4 siblings, 0 replies; 12+ 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] 12+ 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-29 13:24 ` Robert Obkircher
2025-10-14 11:53 ` [pbs-devel] [PATCH proxmox-backup 2/3] api: datastore: unmount datastore after sync if configured Hannes Laimer
` (2 subsequent siblings)
4 siblings, 1 reply; 12+ 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] 12+ messages in thread* Re: [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 1/3] api: syncjob: correctly update/delete 'unmount-on-done' field Hannes Laimer
@ 2025-10-29 13:24 ` Robert Obkircher
2025-10-29 13:37 ` Christian Ebner
0 siblings, 1 reply; 12+ messages in thread
From: Robert Obkircher @ 2025-10-29 13:24 UTC (permalink / raw)
To: pbs-devel
On 10/14/25 13:53, Hannes Laimer wrote:
> 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);
> }
Make deb failed with an error in this file:
error[E0063]: missing field `unmount_on_done` in initializer of
`SyncJobConfig`
--> src/api2/config/sync.rs:684:19
|
684 | let mut job = SyncJobConfig {
| ^^^^^^^^^^^^^ missing `unmount_on_done`
I added "unmount_on_done: None" and performed the following tests:
- create local and removable datastore
- create pull sync job with "run on mount" and "unmount when done"
- detach/reattach disk
- ok, got sync email and was unmounted
- disabled unmount when done
- detach/reattach disk
- ok, got sync email, remained mounted
- enabled "unmount when done" again
- manually start sync job with "run now"
- ok, got sync email
- remained mounted as explained by the cover letter. As a user
this might be confusing.
- created 3 more sync jobs, all with unmount when done
- ok, got 4 emails and was unmounted
Tested-by: Robert Obkircher <r.obkircher@proxmox.com>
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [pbs-devel] [PATCH proxmox-backup 1/3] api: syncjob: correctly update/delete 'unmount-on-done' field
2025-10-29 13:24 ` Robert Obkircher
@ 2025-10-29 13:37 ` Christian Ebner
2025-10-29 13:50 ` Christian Ebner
2025-10-29 13:51 ` Hannes Laimer
0 siblings, 2 replies; 12+ messages in thread
From: Christian Ebner @ 2025-10-29 13:37 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Robert Obkircher
Hi,
On 10/29/25 2:23 PM, Robert Obkircher wrote:
>
> On 10/14/25 13:53, Hannes Laimer wrote:
>> 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);
>> }
> Make deb failed with an error in this file:
>
> error[E0063]: missing field `unmount_on_done` in initializer of
> `SyncJobConfig`
> --> src/api2/config/sync.rs:684:19
> |
> 684 | let mut job = SyncJobConfig {
> | ^^^^^^^^^^^^^ missing `unmount_on_done`
Did you correctly install the changes to the pbs-api-types dependency first?
The `SyncJobConfig` is part of the `pbs-api-types` crate, which is
located in the `proxmox` repo.
Therefore, you can apply the first patch of the series there and build a
deb package via `make pbs-api-types-deb` from the repo base folder (or
in general `make <crate>-deb`). The install it via `dpkg -i
build/<pkg>.deb`.
And in the `proxmox-backup` repo make sure to run a `cargo clean` after
that.
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [pbs-devel] [PATCH proxmox-backup 1/3] api: syncjob: correctly update/delete 'unmount-on-done' field
2025-10-29 13:37 ` Christian Ebner
@ 2025-10-29 13:50 ` Christian Ebner
2025-10-29 13:51 ` Hannes Laimer
1 sibling, 0 replies; 12+ messages in thread
From: Christian Ebner @ 2025-10-29 13:50 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Robert Obkircher
On 10/29/25 2:37 PM, Christian Ebner wrote:
> Hi,
>
> On 10/29/25 2:23 PM, Robert Obkircher wrote:
>>
>> On 10/14/25 13:53, Hannes Laimer wrote:
>>> 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);
>>> }
>> Make deb failed with an error in this file:
>>
>> error[E0063]: missing field `unmount_on_done` in initializer of
>> `SyncJobConfig`
>> --> src/api2/config/sync.rs:684:19
>> |
>> 684 | let mut job = SyncJobConfig {
>> | ^^^^^^^^^^^^^ missing `unmount_on_done`
> Did you correctly install the changes to the pbs-api-types dependency
> first?
>
> The `SyncJobConfig` is part of the `pbs-api-types` crate, which is
> located in the `proxmox` repo.
>
> Therefore, you can apply the first patch of the series there and build a
> deb package via `make pbs-api-types-deb` from the repo base folder (or
> in general `make <crate>-deb`). The install it via `dpkg -i build/
> <pkg>.deb`.
>
> And in the `proxmox-backup` repo make sure to run a `cargo clean` after
> that.
Never mind, I see the build failing here with the same error as well.
Sorry for the noise!
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [pbs-devel] [PATCH proxmox-backup 1/3] api: syncjob: correctly update/delete 'unmount-on-done' field
2025-10-29 13:37 ` Christian Ebner
2025-10-29 13:50 ` Christian Ebner
@ 2025-10-29 13:51 ` Hannes Laimer
1 sibling, 0 replies; 12+ messages in thread
From: Hannes Laimer @ 2025-10-29 13:51 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Christian Ebner,
Robert Obkircher
On 10/29/25 14:37, Christian Ebner wrote:
> Hi,
>
> On 10/29/25 2:23 PM, Robert Obkircher wrote:
>>
>> On 10/14/25 13:53, Hannes Laimer wrote:
>>> 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);
>>> }
>> Make deb failed with an error in this file:
>>
>> error[E0063]: missing field `unmount_on_done` in initializer of
>> `SyncJobConfig`
>> --> src/api2/config/sync.rs:684:19
>> |
>> 684 | let mut job = SyncJobConfig {
>> | ^^^^^^^^^^^^^ missing `unmount_on_done`
> Did you correctly install the changes to the pbs-api-types dependency
> first?
This is in a test, I missed updating that. I didn't notice cause I
didn't `cargo test`...
>
> The `SyncJobConfig` is part of the `pbs-api-types` crate, which is
> located in the `proxmox` repo.
>
> Therefore, you can apply the first patch of the series there and build a
> deb package via `make pbs-api-types-deb` from the repo base folder (or
> in general `make <crate>-deb`). The install it via `dpkg -i build/
> <pkg>.deb`.
>
> And in the `proxmox-backup` repo make sure to run a `cargo clean` after
> that.
>
>
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 12+ 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
2025-10-29 16:02 ` [pbs-devel] superseded: [PATCH proxmox{, -backup} 0/4] unmount datastores after sync job Hannes Laimer
4 siblings, 1 reply; 12+ 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] 12+ 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; 12+ 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] 12+ 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
2025-10-29 16:02 ` [pbs-devel] superseded: [PATCH proxmox{, -backup} 0/4] unmount datastores after sync job Hannes Laimer
4 siblings, 1 reply; 12+ 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] 12+ 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; 12+ 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] 12+ messages in thread
* [pbs-devel] superseded: [PATCH proxmox{, -backup} 0/4] unmount datastores after sync job
2025-10-14 11:53 [pbs-devel] [PATCH proxmox{, -backup} 0/4] unmount datastores after sync job Hannes Laimer
` (3 preceding siblings ...)
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-29 16:02 ` Hannes Laimer
4 siblings, 0 replies; 12+ messages in thread
From: Hannes Laimer @ 2025-10-29 16:02 UTC (permalink / raw)
To: pbs-devel
superseded-by:
https://lore.proxmox.com/pbs-devel/20251029160103.241780-1-h.laimer@proxmox.com/T/#t
On 10/14/25 13:54, Hannes Laimer wrote:
> Adds the option to automatically unmount a datastore after a sync job
> finishes.
>
> The idea is that, in combination with run-on-mount, it is possible to
> have datastores sync to external drives without the need to open the web
> ui or terminal. This came up a handful of times in support and a recent
> thread on the forum. Basically, also non-tech people could be tasked
> with plugging and unplugging different drives regularly and mounting,
> sync and unmounting would be done automatically.
>
> Currently if any of the triggered jobs have the 'unmount-on-done' flag
> set the datastore will be unmounted right after the last of the
> triggered jobs finishes.
>
> This seemed pretty straight forward and should be good in most use-cases
> I came up with. Also, I did consider having 'unmount-on-done' also for
> normally(schedule/manual) started jobs, I guess there could be some
> situations where that might useful. But, as I mentioned on the commit
> itself, we'd probably have to go through the command socket since sync jobs run
> on the proxy. And I did not think it adds that much, also not sure if
> we'd even want that.
>
> proxmox:
>
> Hannes Laimer (1):
> pbs-api-types: add 'unmount-on-done' field to sync job config
>
> pbs-api-types/src/jobs.rs | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
>
> proxmox-backup:
>
> Hannes Laimer (3):
> api: syncjob: correctly update/delete 'unmount-on-done' field
> api: datastore: unmount datastore after sync if configured
> ui: add 'unmount-on-done' field to SyncJobEdit window
>
> src/api2/admin/datastore.rs | 21 +++++++++++++++++++--
> src/api2/config/sync.rs | 8 ++++++++
> www/window/SyncJobEdit.js | 23 +++++++++++++++++++++++
> 3 files changed, 50 insertions(+), 2 deletions(-)
>
>
> Summary over all repositories:
> 4 files changed, 58 insertions(+), 2 deletions(-)
>
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 12+ messages in thread