From 3300775a1d5487954c08a427bf248ec445f31e7f Mon Sep 17 00:00:00 2001 From: Benjamin Herbert <2254565+BenjaminHerbert@users.noreply.github.com> Date: Thu, 10 Jul 2025 23:32:35 +0200 Subject: [PATCH 1/2] docs: improve (#1121) --- .../en/docs/Getting Started/latest/custom-backup-and-restore.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/content/en/docs/Getting Started/latest/custom-backup-and-restore.md b/website/content/en/docs/Getting Started/latest/custom-backup-and-restore.md index f5c9918c..bbf8dd62 100644 --- a/website/content/en/docs/Getting Started/latest/custom-backup-and-restore.md +++ b/website/content/en/docs/Getting Started/latest/custom-backup-and-restore.md @@ -15,7 +15,7 @@ for the Jenkins Operator. Two commands (e.g. scripts) are required: - a backup command, e.g. `backup.sh` that takes one argument, a **backup number** -- a restore command, e.g. `backup.sh` that takes one argument, a **backup number** +- a restore command, e.g. `restore.sh` that takes one argument, a **backup number** Both scripts need to return an exit code of `0` on success and `1` or greater for failure. From ae9cb0c7f502f104391dfe753b5252edd8881093 Mon Sep 17 00:00:00 2001 From: Benjamin Herbert <2254565+BenjaminHerbert@users.noreply.github.com> Date: Wed, 16 Jul 2025 23:43:08 +0200 Subject: [PATCH 2/2] fix(backup): Add error handling and logging backup and restore scripts (#1120) Co-authored-by: Luigi Operoso <40476330+brokenpip3@users.noreply.github.com> --- backup/pvc/VERSION.txt | 2 +- backup/pvc/bin/backup.sh | 4 ++++ backup/pvc/bin/restore.sh | 12 +++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/backup/pvc/VERSION.txt b/backup/pvc/VERSION.txt index 0eec13e4..f87d474c 100644 --- a/backup/pvc/VERSION.txt +++ b/backup/pvc/VERSION.txt @@ -1 +1 @@ -v0.4.2 +v0.4.3 diff --git a/backup/pvc/bin/backup.sh b/backup/pvc/bin/backup.sh index 13d2f096..40c9f8dd 100755 --- a/backup/pvc/bin/backup.sh +++ b/backup/pvc/bin/backup.sh @@ -51,6 +51,10 @@ if [[ "$ret" -eq 0 ]]; then _log "INFO" "[backup] backup ${BACKUP_NUMBER} was completed without warnings" elif [[ "$ret" -eq 1 ]]; then _log "INFO" "[backup] backup ${BACKUP_NUMBER} was completed with some warnings" +else + _log "ERROR" "[backup] backup ${BACKUP_NUMBER} failed with error code: $ret" + _clean + exit "$ret" fi mv "${BACKUP_TMP_DIR}/${BACKUP_NUMBER}.tar.zstd" "${BACKUP_DIR}/${BACKUP_NUMBER}.tar.zstd" diff --git a/backup/pvc/bin/restore.sh b/backup/pvc/bin/restore.sh index 3a692625..f10e2e75 100755 --- a/backup/pvc/bin/restore.sh +++ b/backup/pvc/bin/restore.sh @@ -39,7 +39,17 @@ else exit 1 fi -tar $OPTS -C "${JENKINS_HOME}" -xf "${BACKUP_DIR}/${BACKUP_NUMBER}.${EXT}" +tar $OPTS -C "${JENKINS_HOME}" -xf "${BACKUP_DIR}/${BACKUP_NUMBER}.${EXT}" || ret=$? + +if [[ "$ret" -eq 0 ]]; then + _log "INFO" "[restore] restore ${BACKUP_NUMBER} was completed without warnings" +elif [[ "$ret" -eq 1 ]]; then + _log "INFO" "[restore] restore ${BACKUP_NUMBER} was completed with some warnings" +else + _log "ERROR" "[restore] restore ${BACKUP_NUMBER} failed with error code: $ret" + exit "$ret" +fi + _log "INFO" "[restore] deleting lock file ${TRAP_FILE}" test -f "${TRAP_FILE}" && rm -f "${TRAP_FILE}"