Compare commits
54 Commits
a6988ec7fa
..
newtry
| Author | SHA1 | Date | |
|---|---|---|---|
| 2525f60fa1 | |||
| 7b3d843ea1 | |||
| 4680942268 | |||
| 00a769135d | |||
| 8db818ab8a | |||
| 12ad5c285f | |||
| 62aae741ce | |||
| 7a3fbd64b3 | |||
| e6d25bff2d | |||
| b17a219a4d | |||
| e0cfde229b | |||
| db43d95d87 | |||
| 5163fdbb55 | |||
| 80c98513a7 | |||
| 8adc2dee1e | |||
| 8800a69306 | |||
| 366838f66a | |||
| cff05a3212 | |||
| ad3382c944 | |||
| 49b199c9a4 | |||
| 684939f9d6 | |||
| dfdb4c2723 | |||
| bbd487a2c1 | |||
| c777a4ec0d | |||
| c548d620cf | |||
| d7c327b2d1 | |||
| e79336f6f7 | |||
| 75317b6026 | |||
| 737961782c | |||
| fc31941b12 | |||
| 6eba4630ae | |||
| a90c76d884 | |||
| b23dd8ec00 | |||
| 4e07ca5c82 | |||
| ed5f6b571e | |||
| b6247d8ab0 | |||
| dbc50ac9df | |||
| 27017afe76 | |||
| 5a00e43405 | |||
| fb35a1a1d8 | |||
| e01162530b | |||
| f1508a9617 | |||
| e756465455 | |||
| 19a3e14482 | |||
| 2ff24eae6e | |||
| ccc317141b | |||
| 71aa6e464e | |||
| 72f73ad1f3 | |||
| ca5b28be15 | |||
| 47f41cbcfa | |||
| 8f8be6ebb4 | |||
| 3916a4078a | |||
| 7ef17c5aff | |||
| 4c5aa3af54 |
@@ -0,0 +1,12 @@
|
||||
pipeline {
|
||||
agent any
|
||||
stages {
|
||||
stage ('Run Backup to David') {
|
||||
steps {
|
||||
script {
|
||||
sh "rsync -v -a -e 'ssh -p 664' --delete --bwlimit=3000 --info=progress2 ${env.borglocation} matthias@home.daf2000.nl:/media/disk/"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
pipeline {
|
||||
parameters {
|
||||
agent any
|
||||
stages {
|
||||
stage ('Run Backup to David') {
|
||||
steps {
|
||||
script {
|
||||
sh "cp ${keyfile} ${WORKSPACE}/keyfile"
|
||||
sh "rsync -v -a -e 'ssh -i /home/backupwinschoten/.ssh/id_rsa -p 9897' --delete --info=progress2 ${env.borglocation} backupwinschoten@localhost:/storage/"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
-69
@@ -1,85 +1,26 @@
|
||||
pipeline {
|
||||
agent any
|
||||
parameters {
|
||||
booleanParam(name: 'backuplocally', defaultValue: false, description: 'If true local BORG backup will be created')
|
||||
booleanParam(name: 'backuptostackstorage', defaultValue: false, description: 'If true backup data to TransIP Stack')
|
||||
booleanParam(name: 'backuptodavid', defaultValue: false, description: 'If true rsync the BORG repository to David')
|
||||
booleanParam(name: 'backuptopi', defaultValue: false, description: 'If true rsync the BORG repository to our ExternalPI')
|
||||
string(name: 'directory', defaultValue: params.directory ?: '${env.borglocation}/', 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 Information') {
|
||||
steps {
|
||||
echo "Local BORG backup creation is ${params.backuplocally}"
|
||||
echo "Backup to TransIP Stack is ${params.backuptostackstorage}"
|
||||
echo "Backup to David is ${params.backuptodavid}"
|
||||
echo "Backup to External PI is ${params.backuptopi}"
|
||||
echo "Excludelist: ${params.excludelist}"
|
||||
echo "Backing up directory ${directory}"
|
||||
sh "echo '${params.excludelist}' >> excludelist"
|
||||
}
|
||||
}
|
||||
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 {
|
||||
script {
|
||||
if (params.backuplocally) {
|
||||
withCredentials([string(credentialsId: 'cbce976a-0d98-4f35-8ea2-1f7818931bc3', variable: 'BORG_PASSPHRASE')]) {
|
||||
sh "borg create --progress --stats --exclude-from excludelist ${env.borglocation}/${directory}::${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 ${env.borglocation}/${directory}"
|
||||
}
|
||||
} else {
|
||||
echo "Local BORG backup creation is skipped"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Run rclone') {
|
||||
agent {
|
||||
docker {
|
||||
image 'rclone/rclone'
|
||||
args "--volumes-from=jenkins -v ${env.storagelocation}/${directory}/:/data/ --entrypoint=''"
|
||||
reuseNode true
|
||||
}
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
if (params.backuptostackstorage) {
|
||||
sh "mkdir -p /config/rclone"
|
||||
sh "cp ${WORKSPACE}/config/rclone.conf /config/rclone/"
|
||||
sh "rclone copy -v /data/ stackstorage:/julien/storage/${directory}"
|
||||
} else {
|
||||
echo "Backup to TransIP Stack is skipped"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Run Rsync to David') {
|
||||
steps {
|
||||
script {
|
||||
if (params.backuptodavid) {
|
||||
sh "rsync -v -a -e 'ssh -p 664' --delete --bwlimit=3000 --info=progress2 ${env.borglocation}/${directory} matthias@home.daf2000.nl:/media/disk/borgbackup/${directory}"
|
||||
} else {
|
||||
echo "Backup to David is skipped"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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 ${env.borglocation}/${directory} borgbackup@localhost:/borgbackup/${directory}"
|
||||
}
|
||||
} else {
|
||||
echo "Backup to External PI is skipped"
|
||||
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 prune --list --keep-daily 31 --keep-weekly 48 ${directory}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
pipeline {
|
||||
agent any
|
||||
parameters {
|
||||
booleanParam(name: 'backuplocally', defaultValue: params.backuplocally ?: false, description: 'If true local BORG backup will be created')
|
||||
booleanParam(name: 'backuptodavid', defaultValue: params.backuptodavid ?: false, description: 'If true rsync the BORG repository to David')
|
||||
booleanParam(name: 'backuptowinschoten', defaultValue: params.backuptowinschoten ?: false, description: 'If true rsync the BORG repository to our Winschoten backup system')
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Run Information') {
|
||||
steps {
|
||||
echo "Local BORG backup creation is ${params.backuplocally}"
|
||||
echo "Backup to David is ${params.backuptodavid}"
|
||||
echo "Backup to Winschoten PI is ${params.backuptowinschoten}"
|
||||
}
|
||||
}
|
||||
stage('Run MariaDB') {
|
||||
agent {
|
||||
docker {
|
||||
image 'mariadb:latest'
|
||||
args "--volumes-from=jenkins -v /srv/dev-disk-by-uuid-27fc012e-a1fa-4c7c-9dad-82770888cd03/nextcloud_backup/database_dump:/data/ --entrypoint=''"
|
||||
reuseNode false
|
||||
}
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
if (params.backuplocally) {
|
||||
sh "yes | cp -rf /data/backup_yesterday.dmp /data/backup_early.dmp 2>/dev/null || :"
|
||||
sh "yes | cp -rf /data/backup_latest.dmp /data/backup_yesterday.dmp 2>/dev/null || :"
|
||||
sh "mariadb-dump -u nextcloud -h 10.10.1.32 --all-databases -ppassword -v > /data/backup_latest.dmp"
|
||||
} else {
|
||||
echo "Local backup creation is skipped"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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('Rsync Backup in Parallel') {
|
||||
failFast false
|
||||
parallel {
|
||||
stage ('Run Backup to David') {
|
||||
steps {
|
||||
script {
|
||||
if (params.backuptodavid) {
|
||||
sh "yes | cp -rf matthias@home.daf2000.nl:/media/disk/nextcloudbackup/database_dump/backup_yesterday.dmp matthias@home.daf2000.nl:/media/disk/nextcloudbackup/database_dump/backup_early.dmp 2>/dev/null || :"
|
||||
sh "yes | cp -rf matthias@home.daf2000.nl:/media/disk/nextcloudbackup/database_dump/backup_latest.dmp matthias@home.daf2000.nl:/media/disk/nextcloudbackup/database_dump/backup_yesterday.dmp 2>/dev/null || :"
|
||||
sh "rsync -v -a -e 'ssh -p 664' --delete --bwlimit=3000 --info=progress2 --exclude='.*' /srv/dev-disk-by-uuid-27fc012e-a1fa-4c7c-9dad-82770888cd03/nextcloud_backup/database_dump/ matthias@home.daf2000.nl:/media/disk/nextcloudbackup/database_dump/"
|
||||
} else {
|
||||
echo "Backup to David is skipped"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage ('Run Backup to Winschoten') {
|
||||
steps {
|
||||
script {
|
||||
if (params.backuptowinschoten) {
|
||||
withCredentials([sshUserPrivateKey(credentialsId: 'backupwinschoten', keyFileVariable: 'keyfile', passphraseVariable: 'passphrase', usernameVariable: 'user')]) {
|
||||
sh "cp ${keyfile} ${WORKSPACE}/keyfile"
|
||||
sh "rsync -v -a -e 'ssh -i /home/backupwinschoten/.ssh/id_rsa -p 9897' --delete --info=progress2 ${env.borglocation}/${directory} backupwinschoten@localhost:/storage/borgbackups/"
|
||||
}
|
||||
} else {
|
||||
echo "Backup to Winschoten is skipped"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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