From: Robert Obkircher <r.obkircher@proxmox.com>
To: Christian Ebner <c.ebner@proxmox.com>
Cc: pbs-devel@lists.proxmox.com
Subject: Re: [PATCH proxmox-backup 21/28] sync: pull: allow to set retention timestamp for synced snapshots
Date: Wed, 09 Sep 2026 14:32:04 +0200 [thread overview]
Message-ID: <178895712462.166875.8747321609651298391.b4-review@b4> (raw)
In-Reply-To: <20260813171002.809441-22-c.ebner@proxmox.com>
> Allow the pull sync job to set the retention timestamp when pulling
> the snapshot from the remote.
>
> The timestamp is calculated based on the start time of the sync job
> by pull parameter construction.
>
> Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
>
> diff --git a/src/api2/pull.rs b/src/api2/pull.rs
> index 6b53c55b7..c197c161f 100644
> --- a/src/api2/pull.rs
> +++ b/src/api2/pull.rs
> @@ -10,8 +10,8 @@ use pbs_api_types::{
> Authid, BackupNamespace, CRYPT_KEY_ID_SCHEMA, DATASTORE_SCHEMA, GROUP_FILTER_LIST_SCHEMA,
> GroupFilter, NS_MAX_DEPTH_REDUCED_SCHEMA, PRIV_DATASTORE_APPEND, PRIV_DATASTORE_BACKUP,
> PRIV_DATASTORE_PRUNE, PRIV_REMOTE_READ, REMOTE_ID_SCHEMA, REMOVE_VANISHED_BACKUPS_SCHEMA,
> - RESYNC_CORRUPT_SCHEMA, RateLimitConfig, SYNC_ENCRYPTED_ONLY_SCHEMA, SYNC_VERIFIED_ONLY_SCHEMA,
> - SYNC_WORKER_THREADS_SCHEMA, SyncJobConfig, TRANSFER_LAST_SCHEMA,
> + RESYNC_CORRUPT_SCHEMA, RateLimitConfig, RetentionTimespan, SYNC_ENCRYPTED_ONLY_SCHEMA,
> + SYNC_VERIFIED_ONLY_SCHEMA, SYNC_WORKER_THREADS_SCHEMA, SyncJobConfig, TRANSFER_LAST_SCHEMA,
> };
> use pbs_config::CachedUserInfo;
> use proxmox_rest_server::WorkerTask;
> @@ -93,6 +93,7 @@ impl TryFrom<&SyncJobConfig> for PullParameters {
> sync_job.resync_corrupt,
> sync_job.worker_threads,
> sync_job.associated_key.clone(),
> + sync_job.retention_timespan.clone(),
> )
> }
> }
> @@ -162,6 +163,10 @@ impl TryFrom<&SyncJobConfig> for PullParameters {
> },
> optional: true,
> },
> + "retention-timespan": {
> + type: RetentionTimespan,
> + optional: true,
> + },
> },
> },
> access: {
> @@ -191,6 +196,7 @@ async fn pull(
> resync_corrupt: Option<bool>,
> worker_threads: Option<usize>,
> decryption_keys: Option<Vec<String>>,
> + retention_timespan: Option<RetentionTimespan>,
> rpcenv: &mut dyn RpcEnvironment,
> ) -> Result<String, Error> {
> let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
> @@ -233,6 +239,7 @@ async fn pull(
> resync_corrupt,
> worker_threads,
> decryption_keys,
> + retention_timespan,
> )?;
>
> // fixme: set to_stdout to false?
> diff --git a/src/server/pull.rs b/src/server/pull.rs
> index 856e0fc5a..816e64ce7 100644
> --- a/src/server/pull.rs
> +++ b/src/server/pull.rs
> @@ -23,7 +23,7 @@ use pbs_api_types::{
> ArchiveType, Authid, BackupDir, BackupGroup, BackupNamespace, CLIENT_LOG_BLOB_NAME, CryptMode,
> Fingerprint, GroupFilter, MANIFEST_BLOB_NAME, MAX_NAMESPACE_DEPTH, Operation,
> PRIV_DATASTORE_APPEND, PRIV_DATASTORE_AUDIT, PRIV_DATASTORE_BACKUP, RateLimitConfig, Remote,
> - SnapshotListItem, VerifyState, print_store_and_ns,
> + RetentionTimespan, SnapshotListItem, VerifyState, print_store_and_ns,
> };
> use pbs_client::BackupRepository;
> use pbs_config::CachedUserInfo;
> @@ -77,6 +77,9 @@ pub(crate) struct PullParameters {
> worker_threads: Option<usize>,
> /// Decryption key ids and configs to decrypt snapshots with matching key fingerprint
> crypt_configs: Vec<(String, Arc<CryptConfig>)>,
> + // Retention timestamp to be set for newly pulled snapshots on sync target, overwrites
> + // existing retentions if present on source manifest.
> + retain_until: Option<i64>,
> }
>
> impl PullParameters {
> @@ -99,6 +102,7 @@ impl PullParameters {
> resync_corrupt: Option<bool>,
> worker_threads: Option<usize>,
> decryption_keys: Option<Vec<String>>,
> + retention_timespan: Option<RetentionTimespan>,
> ) -> Result<Self, Error> {
> if let Some(max_depth) = max_depth {
> ns.check_max_depth(max_depth)?;
> @@ -140,6 +144,10 @@ impl PullParameters {
>
> let group_filter = group_filter.unwrap_or_default();
>
> + let retain_until = retention_timespan
> + .map(|timespan| timespan.to_timestamp_from_systemtime())
> + .transpose()?;
> +
> let crypt_configs = if let Some(key_ids) = &decryption_keys {
> let mut crypt_configs = Vec::with_capacity(key_ids.len());
> for key_id in key_ids {
> @@ -165,6 +173,7 @@ impl PullParameters {
> resync_corrupt,
> worker_threads,
> crypt_configs,
> + retain_until,
> })
> }
> }
> @@ -768,7 +777,14 @@ async fn pull_snapshot<'a>(
> )
> .await?
> {
> - (None, false) => (None, None), // regular pull without decryption
> + (None, false) => {
> + let new_manifest = if params.retain_until.is_some() {
> + Some(Arc::new(Mutex::new(BackupManifest::new(snapshot.into()))))
> + } else {
> + None
> + };
Bug: BackupManifest::new does not copy the list of files and
pull_single_archive currently only calls add_to_decrypted_manifest for
the encrypted case. (I noticed that the files list in the manifest was
empty after getting "refusing to overwrite local snapshot: content
differs from source" in a repeated pull sync, where I had manually
removed the retention timestamp of the target.)
Other thoughts:
If the manifest already contains a retain_until but the param is None,
do we just keep using the old value? Do we need a max retention check
in that case or is it safe to trust the manifest?
Further up in this method there are also a fast paths for
`manifest_blob.raw_data() == tmp_manifest_blob.raw_data()` and
`ignore_not_verified_or_encrypted`. If you pull sync with a newly added
retain_until parameter it will be effectively ignored in those cases,
which may be unexpected.
I wonder if it would make sense to store a duration instead of a
timestamp. If we then interpret it relative to mtime that would
automatically "renew" on every sync without manifest modifications.
--
Robert Obkircher <r.obkircher@proxmox.com>
next prev parent reply other threads:[~2026-09-09 12:32 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 17:09 [PATCH proxmox{,-backup} 00/28] append-only sync jobs and snapshot retention timespan Christian Ebner
2026-08-13 17:09 ` [PATCH proxmox 01/28] pbs-api-types: add append only permission and role Christian Ebner
2026-09-09 12:24 ` Robert Obkircher
2026-08-13 17:09 ` [PATCH proxmox 02/28] pbs-api-types: add remote datastore append privs " Christian Ebner
2026-09-09 12:24 ` Robert Obkircher
2026-08-13 17:09 ` [PATCH proxmox 03/28] pbs-api-types: extend snapshot list items by retention timestamp Christian Ebner
2026-08-13 17:09 ` [PATCH proxmox 04/28] pbs-api-types: extend sync job config by retention-timespan parameter Christian Ebner
2026-08-13 17:09 ` [PATCH proxmox 05/28] pbs-api-types: add maximum retention timespan property to datastore Christian Ebner
2026-08-13 17:09 ` [PATCH proxmox-backup 06/28] api: config: extend sync job config by new retention-timespan Christian Ebner
2026-08-13 17:09 ` [PATCH proxmox-backup 07/28] api: admin: improve code style for status endpoint Christian Ebner
2026-08-13 17:09 ` [PATCH proxmox-backup 08/28] client: avoid error in status if user lacks permissions Christian Ebner
2026-08-13 17:09 ` [PATCH proxmox-backup 09/28] server: allow iterating contents for Datastore.Append permissions Christian Ebner
2026-08-13 17:09 ` [PATCH proxmox-backup 10/28] api: backup: fix possible information leak in multi-tenant datastores Christian Ebner
2026-08-13 17:09 ` [PATCH proxmox-backup 11/28] api: backup: allow backup for user/token with append permission Christian Ebner
2026-08-13 17:09 ` [PATCH proxmox-backup 12/28] api: allow namespace creation on append permissions Christian Ebner
2026-08-13 17:09 ` [PATCH proxmox-backup 13/28] api: sync: allow pull to target for user/token with append permission Christian Ebner
2026-08-13 17:09 ` [PATCH proxmox-backup 14/28] sync: pull: allow pulling " Christian Ebner
2026-09-09 12:32 ` Robert Obkircher
2026-08-13 17:09 ` [PATCH proxmox-backup 15/28] sync: push: allow push and ns creation on Remote.DatastoreAppend Christian Ebner
2026-08-13 17:09 ` [PATCH proxmox-backup 16/28] datastore: conditionally treat missing manifest as error or bening Christian Ebner
2026-09-09 12:32 ` Robert Obkircher
2026-08-13 17:09 ` [PATCH proxmox-backup 17/28] api: backup: provide retain-until timestamp for extended prune protection Christian Ebner
2026-09-09 12:32 ` Robert Obkircher
2026-08-13 17:09 ` [PATCH proxmox-backup 18/28] tools: include retain-until timestamp in snapshot list items Christian Ebner
2026-08-13 17:09 ` [PATCH proxmox-backup 19/28] client: backup writer: allow to send retain-until timestamp on backup Christian Ebner
2026-08-13 17:09 ` [PATCH proxmox-backup 20/28] sync: push: allow to set retention timestamp for synced snapshots Christian Ebner
2026-08-13 17:09 ` [PATCH proxmox-backup 21/28] sync: pull: " Christian Ebner
2026-09-09 12:32 ` Robert Obkircher [this message]
2026-08-13 17:09 ` [PATCH proxmox-backup 22/28] sync: pull: protect retained snapshot from being overwritten Christian Ebner
2026-09-09 12:32 ` Robert Obkircher
2026-08-13 17:09 ` [PATCH proxmox-backup 23/28] api: config: allow to set or delete reteniton timespan for sync jobs Christian Ebner
2026-08-13 17:09 ` [PATCH proxmox-backup 24/28] ui: add retention timespan form and use it for sync job edit window Christian Ebner
2026-09-09 12:32 ` Robert Obkircher
2026-08-13 17:09 ` [PATCH proxmox-backup 25/28] datastore/config: parse and enforce maximum retention timespan Christian Ebner
2026-08-13 17:10 ` [PATCH proxmox-backup 26/28] ui: allow datastore wide max retention timespan configuration Christian Ebner
2026-08-13 17:10 ` [PATCH proxmox-backup 27/28] api: admin: allow to update snapshot retention for root user Christian Ebner
2026-09-09 12:32 ` Robert Obkircher
2026-08-13 17:10 ` [PATCH proxmox-backup 28/28] ui: show retention in datastore contents 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=178895712462.166875.8747321609651298391.b4-review@b4 \
--to=r.obkircher@proxmox.com \
--cc=c.ebner@proxmox.com \
--cc=pbs-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox