re-organised the default script to use a name instead of the directory directly
This commit is contained in:
@@ -2,12 +2,15 @@ pipeline {
|
||||
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: 'name', defaultValue: env.JOB_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}"
|
||||
}
|
||||
|
||||
@@ -16,9 +19,9 @@ pipeline {
|
||||
steps {
|
||||
script {
|
||||
if (params.UseLocationPrefix) {
|
||||
backdirectory = env.borglocation + "/" + "${directory}"
|
||||
from_dir = env.storagelocation + "/" + "${name}"
|
||||
}
|
||||
echo "Backing up directory ${backdirectory}"
|
||||
sh "echo 'Backing up directory ${from_dir} to ${to_dir}'"
|
||||
sh "echo '${params.excludelist}' >> excludelist"
|
||||
}
|
||||
}
|
||||
@@ -28,8 +31,8 @@ pipeline {
|
||||
steps {
|
||||
script {
|
||||
withCredentials([string(credentialsId: 'cbce976a-0d98-4f35-8ea2-1f7818931bc3', variable: 'BORG_PASSPHRASE')]) {
|
||||
sh "borg create --progress --stats --exclude-from excludelist ${backdirectory}::${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 ${backdirectory}"
|
||||
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}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user