Compare commits

...

10 Commits

Author SHA1 Message Date
matthias 2525f60fa1 syntax 2026-05-08 13:36:54 +02:00
matthias 7b3d843ea1 fixed ending 2026-05-08 13:36:08 +02:00
matthias 4680942268 trying something new 2026-05-08 13:23:19 +02:00
matthias 00a769135d finally fixed 2026-05-08 12:49:18 +02:00
matthias 8db818ab8a jk 2026-05-08 12:46:17 +02:00
matthias 12ad5c285f stringname ficx 2026-05-08 12:43:35 +02:00
matthias 62aae741ce fixed parameter 2026-05-08 12:42:17 +02:00
matthias 7a3fbd64b3 added parameter agent 2026-05-08 12:40:04 +02:00
matthias e6d25bff2d Merge branch 'main' of https://git.mitscherlich.nl/matthias/backup 2026-05-08 12:37:34 +02:00
matthias b17a219a4d cleanup 2026-05-08 12:37:24 +02:00
3 changed files with 33 additions and 105 deletions
+12
View File
@@ -0,0 +1,12 @@
pipeline {
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/"
}
}
}
}
}
+14
View File
@@ -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/"
}
}
}
}
}
+6 -104
View File
@@ -1,127 +1,29 @@
pipeline {
agent any
parameters {
booleanParam(name: 'backuplocally', defaultValue: params.backuplocally ?: 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: 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')
}
agent { label params['agentname'] }
environment {
BORG_RELOCATED_REPO_ACCESS_IS_OK = 'yes'
}
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 TransIP Stack is ${params.backuptostackstorage}"
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('Getting RClone Configuration') {
steps {
configFileProvider([configFile(fileId: 'e0237193-1245-452e-b035-9d3d501f4c1b', variable: 'rclone_config')]) {
sh "mkdir -p ${WORKSPACE}/config"
sh "cp ${rclone_config} ${WORKSPACE}/config/rclone.conf"
}
}
}
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('Run rclone') {
// agent {
// docker {
// image 'rclone/rclone'
// args "--volumes-from=jenkins -v ${env.storagelocation}/${directory}/:/data/ --entrypoint=''"
// reuseNode true
// }
// }
// 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} --exclude-from excludelist"
// } else {
// echo "Backup to TransIP Stack is skipped"
// }
// }
// }
// }
stage('Rsync TEST') {
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"
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}"
}
}
}
}
}
}
// stage('Run Rsync 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 Rsync 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 External PI is skipped"
// }
// }
// }
// }
}
}