From c28dc0681685e02ec71cde222a478fa0b579d1d8 Mon Sep 17 00:00:00 2001 From: Felipe Cotti Date: Mon, 27 Jan 2025 02:31:12 -0300 Subject: [PATCH] Now it works - except it doesn't. Maybe I shouldn't hide the error in the compactor. --- build/.env.template | 3 +-- build/docker-compose.public.yml | 5 ++--- src/Guestbooky-backup/internal/compactor/compactor.go | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/build/.env.template b/build/.env.template index c15cdcb..1b10862 100644 --- a/build/.env.template +++ b/build/.env.template @@ -15,5 +15,4 @@ BACKUP_S3_KEY_NAME=guestbooky-backup BACKUP_S3_ACCESS_ID=0000000000000000000000000 BACKUP_S3_SECRET_ID=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA BACKUP_S3_ENDPOINT=https://s3.us-east-005.backblazeb2.com -BACKUP_S3_REGION=us-east-005 -BACKUP_SOURCE_PATH=/backups/guestbooky_$(date +\%Y-\%m-\%d) \ No newline at end of file +BACKUP_S3_REGION=us-east-005 \ No newline at end of file diff --git a/build/docker-compose.public.yml b/build/docker-compose.public.yml index 20b6339..873a09a 100644 --- a/build/docker-compose.public.yml +++ b/build/docker-compose.public.yml @@ -66,7 +66,7 @@ services: --username ${GUESTBOOKY_USER} --password ${GUESTBOOKY_USER} --authenticationDatabase ${GUESTBOOKY_DB_NAME} - --out ${BACKUP_SOURCE_PATH} && touch /backups/backup_done" + --out /backups/guestbooky_$(date +\%Y-\%m-\%d) && touch /backups/backup_done" volumes: - ./backups:/backups depends_on: @@ -88,10 +88,9 @@ services: BACKUP_S3_SECRET_ID: ${BACKUP_S3_SECRET_ID} BACKUP_S3_ENDPOINT: ${BACKUP_S3_ENDPOINT} BACKUP_S3_REGION: ${BACKUP_S3_REGION} - BACKUP_SOURCE_PATH: ${BACKUP_SOURCE_PATH} - BACKUP_DESTINATION_PATH: ${BACKUP_SOURCE_PATH}.gzip volumes: - ./backups:/backups + command: sh -c "export BACKUP_SOURCE_PATH=/backups/guestbooky_$(date +\%Y-\%m-\%d) && export BACKUP_DESTINATION_PATH=/backups/guestbooky_$(date +\%Y-\%m-\%d).gzip && /root/guestbooky-backup" volumes: mongodata: diff --git a/src/Guestbooky-backup/internal/compactor/compactor.go b/src/Guestbooky-backup/internal/compactor/compactor.go index 5db45c7..8eb471f 100644 --- a/src/Guestbooky-backup/internal/compactor/compactor.go +++ b/src/Guestbooky-backup/internal/compactor/compactor.go @@ -34,7 +34,7 @@ func Compact(source, destination string) error { defer zipWriter.Close() if _, err := io.Copy(zipWriter, originFileHandle); err != nil { - return errors.New("failed to copy file") + return errors.New("failed to copy zip to destination file: " + err.Error()) //nolint:wraperr } return nil