Added conditions for all backup steps
This commit is contained in:
@@ -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,9 +23,15 @@ pipeline {
|
||||
}
|
||||
stage('Create local BorgBackup'){
|
||||
steps {
|
||||
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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Run rclone') {
|
||||
@@ -35,9 +43,15 @@ pipeline {
|
||||
}
|
||||
}
|
||||
steps {
|
||||
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') {
|
||||
|
||||
Reference in New Issue
Block a user