Compare commits
39 Commits
ac1687c402
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 238d64f785 | |||
| 8c7b633323 | |||
| 4990d39810 | |||
| d62ba26215 | |||
| 3c823a0135 | |||
| b7367ae30c | |||
| 4d062fd626 | |||
| cce4be576e | |||
| 55a9cffe6a | |||
| e23cc9eca0 | |||
| 92dbce1d8b | |||
| 41bfbe92ff | |||
| f11884e91f | |||
| 0c1f2cb464 | |||
| 326f919ef9 | |||
| 2887e2f15b | |||
| c787fb51e2 | |||
| 1bd54edc93 | |||
| b06d155d48 | |||
| 8bd4acd531 | |||
| bbb7ceb332 | |||
| 0314d00426 | |||
| be4ecdb674 | |||
| 38138dfed4 | |||
| f1114cd2bb | |||
| 5e71088b97 | |||
| 3e18c39e68 | |||
| 836ff078e0 | |||
| 67a0604a01 | |||
| aace7a4f86 | |||
| b2b1b4e056 | |||
| 10627b100e | |||
| a228f0f340 | |||
| 7a83abe6d3 | |||
| 7634efd863 | |||
| b677ede690 | |||
| 2525f60fa1 | |||
| 7b3d843ea1 | |||
| 4680942268 |
@@ -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.julienbackuplocation} matthias@home.daf2000.nl:/media/disk/backup_julien"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
pipeline {
|
||||
agent any
|
||||
stages {
|
||||
stage ('Run Backup to David') {
|
||||
steps {
|
||||
script {
|
||||
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.julienbackuplocation} backupwinschoten@localhost:/storage/backup_julien"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
-48
@@ -1,68 +1,38 @@
|
||||
pipeline {
|
||||
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')
|
||||
string(name: 'directory', defaultValue: params.directory ?: ' ', description: 'The directory that should be handled')
|
||||
booleanParam(name: 'UseLocationPrefix', defaultValue: params.UseLocationPrefix ?: false, description: 'Use the environmental storage (FROM directory) location')
|
||||
string(name: 'directory', defaultValue: params.directory ?: ' ', description: 'The directory that should be handled - either at the environmental location or fill in a custom absolute path')
|
||||
string(name: 'name', defaultValue: params.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}"
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Run Information') {
|
||||
steps {
|
||||
script { env.backuptostackstorage = false }
|
||||
echo "Backing up directory ${env.storagelocation}/${directory}"
|
||||
echo "Local BORG backup creation is ${params.backuplocally}"
|
||||
echo "Backup to David is ${params.backuptodavid}"
|
||||
echo "Backup to Winschoten PI is ${params.backuptowinschoten}"
|
||||
sh "echo '${params.excludelist}' >> excludelist"
|
||||
}
|
||||
}
|
||||
stage('Create local BorgBackup'){
|
||||
stage('Run Preparation') {
|
||||
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"
|
||||
if (params.UseLocationPrefix) {
|
||||
from_dir = env.storagelocation + "/" + "${name}"
|
||||
}
|
||||
sh "echo 'Backing up directory ${from_dir} to ${to_dir}'"
|
||||
sh "echo '${params.excludelist}' >> excludelist"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Rsync Backup in Parallel') {
|
||||
failFast false
|
||||
parallel {
|
||||
stage ('Run Backup 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/borgbackups/"
|
||||
} 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('Create local BorgBackup') {
|
||||
steps {
|
||||
script {
|
||||
withCredentials([string(credentialsId: 'cbce976a-0d98-4f35-8ea2-1f7818931bc3', variable: 'BORG_PASSPHRASE')]) {
|
||||
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}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,76 +1,38 @@
|
||||
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')
|
||||
string(name: 'directory', defaultValue: params.directory ?: ' ', description: 'The directory that should be handled - either at the environmental location or fill in a custom absolute path')
|
||||
string(name: 'name', defaultValue: params.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')
|
||||
}
|
||||
environment {
|
||||
BORG_RELOCATED_REPO_ACCESS_IS_OK = 'yes'
|
||||
from_dir = "${directory}"
|
||||
to_dir = "${env.borglocation}" + "/" + "${name}"
|
||||
}
|
||||
|
||||
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=''"
|
||||
args "-v '${from_dir}':/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"
|
||||
}
|
||||
}
|
||||
}
|
||||
sh "mariadb-dump -u nextcloud -h 10.10.1.32 --all-databases -ppassword -v > /data/nextcloud_database.dmp"
|
||||
|
||||
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('Create local BorgBackup') {
|
||||
steps {
|
||||
script {
|
||||
withCredentials([string(credentialsId: 'cbce976a-0d98-4f35-8ea2-1f7818931bc3', variable: 'BORG_PASSPHRASE')]) {
|
||||
sh "borg create --progress --stats ${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}"
|
||||
sh "rm -rf ${from_dir}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
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/${agentname}_${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/${agentname}_${directory}"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user