Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backups should only exclude config.xml in top level job directories, … #251

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions backup/pvc/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.9
FROM debian:buster-slim

ENV USER=user
ENV UID=1000
Expand All @@ -10,8 +10,8 @@ RUN addgroup --gid "$GID" "$USER" && \
--gecos "" \
--ingroup "$USER" \
--uid "$UID" \
"$USER" && \
apk add --no-cache bash
"$USER"

WORKDIR /home/user/bin
COPY bin .
RUN chmod +x *.sh
Expand Down
6 changes: 5 additions & 1 deletion backup/pvc/bin/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ BACKUP_TMP_DIR=$(mktemp -d)
backup_number=$1
echo "Running backup"

tar -C ${JENKINS_HOME} -czf "${BACKUP_TMP_DIR}/${backup_number}.tar.gz" --exclude jobs/*/config.xml --exclude jobs/*/workspace* -c jobs && \
# config.xml in a job directory is a config file that shouldnt be backed up
# config.xml in child directores is state that should. For example-
# branches/myorg/branches/myrepo/branches/master/config.xml should be retained while
# branches/myorg/config.xml should not
tar -C ${JENKINS_HOME} -czf "${BACKUP_TMP_DIR}/${backup_number}.tar.gz" --exclude jobs/*/workspace* --no-wildcards-match-slash --anchored --exclude jobs/*/config.xml -c jobs && \
mv ${BACKUP_TMP_DIR}/${backup_number}.tar.gz ${BACKUP_DIR}/${backup_number}.tar.gz

[[ ! -s ${BACKUP_DIR}/${backup_number}.tar.gz ]] && echo "backup file '${BACKUP_DIR}/${backup_number}.tar.gz' is empty" && exit 1;
Expand Down
Empty file.
Empty file.
6 changes: 3 additions & 3 deletions backup/pvc/e2e/backup_and_restore/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ backup_file="${BACKUP_DIR}/${backup_number}.tar.gz"
docker exec -it ${cid} /bin/bash -c "JENKINS_HOME=${RESTORE_FOLDER};/home/user/bin/restore.sh ${backup_number}"

echo "Compare directories"
diff --brief --recursive ${JENKINS_HOME} ${RESTORE_FOLDER}
echo "Directories are the same"
echo PASS
test $(diff --brief --recursive ${JENKINS_HOME} ${RESTORE_FOLDER} | wc -l) = 3
echo "Directories are the same except for 2 excluded config.xml and the 1 workspace file"
echo PASS