Compare commits
2 Commits
newtry
...
b677ede690
| Author | SHA1 | Date | |
|---|---|---|---|
| b677ede690 | |||
| ac1687c402 |
@@ -1,5 +1,4 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
parameters {
|
|
||||||
agent any
|
agent any
|
||||||
stages {
|
stages {
|
||||||
stage ('Run Backup to David') {
|
stage ('Run Backup to David') {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
parameters {
|
parameters {
|
||||||
string(name: 'directory', defaultValue: params.directory ?: '${env.borglocation}/', description: 'The directory that should be handled')
|
string(name: 'directoryPrefix', defaultValue: params.directoryPrefix ?: '${env.borglocation}/', description: 'The directory prefix that should be handled')
|
||||||
|
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')
|
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')
|
text(name: 'excludelist', defaultValue: params.excludelist ?: '**/cache/** ', description: 'Multiline string to exclude patterns from backup')
|
||||||
}
|
}
|
||||||
@@ -9,19 +10,18 @@ pipeline {
|
|||||||
BORG_RELOCATED_REPO_ACCESS_IS_OK = 'yes'
|
BORG_RELOCATED_REPO_ACCESS_IS_OK = 'yes'
|
||||||
}
|
}
|
||||||
stages {
|
stages {
|
||||||
stage('Run Information') {
|
stage('Run Information') {
|
||||||
steps {
|
steps {
|
||||||
echo "Backing up directory ${directory}"
|
echo "Backing up directory ${directoryPrefix}/${directory}"
|
||||||
sh "echo '${params.excludelist}' >> excludelist"
|
sh "echo '${params.excludelist}' >> excludelist"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Create local BorgBackup'){
|
stage('Create local BorgBackup') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
withCredentials([string(credentialsId: 'cbce976a-0d98-4f35-8ea2-1f7818931bc3', variable: 'BORG_PASSPHRASE')]) {
|
withCredentials([string(credentialsId: 'cbce976a-0d98-4f35-8ea2-1f7818931bc3', variable: 'BORG_PASSPHRASE')]) {
|
||||||
sh "borg create --progress --stats --exclude-from excludelist ${directory}::${java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern('dd-MM-yyyy_HH:mm'))} ${env.storagelocation}/${directory}"
|
sh "borg create --progress --stats --exclude-from excludelist ${directoryPrefix}/${directory}::${java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern('dd-MM-yyyy_HH:mm'))} ${directoryPrefix}/${directory}"
|
||||||
sh "borg prune --list --keep-daily 31 --keep-weekly 48 ${directory}"
|
sh "borg prune --list --keep-daily 31 --keep-weekly 48 ${directoryPrefix}/${directory}"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,21 +75,5 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user