From 46809422683f0994577bfae6b34d5b0846bfe108 Mon Sep 17 00:00:00 2001 From: matthias Date: Fri, 8 May 2026 13:23:19 +0200 Subject: [PATCH 1/3] trying something new --- jenkins/backupDavid.yaml | 13 +++++++++ jenkins/backupWinschoten.yaml | 14 ++++++++++ jenkins/default_backup.yml | 52 ++++------------------------------- 3 files changed, 32 insertions(+), 47 deletions(-) create mode 100644 jenkins/backupDavid.yaml create mode 100644 jenkins/backupWinschoten.yaml diff --git a/jenkins/backupDavid.yaml b/jenkins/backupDavid.yaml new file mode 100644 index 0000000..2d4a4f6 --- /dev/null +++ b/jenkins/backupDavid.yaml @@ -0,0 +1,13 @@ +pipeline { + parameters { + agent any + stages { + stage ('Run Backup to David') { + steps { + script { + sh "rsync -v -a -e 'ssh -p 664' --delete --bwlimit=3000 --info=progress2 ${env.borglocation} matthias@home.daf2000.nl:/media/disk/" + } + } + } + } +} diff --git a/jenkins/backupWinschoten.yaml b/jenkins/backupWinschoten.yaml new file mode 100644 index 0000000..f634455 --- /dev/null +++ b/jenkins/backupWinschoten.yaml @@ -0,0 +1,14 @@ +pipeline { + parameters { + agent any + stages { + stage ('Run Backup to David') { + steps { + script { + sh "cp ${keyfile} ${WORKSPACE}/keyfile" + sh "rsync -v -a -e 'ssh -i /home/backupwinschoten/.ssh/id_rsa -p 9897' --delete --info=progress2 ${env.borglocation} backupwinschoten@localhost:/storage/" + } + } + } + } +} diff --git a/jenkins/default_backup.yml b/jenkins/default_backup.yml index a06861d..baa3e34 100644 --- a/jenkins/default_backup.yml +++ b/jenkins/default_backup.yml @@ -1,9 +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: 'directory', defaultValue: params.directory ?: ' ', description: 'The directory that should be handled') + string(name: 'directory', defaultValue: params.directory ?: '${env.borglocation}/', 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') } @@ -14,55 +11,16 @@ pipeline { stages { 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 ${directory}" sh "echo '${params.excludelist}' >> excludelist" } } 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/borgbackup/" - } 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 ${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 ${directory}" } } } From 7b3d843ea1bfe7130f452c2e358c04f69795361a Mon Sep 17 00:00:00 2001 From: matthias Date: Fri, 8 May 2026 13:36:08 +0200 Subject: [PATCH 2/3] fixed ending --- jenkins/{backupDavid.yaml => backupDavid.yml} | 0 jenkins/{backupWinschoten.yaml => backupWinschoten.yml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename jenkins/{backupDavid.yaml => backupDavid.yml} (100%) rename jenkins/{backupWinschoten.yaml => backupWinschoten.yml} (100%) diff --git a/jenkins/backupDavid.yaml b/jenkins/backupDavid.yml similarity index 100% rename from jenkins/backupDavid.yaml rename to jenkins/backupDavid.yml diff --git a/jenkins/backupWinschoten.yaml b/jenkins/backupWinschoten.yml similarity index 100% rename from jenkins/backupWinschoten.yaml rename to jenkins/backupWinschoten.yml From 2525f60fa1a8f2e1f4fbb602a4b40d18e4ca890a Mon Sep 17 00:00:00 2001 From: matthias Date: Fri, 8 May 2026 13:36:54 +0200 Subject: [PATCH 3/3] syntax --- jenkins/backupDavid.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/jenkins/backupDavid.yml b/jenkins/backupDavid.yml index 2d4a4f6..822a4f2 100644 --- a/jenkins/backupDavid.yml +++ b/jenkins/backupDavid.yml @@ -1,5 +1,4 @@ pipeline { - parameters { agent any stages { stage ('Run Backup to David') {