Files
backup/jenkins/nextcloud_database.yml
T
2026-05-31 21:38:02 +02:00

41 lines
1.8 KiB
YAML

pipeline {
agent any
parameters {
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 MariaDB') {
agent {
docker {
image 'mariadb:latest'
args "-v '${from_dir}':/data/ --entrypoint=''"
reuseNode false
}
}
steps {
script {
sh "mariadb-dump -u nextcloud -h 10.10.1.32 --all-databases -ppassword -v > /data/nextcloud_database.dmp"
}
}
}
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}"
}
}
}
}
}
}