1
0
mirror of https://github.com/garraflavatra/docker-volume-s3-backup.git synced 2025-05-17 13:14:38 +00:00

Fix some bugs, it is working now!

This commit is contained in:
Romein van Buren 2025-05-04 13:54:42 +02:00
parent b9c40a6ee8
commit e569eb75b0
No known key found for this signature in database
5 changed files with 25 additions and 13 deletions

View File

@ -24,4 +24,4 @@ ADD src/env.sh env.sh
ADD src/backup.sh backup.sh ADD src/backup.sh backup.sh
# ADD src/restore.sh restore.sh -- not ready yet # ADD src/restore.sh restore.sh -- not ready yet
CMD ['sh', 'run.sh'] CMD ["sh", "run.sh"]

View File

@ -19,17 +19,21 @@ services:
volume_backup: volume_backup:
image: smartyellow/docker-volume-s3-backup image: smartyellow/docker-volume-s3-backup
volumes:
data:/data/folder1
environment: environment:
BACKUP_NAME: myvolume # required
SCHEDULE: '@weekly' # optional SCHEDULE: '@weekly' # optional
BACKUP_KEEP_DAYS: 7 # optional BACKUP_KEEP_DAYS: 7 # optional
PASSPHRASE: passphrase # optional PASSPHRASE: passphrase # optional
S3_REGION: region S3_REGION: region # or set S3_ENDPOINT if you do not use AWS
S3_ACCESS_KEY_ID: key S3_ACCESS_KEY_ID: key # alias S3_ACCESS_KEY
S3_SECRET_ACCESS_KEY: secret S3_SECRET_ACCESS_KEY: secret # alias S3_SECRET_KEY
S3_BUCKET: my-bucket S3_BUCKET: my-bucket # required
S3_PREFIX: backup S3_PREFIX: backup # required
``` ```
- You can mount as many folders into `/data` as you like. Everything in `/data` is copied to your S3 storage in a single `.tar.gz`.
- The `SCHEDULE` variable determines backup frequency. See go-cron schedules documentation [here](http://godoc.org/github.com/robfig/cron#hdr-Predefined_schedules). Omit to run the backup immediately and then exit. - The `SCHEDULE` variable determines backup frequency. See go-cron schedules documentation [here](http://godoc.org/github.com/robfig/cron#hdr-Predefined_schedules). Omit to run the backup immediately and then exit.
- If `PASSPHRASE` is provided, the backup will be encrypted using GPG. - If `PASSPHRASE` is provided, the backup will be encrypted using GPG.
- Run `docker exec <container_name> sh backup.sh` to trigger a backup ad-hoc. - Run `docker exec <container_name> sh backup.sh` to trigger a backup ad-hoc.

View File

@ -4,16 +4,22 @@
# $ docker compose up -d --build --force-recreate # $ docker compose up -d --build --force-recreate
services: services:
test: test_image:
build: test_image build: ./test_image
volumes: volumes:
- data:/data - data:/data
backup: backup:
build: . build: .
env_file: .env env_file: .env
volumes:
- data:/data/testdir
environment: environment:
BACKUP_NAME: backup-test
SCHEDULE: '* * * * *' SCHEDULE: '* * * * *'
BACKUP_KEEP_DAYS: 7 BACKUP_KEEP_DAYS: 7
PASSPHRASE: passphrase PASSPHRASE: passphrase
S3_PREFIX: backup-test S3_PREFIX: backup-test
volumes:
data:

View File

@ -6,7 +6,7 @@ set -o pipefail
source ./env.sh source ./env.sh
echo "Creating backup..." echo "Creating backup..."
tar -xzf dump.tar.gz /data tar -czf dump.tar.gz /data
timestamp=$(date +"%Y-%m-%dT%H:%M:%S") timestamp=$(date +"%Y-%m-%dT%H:%M:%S")
s3_uri_base="s3://${S3_BUCKET}/${S3_PREFIX}/${BACKUP_NAME}_${timestamp}.dump" s3_uri_base="s3://${S3_BUCKET}/${S3_PREFIX}/${BACKUP_NAME}_${timestamp}.dump"

View File

@ -1,3 +1,5 @@
FROM scratch FROM alpine:3.21
COPY data/ /data COPY data/ /data
ENTRYPOINT ["/bin/sh", "-c", "while sleep 3600; do :; done"]