From 184b7a1e187804f0c88f24842e2658493c0d669b Mon Sep 17 00:00:00 2001 From: Frederik Ring Date: Sat, 11 Sep 2021 10:30:36 +0200 Subject: [PATCH] add docs on one off backups using docker cli --- README.md | 22 +++++++++++++++++++++- test/cli/run.sh | 9 +++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b20a8d1..2117647 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,13 @@ Backup Docker volumes locally or to any S3 compatible storage. The [offen/docker-volume-backup](https://hub.docker.com/r/offen/docker-volume-backup) Docker image can be used as a lightweight (below 15MB) sidecar container to an existing Docker setup. -It handles __recurring or one-off backups of Docker volumes__ to a __local directory__ or __any S3 compatible storage__ (or both), and __rotates away old backups__ if configured. It also supports __encrypting your backups using GPG__. +It handles __recurring or one-off backups of Docker volumes__ to a __local directory__ or __any S3 compatible storage__ (or both), and __rotates away old backups__ if configured. It also supports __encrypting your backups using GPG__ and __sending notifications for failed backup runs__. - [Quickstart](#quickstart) + - [Recurring backups in a compose setup](#recurring-backups-in-a-compose-setup) + - [One-off backups using Docker CLI](#one-off-backups-using-docker-cli) - [Configuration reference](#configuration-reference) - [How to](#how-to) - [Stopping containers during backup](#stopping-containers-during-backup) @@ -38,6 +40,8 @@ Code and documentation for `v1` versions are found on [this branch][v1-branch]. ## Quickstart +### Recurring backups in a compose setup + Add a `backup` service to your compose setup and mount the volumes you would like to see backed up: ```yml @@ -78,6 +82,22 @@ volumes: data: ``` +### One-off backups using Docker CLI + +To run a one time backup, mount the volume you would like to see backed up into a container and run the `backup` command: + +```console +docker run --rm \ + -v data:/backup/data \ + --env AWS_ACCESS_KEY_ID="" \ + --env AWS_SECRET_ACCESS_KEY="" \ + --env AWS_S3_BUCKET_NAME="" \ + --entrypoint backup \ + offen/docker-volume-backup:latest +``` + +Alternatively, pass a `--env-file` in order to use a full config as described below. + ## Configuration reference Backup targets, schedule and retention are configured in environment variables. diff --git a/test/cli/run.sh b/test/cli/run.sh index 9b3f1d7..993c773 100755 --- a/test/cli/run.sh +++ b/test/cli/run.sh @@ -29,8 +29,7 @@ docker run -d \ sleep 10 -docker run -d \ - --name backup \ +docker run --rm \ --network test_network \ -v app_data:/backup/app_data \ -v /var/run/docker.sock:/var/run/docker.sock \ @@ -40,18 +39,16 @@ docker run -d \ --env AWS_ENDPOINT_PROTO=http \ --env AWS_S3_BUCKET_NAME=backup \ --env BACKUP_FILENAME=test.tar.gz \ - --env BACKUP_CRON_EXPRESSION="0 0 5 31 2 ?" \ + --entrypoint backup \ offen/docker-volume-backup:$TEST_VERSION -docker exec backup backup - docker run --rm -it \ -v backup_data:/data alpine \ ash -c 'tar -xvf /data/backup/test.tar.gz && test -f /backup/app_data/offen.db' echo "[TEST:PASS] Found relevant files in untared backup." -if [ "$(docker ps -q | wc -l)" != "3" ]; then +if [ "$(docker ps -q | wc -l)" != "2" ]; then echo "[TEST:FAIL] Expected all containers to be running post backup, instead seen:" docker ps exit 1