Merge branch 'newtry'
# Conflicts: # jenkins/default_backup.yml
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
pipeline {
|
||||
parameters {
|
||||
booleanParam(name: 'backuplocally', defaultValue: params.backuplocally ?: false, description: 'If true local BORG backup will be created')
|
||||
booleanParam(name: 'backuptodavid', defaultValue: params.backuptodavid ?: false, description: 'If true rsync the BORG repository to David')
|
||||
booleanParam(name: 'backuptowinschoten', defaultValue: params.backuptowinschoten ?: false, description: 'If true rsync the BORG repository to our Winschoten backup system')
|
||||
string(name: 'directoryPrefix', defaultValue: params.directoryPrefix ?: '${env.borglocation}/', description: 'The directory prefix that should be handled')
|
||||
string(name: 'directory', defaultValue: params.directory ?: ' ', description: 'The directory that should be handled')
|
||||
string(name: 'agentname', defaultValue: params.agentname ?: 'julien', description: 'The agent to run this backup on')
|
||||
text(name: 'excludelist', defaultValue: params.excludelist ?: '**/cache/** ', description: 'Multiline string to exclude patterns from backup')
|
||||
@@ -12,58 +10,18 @@ pipeline {
|
||||
BORG_RELOCATED_REPO_ACCESS_IS_OK = 'yes'
|
||||
}
|
||||
stages {
|
||||
stage('Run Information') {
|
||||
stage('Run Information') {
|
||||
steps {
|
||||
script { env.backuptostackstorage = false }
|
||||
echo "Backing up directory ${env.storagelocation}/${directory}"
|
||||
echo "Local BORG backup creation is ${params.backuplocally}"
|
||||
echo "Backup to David is ${params.backuptodavid}"
|
||||
echo "Backup to Winschoten PI is ${params.backuptowinschoten}"
|
||||
echo "Backing up directory ${directoryPrefix}/${directory}"
|
||||
sh "echo '${params.excludelist}' >> excludelist"
|
||||
}
|
||||
}
|
||||
stage('Create local BorgBackup'){
|
||||
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 --exclude-from excludelist ${env.borglocation}/${directory}::${java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern('dd-MM-yyyy_HH:mm'))} ${env.storagelocation}/${directory}"
|
||||
sh "borg prune --list --keep-daily 31 --keep-weekly 48 ${env.borglocation}/${directory}"
|
||||
}
|
||||
} else {
|
||||
echo "Local BORG backup creation is skipped"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Rsync Backup in Parallel') {
|
||||
failFast false
|
||||
parallel {
|
||||
stage ('Run Backup to David') {
|
||||
steps {
|
||||
script {
|
||||
if (params.backuptodavid) {
|
||||
sh "rsync -v -a -e 'ssh -p 664' --delete --bwlimit=3000 --info=progress2 ${env.borglocation}/${directory} matthias@home.daf2000.nl:/media/disk/borgbackups/"
|
||||
} else {
|
||||
echo "Backup to David is skipped"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage ('Run Backup to Winschoten') {
|
||||
steps {
|
||||
script {
|
||||
if (params.backuptowinschoten) {
|
||||
withCredentials([sshUserPrivateKey(credentialsId: 'backupwinschoten', keyFileVariable: 'keyfile', passphraseVariable: 'passphrase', usernameVariable: 'user')]) {
|
||||
sh "cp ${keyfile} ${WORKSPACE}/keyfile"
|
||||
sh "rsync -v -a -e 'ssh -i /home/backupwinschoten/.ssh/id_rsa -p 9897' --delete --info=progress2 ${env.borglocation}/${directory} backupwinschoten@localhost:/storage/borgbackups/"
|
||||
}
|
||||
} else {
|
||||
echo "Backup to Winschoten is skipped"
|
||||
}
|
||||
}
|
||||
}
|
||||
withCredentials([string(credentialsId: 'cbce976a-0d98-4f35-8ea2-1f7818931bc3', variable: 'BORG_PASSPHRASE')]) {
|
||||
sh "borg create --progress --stats --exclude-from excludelist ${directoryPrefix}/${directory}::${java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern('dd-MM-yyyy_HH:mm'))} ${directoryPrefix}/${directory}"
|
||||
sh "borg prune --list --keep-daily 31 --keep-weekly 48 ${directoryPrefix}/${directory}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user