From 61ef4ae8cbac4c2d0fcf53b8ef5d7459db79e41d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Thu, 28 Oct 2021 15:00:58 +0200 Subject: [PATCH] fix #sync.cfg/pull: don't remove by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and convert existing (manually created/edited) jobs to the previous default value of 'true'. the GUI has always set this value and defaults to 'false'. Signed-off-by: Fabian Grünbichler Reviewed-by: Dominik Csapak Signed-off-by: Thomas Lamprecht --- debian/postinst | 31 +++++++++++++++++++++++++++++++ pbs-api-types/src/jobs.rs | 2 +- src/api2/pull.rs | 2 +- src/server/pull.rs | 2 +- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/debian/postinst b/debian/postinst index 83352853..af290069 100644 --- a/debian/postinst +++ b/debian/postinst @@ -4,6 +4,14 @@ set -e #DEBHELPER# +update_sync_job() { + job="$1" + + echo "Updating sync job '$job' to make old 'remove-vanished' default explicit.." + proxmox-backup-manager sync-job update "$job" --remove-vanished true \ + || echo "Failed, please check sync.cfg manually!" +} + case "$1" in configure) # need to have user backup in the tape group @@ -32,6 +40,29 @@ case "$1" in echo "Fixing up termproxy user id in task log..." flock -w 30 /var/log/proxmox-backup/tasks/active.lock sed -i 's/:termproxy::\([^@]\+\): /:termproxy::\1@pam: /' /var/log/proxmox-backup/tasks/active || true fi + + if dpkg --compare-versions "$2" 'lt' '7.1-1' && test -e /etc/proxmox-backup/sync.cfg; then + prev_job="" + + # read from HERE doc because POSIX sh limitations + while read -r key value; do + if test "$key" = "sync:"; then + if test -n "$prev_job"; then + # previous job doesn't have an explicit value + update_sync_job "$prev_job" + fi + prev_job=$value + else + prev_job="" + fi + done < Result { let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; - let delete = remove_vanished.unwrap_or(true); + let delete = remove_vanished.unwrap_or(false); check_pull_privs(&auth_id, &store, &remote, &remote_store, delete)?; diff --git a/src/server/pull.rs b/src/server/pull.rs index 63bf92b4..e34ac891 100644 --- a/src/server/pull.rs +++ b/src/server/pull.rs @@ -57,7 +57,7 @@ impl PullParameters { let (remote_config, _digest) = pbs_config::remote::config()?; let remote: Remote = remote_config.lookup("remote", remote)?; - let remove_vanished = remove_vanished.unwrap_or(true); + let remove_vanished = remove_vanished.unwrap_or(false); let source = BackupRepository::new( Some(remote.config.auth_id.clone()),