From f2fae8f9b7325e40bd6c9063b83934e01d588706 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 11 Jan 2026 10:48:23 +0100 Subject: [PATCH] Added conditions for all backup steps --- jenkins/default_backup.yml | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/jenkins/default_backup.yml b/jenkins/default_backup.yml index 618d98e..922eb39 100644 --- a/jenkins/default_backup.yml +++ b/jenkins/default_backup.yml @@ -1,8 +1,10 @@ pipeline { agent any parameters { - booleanParam(name: 'backuptodavid', defaultValue: false, description: 'Checked = true. Unchecked = false') - booleanParam(name: 'backuptopi', defaultValue: false, description: 'Checked = true. Unchecked = false') + booleanParam(name: 'backuplocally', defaultValue: false, description: 'If true local BORG backup will be created') + booleanParam(name: 'backuptostackstorage', defaultValue: false, description: 'If true backup data to TransIP Stack') + booleanParam(name: 'backuptodavid', defaultValue: false, description: 'If true rsync the BORG repository to David') + booleanParam(name: 'backuptopi', defaultValue: false, description: 'If true rsync the BORG repository to our ExternalPI') } stages { stage('Run Information') { @@ -21,8 +23,14 @@ pipeline { } stage('Create local BorgBackup'){ steps { - withCredentials([string(credentialsId: 'cbce976a-0d98-4f35-8ea2-1f7818931bc3', variable: 'BORG_PASSPHRASE')]) { - sh "borg create --progress --stats ${env.borglocation}/${directory}::${java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern('dd-MM-yyyy_HH:mm'))} ${env.storagelocation}/${directory}" + script { + if (params.backuplocally) { + withCredentials([string(credentialsId: 'cbce976a-0d98-4f35-8ea2-1f7818931bc3', variable: 'BORG_PASSPHRASE')]) { + sh "borg create --progress --stats ${env.borglocation}/${directory}::${java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern('dd-MM-yyyy_HH:mm'))} ${env.storagelocation}/${directory}" + } + } else { + echo "Local BORG backup creation is skipped" + } } } } @@ -35,9 +43,15 @@ pipeline { } } steps { - sh "mkdir -p /config/rclone" - sh "cp ${WORKSPACE}/config/rclone.conf /config/rclone/" - sh "rclone copy -v /data/ stackstorage:/julien/storage/${directory}" + script { + if (params.backuptostackstorage) { + sh "mkdir -p /config/rclone" + sh "cp ${WORKSPACE}/config/rclone.conf /config/rclone/" + sh "rclone copy -v /data/ stackstorage:/julien/storage/${directory}" + } else { + echo "Backup to TransIP Stack is skipped" + } + } } } stage('Run Rsync to David') {