Added default backup file for jenkins
This commit is contained in:
48
jenkins/default_backup.yml
Normal file
48
jenkins/default_backup.yml
Normal file
@@ -0,0 +1,48 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
stage('Getting RClone Configuration') {
|
||||
steps {
|
||||
configFileProvider([configFile(fileId: 'e0237193-1245-452e-b035-9d3d501f4c1b', variable: 'rclone_config')]) {
|
||||
sh "mkdir -p ${WORKSPACE}/config"
|
||||
sh "cp ${rclone_config} ${WORKSPACE}/config/rclone.conf"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Create local BorgBackup'){
|
||||
steps {
|
||||
withCredentials([string(credentialsId: 'cbce976a-0d98-4f35-8ea2-1f7818931bc3', variable: 'BORG_PASSPHRASE')]) {
|
||||
sh "borg create --progress --stats ${env.borglocation}/${directory}::${java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern('dd-MM-yyyy_HH:mm'))} ${env.storagelocation}/${directory}"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Run rclone') {
|
||||
agent {
|
||||
docker {
|
||||
image 'rclone/rclone'
|
||||
args "--volumes-from=jenkins -v ${env.storagelocation}/${directory}/:/data/ --entrypoint=''"
|
||||
reuseNode true
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh "mkdir -p /config/rclone"
|
||||
sh "cp ${WORKSPACE}/config/rclone.conf /config/rclone/"
|
||||
sh "rclone copy -v /data/ stackstorage:/julien/storage/${directory}"
|
||||
}
|
||||
}
|
||||
stage('Run Rsync to David') {
|
||||
steps {
|
||||
sh "rsync -v -a -e 'ssh -p 664' --delete --bwlimit=3000 ${env.borglocation}/${directory} matthias@home.daf2000.nl:/media/disk/borgbackup"
|
||||
}
|
||||
}
|
||||
stage('Run Rsync to External PI') {
|
||||
steps {
|
||||
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 ${env.borglocation}/${directory} borgbackup@localhost:/borgbackup"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user