Compare commits

..

35 Commits

Author SHA1 Message Date
matthias 238d64f785 Update jenkins/default_backup.yml 2026-06-12 22:52:28 +02:00
matthias 8c7b633323 Update jenkins/default_backup.yml 2026-06-12 22:51:20 +02:00
matthias 4990d39810 Update jenkins/default_backup.yml 2026-06-12 22:22:49 +02:00
matthias d62ba26215 updated db script afte rdefault script 2026-05-31 21:38:02 +02:00
matthias 3c823a0135 removed the forced NAME fill-in 2026-05-31 21:34:57 +02:00
matthias b7367ae30c re-organised the default script to use a name instead of the directory directly 2026-05-31 21:22:10 +02:00
matthias 4d062fd626 jk 2026-05-31 19:00:09 +02:00
matthias cce4be576e docker errors 2026-05-31 18:54:21 +02:00
matthias 55a9cffe6a syntax 2026-05-31 18:49:08 +02:00
matthias e23cc9eca0 further tweaking 2026-05-31 18:48:31 +02:00
matthias 92dbce1d8b syntax error 2026-05-31 18:42:33 +02:00
matthias 41bfbe92ff db script rebuild 2026-05-31 18:39:31 +02:00
matthias f11884e91f Update jenkins/backupWinschoten.yml 2026-05-25 15:20:28 +02:00
matthias 0c1f2cb464 Update jenkins/backupDavid.yml 2026-05-25 15:18:06 +02:00
matthias 326f919ef9 Update jenkins/backupDavid.yml 2026-05-25 15:07:39 +02:00
matthias 2887e2f15b fixed error handling for winschoten, too 2026-05-13 08:26:06 +02:00
matthias c787fb51e2 added error handling 2026-05-13 08:24:06 +02:00
matthias 1bd54edc93 renamed backup_yesterday to backup_previous 2026-05-13 08:21:45 +02:00
matthias b06d155d48 fixed error in winschoten storage location 2026-05-13 08:09:04 +02:00
matthias 8bd4acd531 twaeaked nextcloud database script to run CP commands in ssh 2026-05-13 08:03:35 +02:00
matthias bbb7ceb332 added agent name to ssh mount 2026-05-08 20:52:07 +02:00
matthias 0314d00426 m, 2026-05-08 20:33:28 +02:00
matthias be4ecdb674 lk;;k;lk 2026-05-08 20:32:45 +02:00
matthias 38138dfed4 jk 2026-05-08 20:31:50 +02:00
matthias f1114cd2bb fixed sshfs 2026-05-08 20:30:15 +02:00
matthias 5e71088b97 identifyfile added 2026-05-08 20:24:20 +02:00
matthias 3e18c39e68 jk 2026-05-08 19:16:17 +02:00
matthias 836ff078e0 kl 2026-05-08 19:15:44 +02:00
matthias 67a0604a01 root 2026-05-08 19:15:18 +02:00
matthias aace7a4f86 wrong storage location 2026-05-08 19:11:32 +02:00
matthias b2b1b4e056 fixed winschoten file 2026-05-08 17:32:09 +02:00
matthias 10627b100e fixed 2026-05-08 16:31:22 +02:00
matthias a228f0f340 / gone 2026-05-08 14:49:32 +02:00
matthias 7a83abe6d3 test 2026-05-08 14:48:53 +02:00
matthias 7634efd863 paranthesis 2026-05-08 14:46:12 +02:00
5 changed files with 77 additions and 67 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ pipeline {
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/"
sh "rsync -v -a -e 'ssh -p 664' --delete --bwlimit=3000 --info=progress2 ${env.julienbackuplocation} matthias@home.daf2000.nl:/media/disk/backup_julien"
}
}
}
+4 -2
View File
@@ -4,8 +4,10 @@ pipeline {
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/"
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.julienbackuplocation} backupwinschoten@localhost:/storage/backup_julien"
}
}
}
}
+19 -7
View File
@@ -1,27 +1,39 @@
pipeline {
parameters {
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')
booleanParam(name: 'UseLocationPrefix', defaultValue: params.UseLocationPrefix ?: false, description: 'Use the environmental storage (FROM directory) location')
string(name: 'directory', defaultValue: params.directory ?: ' ', description: 'The directory that should be handled - either at the environmental location or fill in a custom absolute path')
string(name: 'name', defaultValue: params.name ?: ' ', description: 'The name of the job/repository 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'
from_dir = "${directory}"
to_dir = "${env.borglocation}" + "/" + "${name}"
backdirectory = "${directory}"
}
stages {
stage('Run Information') {
stage('Run Preparation') {
steps {
echo "Backing up directory ${directoryPrefix}/${directory}"
sh "echo '${params.excludelist}' >> excludelist"
script {
if (params.UseLocationPrefix) {
from_dir = env.storagelocation + "/" + "${name}"
}
sh "echo 'Backing up directory ${from_dir} to ${to_dir}'"
sh "echo '${params.excludelist}' >> excludelist"
}
}
}
stage('Create local BorgBackup') {
steps {
script {
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}"
sh "borg create --progress --stats --exclude-from excludelist ${to_dir}::${java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern('dd-MM-yyyy_HH:mm'))} ${from_dir}"
sh "borg prune --list --keep-daily 31 --keep-weekly 48 ${to_dir}"
}
}
}
}
+19 -57
View File
@@ -1,76 +1,38 @@
pipeline {
agent any
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 - either at the environmental location or fill in a custom absolute path')
string(name: 'name', defaultValue: params.name ?: ' ', description: 'The name of the job/repository that should be handled')
string(name: 'agentname', defaultValue: params.agentname ?: 'julien', description: 'The agent to run this backup on')
}
environment {
BORG_RELOCATED_REPO_ACCESS_IS_OK = 'yes'
from_dir = "${directory}"
to_dir = "${env.borglocation}" + "/" + "${name}"
}
stages {
stage('Run Information') {
steps {
echo "Local BORG backup creation is ${params.backuplocally}"
echo "Backup to David is ${params.backuptodavid}"
echo "Backup to Winschoten PI is ${params.backuptowinschoten}"
}
}
stage('Run MariaDB') {
agent {
docker {
image 'mariadb:latest'
args "--volumes-from=jenkins -v /srv/dev-disk-by-uuid-27fc012e-a1fa-4c7c-9dad-82770888cd03/nextcloud_backup/database_dump:/data/ --entrypoint=''"
args "-v '${from_dir}':/data/ --entrypoint=''"
reuseNode false
}
}
steps {
script {
if (params.backuplocally) {
sh "yes | cp -rf /data/backup_yesterday.dmp /data/backup_early.dmp 2>/dev/null || :"
sh "yes | cp -rf /data/backup_latest.dmp /data/backup_yesterday.dmp 2>/dev/null || :"
sh "mariadb-dump -u nextcloud -h 10.10.1.32 --all-databases -ppassword -v > /data/backup_latest.dmp"
} else {
echo "Local backup creation is skipped"
}
}
}
}
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"
}
}
}
sh "mariadb-dump -u nextcloud -h 10.10.1.32 --all-databases -ppassword -v > /data/nextcloud_database.dmp"
stage('Rsync Backup in Parallel') {
failFast false
parallel {
stage ('Run Backup to David') {
steps {
script {
if (params.backuptodavid) {
sh "yes | cp -rf matthias@home.daf2000.nl:/media/disk/nextcloudbackup/database_dump/backup_yesterday.dmp matthias@home.daf2000.nl:/media/disk/nextcloudbackup/database_dump/backup_early.dmp 2>/dev/null || :"
sh "yes | cp -rf matthias@home.daf2000.nl:/media/disk/nextcloudbackup/database_dump/backup_latest.dmp matthias@home.daf2000.nl:/media/disk/nextcloudbackup/database_dump/backup_yesterday.dmp 2>/dev/null || :"
sh "rsync -v -a -e 'ssh -p 664' --delete --bwlimit=3000 --info=progress2 --exclude='.*' /srv/dev-disk-by-uuid-27fc012e-a1fa-4c7c-9dad-82770888cd03/nextcloud_backup/database_dump/ matthias@home.daf2000.nl:/media/disk/nextcloudbackup/database_dump/"
} 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"
}
}
}
}
stage('Create local BorgBackup') {
steps {
script {
withCredentials([string(credentialsId: 'cbce976a-0d98-4f35-8ea2-1f7818931bc3', variable: 'BORG_PASSPHRASE')]) {
sh "borg create --progress --stats ${to_dir}::${java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern('dd-MM-yyyy_HH:mm'))} ${from_dir}"
sh "borg prune --list --keep-daily 31 --keep-weekly 48 ${to_dir}"
sh "rm -rf ${from_dir}"
}
}
}
+34
View File
@@ -0,0 +1,34 @@
pipeline {
parameters {
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')
}
agent { label params['agentname'] }
environment {
BORG_RELOCATED_REPO_ACCESS_IS_OK = 'yes'
}
stages {
stage('Run Preparation') {
steps {
echo "Backing up directory ${directory}"
sh "echo '${params.excludelist}' >> excludelist"
}
}
stage('Create local BorgBackup') {
steps {
script {
sh "mkdir -p ${WORKSPACE}/tmpmount"
sh "sshfs -o IdentityFile=/home/pi/.ssh/id_rsa root@10.10.1.32:/${env.borglocation}/ ${WORKSPACE}/tmpmount"
withCredentials([string(credentialsId: 'cbce976a-0d98-4f35-8ea2-1f7818931bc3', variable: 'BORG_PASSPHRASE')]) {
sh "borg create --progress --stats --exclude-from excludelist ${WORKSPACE}/tmpmount/${agentname}_${directory}::${java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern('dd-MM-yyyy_HH:mm'))} /${directory}"
sh "borg prune --list --keep-daily 31 --keep-weekly 48 ${WORKSPACE}/tmpmount/${agentname}_${directory}"
}
}
}
}
}
}