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 {
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') {