Added conditions for all backup steps

This commit is contained in:
2026-01-11 10:48:23 +01:00
parent eb6fb61f19
commit f2fae8f9b7

View File

@@ -1,8 +1,10 @@
pipeline { pipeline {
agent any agent any
parameters { parameters {
booleanParam(name: 'backuptodavid', defaultValue: false, description: 'Checked = true. Unchecked = false') booleanParam(name: 'backuplocally', defaultValue: false, description: 'If true local BORG backup will be created')
booleanParam(name: 'backuptopi', defaultValue: false, description: 'Checked = true. Unchecked = false') 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 { stages {
stage('Run Information') { stage('Run Information') {
@@ -21,9 +23,15 @@ pipeline {
} }
stage('Create local BorgBackup'){ stage('Create local BorgBackup'){
steps { steps {
script {
if (params.backuplocally) {
withCredentials([string(credentialsId: 'cbce976a-0d98-4f35-8ea2-1f7818931bc3', variable: 'BORG_PASSPHRASE')]) { 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}" 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"
}
}
} }
} }
stage('Run rclone') { stage('Run rclone') {
@@ -35,9 +43,15 @@ pipeline {
} }
} }
steps { steps {
script {
if (params.backuptostackstorage) {
sh "mkdir -p /config/rclone" sh "mkdir -p /config/rclone"
sh "cp ${WORKSPACE}/config/rclone.conf /config/rclone/" sh "cp ${WORKSPACE}/config/rclone.conf /config/rclone/"
sh "rclone copy -v /data/ stackstorage:/julien/storage/${directory}" sh "rclone copy -v /data/ stackstorage:/julien/storage/${directory}"
} else {
echo "Backup to TransIP Stack is skipped"
}
}
} }
} }
stage('Run Rsync to David') { stage('Run Rsync to David') {