Added conditions for all backup steps
This commit is contained in:
@@ -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,8 +23,14 @@ pipeline {
|
|||||||
}
|
}
|
||||||
stage('Create local BorgBackup'){
|
stage('Create local BorgBackup'){
|
||||||
steps {
|
steps {
|
||||||
withCredentials([string(credentialsId: 'cbce976a-0d98-4f35-8ea2-1f7818931bc3', variable: 'BORG_PASSPHRASE')]) {
|
script {
|
||||||
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}"
|
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 {
|
steps {
|
||||||
sh "mkdir -p /config/rclone"
|
script {
|
||||||
sh "cp ${WORKSPACE}/config/rclone.conf /config/rclone/"
|
if (params.backuptostackstorage) {
|
||||||
sh "rclone copy -v /data/ stackstorage:/julien/storage/${directory}"
|
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') {
|
stage('Run Rsync to David') {
|
||||||
|
|||||||
Reference in New Issue
Block a user