50 lines
2.0 KiB
YAML
50 lines
2.0 KiB
YAML
pipeline {
|
|
agent any
|
|
parameters {
|
|
booleanParam(name: 'UseLocationPrefix', defaultValue: params.backuplocally ?: true, description: 'Use the environmental backup location')
|
|
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')
|
|
}
|
|
environment {
|
|
BORG_RELOCATED_REPO_ACCESS_IS_OK = 'yes'
|
|
backdirectory = "${directory}"
|
|
}
|
|
stages {
|
|
stage('Run Preparation') {
|
|
steps {
|
|
script {
|
|
if (params.UseLocationPrefix) {
|
|
backdirectory = env.borglocation + "/" + "${directory}"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Run MariaDB') {
|
|
agent {
|
|
docker {
|
|
image 'mariadb:latest'
|
|
args "--volumes-from=jenkins -v ${backdirectory}:/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 ${env.borglocation}/nextcloud_database::${java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern('dd-MM-yyyy_HH:mm'))} ${backdirectory}"
|
|
sh "borg prune --list --keep-daily 31 --keep-weekly 48 ${env.borglocation}/nextcloud_database"
|
|
sh "rm -rf ${backdirectory}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |