Merge pull request #50 from benlangfeld/patch-1

Allow rolling backups to a limit
This commit is contained in:
Tomasz Sęk 2019-07-12 09:44:03 +02:00 committed by GitHub
commit c7068edf64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View File

@ -1 +1 @@
v0.0.3
v0.0.4

View File

@ -6,6 +6,11 @@ set -eo pipefail
[[ -z "${BACKUP_DIR}" ]] && echo "Required 'BACKUP_DIR' env not set" && exit 1;
[[ -z "${JENKINS_HOME}" ]] && echo "Required 'JENKINS_HOME' env not set" && exit 1;
if [[ ! -z "${BACKUP_COUNT}" ]]; then
echo "Trimming to only $((BACKUP_COUNT-1)) recent backups in preparation for new backup"
ls -1t ${BACKUP_DIR} | tail -n +${BACKUP_COUNT} | xargs -I '{}' rm -f ${BACKUP_DIR}/'{}'
fi
backup_number=$1
echo "Running backup"
@ -14,4 +19,4 @@ tar -C ${JENKINS_HOME} -czf "${BACKUP_DIR}/${backup_number}.tar.gz" --exclude jo
[[ ! -s ${BACKUP_DIR}/${backup_number}.tar.gz ]] && echo "backup file '${BACKUP_DIR}/${backup_number}.tar.gz' is empty" && exit 1;
echo Done
exit 0
exit 0

View File

@ -423,7 +423,9 @@ spec:
value: /backup
- name: JENKINS_HOME
value: /jenkins-home
image: virtuslab/jenkins-operator-backup-pvc:v0.0.3 # look at backup/pvc directory
- name: BACKUP_COUNT
value: "2" # keep only the 2 most recent backups
image: virtuslab/jenkins-operator-backup-pvc:v0.0.4 # look at backup/pvc directory
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /jenkins-home # Jenkins home volume