From bf2dabd2c70a40b1ee06772775d5fad541619892 Mon Sep 17 00:00:00 2001 From: Marcio Zimbres Date: Thu, 7 Dec 2023 14:02:36 -0300 Subject: [PATCH 1/4] Added option to set the target folder backup --- CHANGELOG.md | 3 +++ Dockerfile | 1 + README.md | 1 + backup.sh | 8 +++++++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0d6c82..598d44f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +### Added +* Option to set the target folder backup + ## v1.3.2 (restic 0.16.0) ### Changed diff --git a/Dockerfile b/Dockerfile index 9cf220b..20f0424 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,6 +35,7 @@ ENV OS_PASSWORD="" ENV OS_REGION_NAME="" ENV OS_INTERFACE="" ENV OS_IDENTITY_API_VERSION=3 +ENV BACKUP_SOURCES="" # openshift fix RUN mkdir /.cache && \ diff --git a/README.md b/README.md index a75fcd6..c5d8aca 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,7 @@ The container is set up by setting [environment variables](https://docs.docker.c * `OS_REGION_NAME` - Optional. When using restic with OpenStack Swift container. * `OS_INTERFACE` - Optional. When using restic with OpenStack Swift container. * `OS_IDENTITY_API_VERSION` - Optional. When using restic with OpenStack Swift container. +* `BACKUP_SOURCES` - Optional. Set the folder that will be backed up. ## Volumes diff --git a/backup.sh b/backup.sh index 6391ebc..36cadaa 100755 --- a/backup.sh +++ b/backup.sh @@ -4,6 +4,12 @@ lastLogfile="/var/log/backup-last.log" lastMailLogfile="/var/log/mail-last.log" lastMicrosoftTeamsLogfile="/var/log/microsoft-teams-last.log" +if [ -n "$BACKUP_SOURCES" ]; then + backupSources="$BACKUP_SOURCES" +else + backupSources="/data" +fi + copyErrorLog() { cp ${lastLogfile} /var/log/backup-error-last.log } @@ -31,7 +37,7 @@ logLast "RESTIC_REPOSITORY: ${RESTIC_REPOSITORY}" logLast "AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}" # Do not save full backup log to logfile but to backup-last.log -restic backup /data ${RESTIC_JOB_ARGS} --tag=${RESTIC_TAG?"Missing environment variable RESTIC_TAG"} >> ${lastLogfile} 2>&1 +restic backup ${backupSources} ${RESTIC_JOB_ARGS} --tag=${RESTIC_TAG?"Missing environment variable RESTIC_TAG"} >> ${lastLogfile} 2>&1 backupRC=$? logLast "Finished backup at $(date)" if [[ $backupRC == 0 ]]; then From 9b829f90e0b7036b5ca373091c522d560aacf5cb Mon Sep 17 00:00:00 2001 From: Marcio Zimbres Date: Thu, 7 Dec 2023 19:25:36 -0300 Subject: [PATCH 2/4] Change Action to add multi-platform image build --- .github/workflows/docker-publish.yml | 1 + CHANGELOG.md | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index cec15e2..f0955aa 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -72,6 +72,7 @@ jobs: uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a with: context: . + platforms: linux/amd64,linux/arm64,linux/arm/v7 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 598d44f..db33663 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Added * Option to set the target folder backup +* Multi-platform image build ## v1.3.2 (restic 0.16.0) From b2616ef2dce83ff0c06ecfe27b7aad8a6b008b50 Mon Sep 17 00:00:00 2001 From: Marcio Zimbres Date: Thu, 7 Dec 2023 19:55:23 -0300 Subject: [PATCH 3/4] Adjust Dockerfile in order to download rclone that matches container architecture --- Dockerfile | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 20f0424..1c9f832 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,17 @@ -FROM alpine:latest as rclone +FROM --platform=$TARGETPLATFORM alpine:latest as rclone +ARG TARGETPLATFORM + +RUN apk add wget # Get rclone executable -ADD https://downloads.rclone.org/rclone-current-linux-amd64.zip / -RUN unzip rclone-current-linux-amd64.zip && mv rclone-*-linux-amd64/rclone /bin/rclone && chmod +x /bin/rclone +RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ + wget https://downloads.rclone.org/rclone-current-linux-amd64.zip && unzip rclone-current-linux-amd64.zip && mv rclone-*-linux-*/rclone /bin/rclone && chmod +x /bin/rclone; \ + elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ + wget https://downloads.rclone.org/rclone-current-linux-arm64.zip && unzip rclone-current-linux-arm64.zip && mv rclone-*-linux-*/rclone /bin/rclone && chmod +x /bin/rclone; \ + elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \ + wget https://downloads.rclone.org/rclone-current-linux-arm-v7.zip && unzip rclone-current-linux-arm-v7.zip && mv rclone-*-linux-*/rclone /bin/rclone && chmod +x /bin/rclone; \ + fi + FROM restic/restic:0.16.0 From 2f0ce618b8fb5ae07c10d9b46019ec4f83d14d67 Mon Sep 17 00:00:00 2001 From: Marcio Zimbres Date: Thu, 7 Dec 2023 20:23:09 -0300 Subject: [PATCH 4/4] Adjust file name of rclone zip in Dockerfile --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1c9f832..f4e5126 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,11 +5,11 @@ RUN apk add wget # Get rclone executable RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ - wget https://downloads.rclone.org/rclone-current-linux-amd64.zip && unzip rclone-current-linux-amd64.zip && mv rclone-*-linux-*/rclone /bin/rclone && chmod +x /bin/rclone; \ + wget https://downloads.rclone.org/rclone-current-linux-amd64.zip && unzip rclone-current-linux-amd64.zip && mv rclone-*-linux-amd64/rclone /bin/rclone && chmod +x /bin/rclone; \ elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ - wget https://downloads.rclone.org/rclone-current-linux-arm64.zip && unzip rclone-current-linux-arm64.zip && mv rclone-*-linux-*/rclone /bin/rclone && chmod +x /bin/rclone; \ + wget https://downloads.rclone.org/rclone-current-linux-arm64.zip && unzip rclone-current-linux-arm64.zip && mv rclone-*-linux-arm64/rclone /bin/rclone && chmod +x /bin/rclone; \ elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \ - wget https://downloads.rclone.org/rclone-current-linux-arm-v7.zip && unzip rclone-current-linux-arm-v7.zip && mv rclone-*-linux-*/rclone /bin/rclone && chmod +x /bin/rclone; \ + wget https://downloads.rclone.org/rclone-current-linux-arm-v7.zip && unzip rclone-current-linux-arm-v7.zip && mv rclone-*-linux-arm-v7/rclone /bin/rclone && chmod +x /bin/rclone; \ fi