Files
backup/jenkins/other_location_backup.yml
T
matthias 0314d00426 m,
2026-05-08 20:33:28 +02:00

34 lines
1.6 KiB
YAML

pipeline {
parameters {
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')
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 Preparation') {
steps {
echo "Backing up directory ${directory}"
sh "echo '${params.excludelist}' >> excludelist"
}
}
stage('Create local BorgBackup') {
steps {
script {
sh "mkdir -p ${WORKSPACE}/tmpmount"
sh "sshfs -o IdentityFile=/home/pi/.ssh/id_rsa root@10.10.1.32:/${env.borglocation}/ ${WORKSPACE}/tmpmount"
withCredentials([string(credentialsId: 'cbce976a-0d98-4f35-8ea2-1f7818931bc3', variable: 'BORG_PASSPHRASE')]) {
sh "borg create --progress --stats --exclude-from excludelist ${WORKSPACE}/tmpmount/${directory}::${java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern('dd-MM-yyyy_HH:mm'))} /${directory}"
sh "borg prune --list --keep-daily 31 --keep-weekly 48 ${WORKSPACE}/tmpmount/${directory}"
}
}
}
}
}
}