Compare commits

...

52 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
matthias e0cfde229b Update jenkins/nextcloud_database.yml 2026-05-07 10:18:56 +02:00
matthias db43d95d87 tweaky 2026-05-04 15:08:31 +02:00
matthias 5163fdbb55 tweakin 2026-05-04 15:02:29 +02:00
matthias 80c98513a7 Update jenkins/default_backup.yml 2026-05-03 19:10:21 +02:00
matthias 8adc2dee1e Update jenkins/default_backup.yml 2026-05-03 19:08:25 +02:00
matthias 8800a69306 Update jenkins/default_backup.yml 2026-04-09 16:42:51 +02:00
matthias 366838f66a Update jenkins/default_backup.yml 2026-04-09 16:42:16 +02:00
matthias cff05a3212 Update jenkins/default_backup.yml 2026-04-09 16:40:42 +02:00
matthias ad3382c944 Update jenkins/default_backup.yml 2026-04-09 16:38:10 +02:00
matthias 49b199c9a4 Update jenkins/default_backup.yml 2026-04-09 16:37:35 +02:00
matthias 684939f9d6 Update jenkins/default_backup.yml 2026-04-09 16:36:15 +02:00
matthias dfdb4c2723 Update jenkins/default_backup.yml 2026-04-09 16:35:14 +02:00
matthias bbd487a2c1 Update jenkins/default_backup.yml 2026-04-09 16:34:28 +02:00
matthias c777a4ec0d Update jenkins/default_backup.yml 2026-04-09 16:32:14 +02:00
matthias c548d620cf removed obsolete subdirectories 2026-04-02 20:46:08 +02:00
matthias d7c327b2d1 fixed wrong user usage 2026-04-02 07:40:29 +02:00
matthias e79336f6f7 added debug output 2026-04-02 07:27:59 +02:00
matthias 75317b6026 added switch to winschoten option 2026-04-02 07:25:11 +02:00
matthias 737961782c added winschoten backup to script 2026-04-02 07:22:33 +02:00
matthias fc31941b12 Update jenkins/nextcloud_database.yml 2026-02-05 13:31:35 +01:00
matthias 6eba4630ae Update jenkins/nextcloud_database.yml
Added exclusion of hidden files
2026-02-05 13:13:39 +01:00
matthias a90c76d884 Update jenkins/nextcloud_database.yml 2026-02-05 11:46:36 +01:00
matthias b23dd8ec00 added rclone config step 2026-01-18 16:54:02 +01:00
matthias 4e07ca5c82 removed paramteres 2026-01-18 16:52:00 +01:00
matthias ed5f6b571e Added more backup steps 2026-01-18 16:50:11 +01:00
matthias b6247d8ab0 Added file extension 2026-01-18 16:44:28 +01:00
matthias dbc50ac9df Added script for nextcloud database dump and backup 2026-01-18 16:42:46 +01:00
matthias 27017afe76 a 2026-01-14 12:38:08 +01:00
matthias 5a00e43405 a 2026-01-14 12:36:16 +01:00
matthias fb35a1a1d8 a 2026-01-14 12:34:26 +01:00
matthias e01162530b Added repo relocation permission 2026-01-14 12:31:30 +01:00
matthias f1508a9617 fixed syntax errors 2026-01-12 20:59:25 +01:00
matthias e756465455 fixed the parameters to not overwrite jenkins settings 2026-01-12 20:57:32 +01:00
matthias 19a3e14482 fix 2 2026-01-12 20:54:11 +01:00
matthias 2ff24eae6e fix 2026-01-12 20:51:06 +01:00
matthias ccc317141b try something 2026-01-12 20:49:02 +01:00
matthias 71aa6e464e removed parameters 2026-01-12 20:40:35 +01:00
matthias 72f73ad1f3 Fixed exclusion syntax 2026-01-12 20:35:42 +01:00
matthias ca5b28be15 Removed some printout 2026-01-12 20:25:57 +01:00
matthias 47f41cbcfa Added exclude to rclone 2026-01-12 20:22:13 +01:00
matthias 8f8be6ebb4 fixed an error 2026-01-12 20:13:07 +01:00
matthias 3916a4078a Added parameters for exclude list and added more printout 2026-01-12 20:11:23 +01:00
4 changed files with 132 additions and 70 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/"
}
}
}
}
}
+10 -69
View File
@@ -1,85 +1,26 @@
pipeline {
agent any
parameters {
booleanParam(name: 'backuplocally', defaultValue: 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: 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')
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 {
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 External PI is ${params.backuptopi}"
echo "Excludelist: ${params.excludelist}"
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}"
} else {
echo "Backup to TransIP Stack is skipped"
}
}
}
}
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/${directory}"
} else {
echo "Backup to David is skipped"
}
}
}
}
stage('Run Rsync to External PI') {
steps {
script {
if (params.backuptopi) {
withCredentials([sshUserPrivateKey(credentialsId: '095cc365-ac40-4ddb-a078-2fa403092de0', keyFileVariable: 'keyfile', passphraseVariable: 'passphrase', usernameVariable: 'user')]) {
sh "cp ${keyfile} ${WORKSPACE}/keyfile"
sh "rsync -v -a -e 'ssh -i /home/borgbackup/.ssh/id_rsa -p 9898' --delete --info=progress2 ${env.borglocation}/${directory} borgbackup@localhost:/borgbackup/${directory}"
}
} else {
echo "Backup to External PI 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}"
}
}
}
+95
View File
@@ -0,0 +1,95 @@
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')
}
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=''"
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"
}
}
}
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('Run Rsync to External PI') {
steps {
script {
if (params.backuptopi) {
withCredentials([sshUserPrivateKey(credentialsId: '095cc365-ac40-4ddb-a078-2fa403092de0', keyFileVariable: 'keyfile', passphraseVariable: 'passphrase', usernameVariable: 'user')]) {
sh "cp ${keyfile} ${WORKSPACE}/keyfile"
sh "rsync -v -a -e 'ssh -i /home/borgbackup/.ssh/id_rsa -p 9898' --delete --info=progress2 --exclude='.*' /srv/dev-disk-by-uuid-27fc012e-a1fa-4c7c-9dad-82770888cd03/nextcloud_backup/database_dump/ borgbackup@localhost:/nextcloudbackup/database_dump/"
}
} else {
echo "Backup to External PI is skipped"
}
}
}
}
}
}