Compare commits

..

25 Commits

Author SHA1 Message Date
fc31941b12 Update jenkins/nextcloud_database.yml 2026-02-05 13:31:35 +01:00
6eba4630ae Update jenkins/nextcloud_database.yml
Added exclusion of hidden files
2026-02-05 13:13:39 +01:00
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
27017afe76 a 2026-01-14 12:38:08 +01:00
5a00e43405 a 2026-01-14 12:36:16 +01:00
fb35a1a1d8 a 2026-01-14 12:34:26 +01:00
e01162530b Added repo relocation permission 2026-01-14 12:31:30 +01:00
f1508a9617 fixed syntax errors 2026-01-12 20:59:25 +01:00
e756465455 fixed the parameters to not overwrite jenkins settings 2026-01-12 20:57:32 +01:00
19a3e14482 fix 2 2026-01-12 20:54:11 +01:00
2ff24eae6e fix 2026-01-12 20:51:06 +01:00
ccc317141b try something 2026-01-12 20:49:02 +01:00
71aa6e464e removed parameters 2026-01-12 20:40:35 +01:00
72f73ad1f3 Fixed exclusion syntax 2026-01-12 20:35:42 +01:00
ca5b28be15 Removed some printout 2026-01-12 20:25:57 +01:00
47f41cbcfa Added exclude to rclone 2026-01-12 20:22:13 +01:00
8f8be6ebb4 fixed an error 2026-01-12 20:13:07 +01:00
3916a4078a Added parameters for exclude list and added more printout 2026-01-12 20:11:23 +01:00
7ef17c5aff Merge branch 'main' of https://git.mitscherlich.nl/matthias/backup 2026-01-12 08:08:07 +01:00
4c5aa3af54 removed obsolete parameter TEXT 2026-01-12 08:07:00 +01:00
2 changed files with 105 additions and 6 deletions

View File

@@ -1,19 +1,24 @@
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')
booleanParam(name: 'backuplocally', defaultValue: params.backuplocally ?: false, description: 'If true local BORG backup will be created')
booleanParam(name: 'backuptostackstorage', defaultValue: params.backuptostackstorage ?: 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: 'backuptopi', defaultValue: params.backuptopi ?: false, description: 'If true rsync the BORG repository to our ExternalPI')
string(name: 'directory', defaultValue: params.directory ?: ' ', description: 'The directory that should be handled')
text(name: 'excludelist', defaultValue: params.excludelist ?: '**/cache/** ', description: 'Multiline string to exclude patterns from backup')
}
environment {
BORG_RELOCATED_REPO_ACCESS_IS_OK = 'yes'
}
stages {
stage('Run Information') {
steps {
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 External PI is ${params.backuptopi}"
echo "Excludelist: ${params.excludelist}"
sh "echo '${params.excludelist}' >> excludelist"
}
}
@@ -52,7 +57,7 @@ pipeline {
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}"
sh "rclone copy -v /data/ stackstorage:/julien/storage/${directory} --exclude-from excludelist"
} else {
echo "Backup to TransIP Stack is skipped"
}

View File

@@ -0,0 +1,94 @@
pipeline {
agent any
parameters {
booleanParam(name: 'backuplocally', defaultValue: params.backuplocally ?: false, description: 'If true local BORG backup will be created')
booleanParam(name: 'backuptostackstorage', defaultValue: params.backuptostackstorage ?: 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: 'backuptopi', defaultValue: params.backuptopi ?: false, description: 'If true rsync the BORG repository to our ExternalPI')
}
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}"
}
}
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('Run rclone') {
agent {
docker {
image 'rclone/rclone'
args "--volumes-from=jenkins -v /srv/dev-disk-by-uuid-27fc012e-a1fa-4c7c-9dad-82770888cd03/nextcloud_backup/database_dump/:/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/nextcloud/database"
} 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 --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 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"
}
}
}
}
}
}