mirror of
https://github.com/offen/docker-volume-backup.git
synced 2024-12-25 01:50:22 +01:00
Docs site (#269)
* Set up documentation site using jekyll * Add workflow for deploying docs * Ini formatting is hard to read * Add instructions on how to run docs locally * Work through docs * Remove content from README * Miscellaneous fixes * Fix artifact upload
This commit is contained in:
parent
336c5bed71
commit
0bb94a2f56
53
.github/workflows/deploy-docs.yml
vendored
Normal file
53
.github/workflows/deploy-docs.yml
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
name: Deploy Documenation site to GitHub Pages
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['main']
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
concurrency:
|
||||
group: 'pages'
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Setup Ruby
|
||||
working-directory: docs
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: '3.2'
|
||||
bundler-cache: true
|
||||
cache-version: 0
|
||||
- name: Setup Pages
|
||||
id: pages
|
||||
working-directory: docs
|
||||
uses: actions/configure-pages@v2
|
||||
- name: Build with Jekyll
|
||||
working-directory: docs
|
||||
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
|
||||
env:
|
||||
JEKYLL_ENV: production
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v1
|
||||
with:
|
||||
path: 'docs/_site/'
|
||||
|
||||
deploy:
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v1
|
2
docs/.gitignore
vendored
Normal file
2
docs/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
_site
|
||||
.jekyll-cache
|
4
docs/Gemfile
Normal file
4
docs/Gemfile
Normal file
@ -0,0 +1,4 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem "jekyll", "~> 4.3.2"
|
||||
gem "just-the-docs", "0.6.1"
|
80
docs/Gemfile.lock
Normal file
80
docs/Gemfile.lock
Normal file
@ -0,0 +1,80 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
addressable (2.8.5)
|
||||
public_suffix (>= 2.0.2, < 6.0)
|
||||
colorator (1.1.0)
|
||||
concurrent-ruby (1.2.2)
|
||||
em-websocket (0.5.3)
|
||||
eventmachine (>= 0.12.9)
|
||||
http_parser.rb (~> 0)
|
||||
eventmachine (1.2.7)
|
||||
ffi (1.15.5)
|
||||
forwardable-extended (2.6.0)
|
||||
http_parser.rb (0.8.0)
|
||||
i18n (1.14.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jekyll (4.3.2)
|
||||
addressable (~> 2.4)
|
||||
colorator (~> 1.0)
|
||||
em-websocket (~> 0.5)
|
||||
i18n (~> 1.0)
|
||||
jekyll-sass-converter (>= 2.0, < 4.0)
|
||||
jekyll-watch (~> 2.0)
|
||||
kramdown (~> 2.3, >= 2.3.1)
|
||||
kramdown-parser-gfm (~> 1.0)
|
||||
liquid (~> 4.0)
|
||||
mercenary (>= 0.3.6, < 0.5)
|
||||
pathutil (~> 0.9)
|
||||
rouge (>= 3.0, < 5.0)
|
||||
safe_yaml (~> 1.0)
|
||||
terminal-table (>= 1.8, < 4.0)
|
||||
webrick (~> 1.7)
|
||||
jekyll-include-cache (0.2.1)
|
||||
jekyll (>= 3.7, < 5.0)
|
||||
jekyll-sass-converter (2.2.0)
|
||||
sassc (> 2.0.1, < 3.0)
|
||||
jekyll-seo-tag (2.8.0)
|
||||
jekyll (>= 3.8, < 5.0)
|
||||
jekyll-watch (2.2.1)
|
||||
listen (~> 3.0)
|
||||
just-the-docs (0.6.1)
|
||||
jekyll (>= 3.8.5)
|
||||
jekyll-include-cache
|
||||
jekyll-seo-tag (>= 2.0)
|
||||
rake (>= 12.3.1)
|
||||
kramdown (2.4.0)
|
||||
rexml
|
||||
kramdown-parser-gfm (1.1.0)
|
||||
kramdown (~> 2.0)
|
||||
liquid (4.0.4)
|
||||
listen (3.8.0)
|
||||
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||
rb-inotify (~> 0.9, >= 0.9.10)
|
||||
mercenary (0.4.0)
|
||||
pathutil (0.16.2)
|
||||
forwardable-extended (~> 2.6)
|
||||
public_suffix (4.0.7)
|
||||
rake (13.0.6)
|
||||
rb-fsevent (0.11.2)
|
||||
rb-inotify (0.10.1)
|
||||
ffi (~> 1.0)
|
||||
rexml (3.2.6)
|
||||
rouge (3.30.0)
|
||||
safe_yaml (1.0.5)
|
||||
sassc (2.4.0)
|
||||
ffi (~> 1.9)
|
||||
terminal-table (3.0.2)
|
||||
unicode-display_width (>= 1.1.1, < 3)
|
||||
unicode-display_width (2.4.2)
|
||||
webrick (1.8.1)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
jekyll (~> 4.3.2)
|
||||
just-the-docs (= 0.6.1)
|
||||
|
||||
BUNDLED WITH
|
||||
2.1.4
|
@ -1,40 +0,0 @@
|
||||
# Notification templates reference
|
||||
|
||||
In order to customize title and body of notifications you'll have to write a [go template](https://pkg.go.dev/text/template) and mount it inside the `/etc/dockervolumebackup/notifications.d/` directory.
|
||||
|
||||
Configuration, data about the backup run and helper functions will be passed to this template, this page documents them fully.
|
||||
|
||||
## Data
|
||||
Here is a list of all data passed to the template:
|
||||
|
||||
* `Config`: this object holds the configuration that has been passed to the script. The field names are the name of the recognized environment variables converted in PascalCase. (e.g. `BACKUP_STOP_CONTAINER_LABEL` becomes `BackupStopContainerLabel`)
|
||||
* `Error`: the error that made the backup fail. Only available in the `title_failure` and `body_failure` templates
|
||||
* `Stats`: objects that holds stats regarding script execution. In case of an unsuccessful run, some information may not be available.
|
||||
* `StartTime`: time when the script started execution
|
||||
* `EndTime`: time when the backup has completed successfully (after pruning)
|
||||
* `TookTime`: amount of time it took for the backup to run. (equal to `EndTime - StartTime`)
|
||||
* `LockedTime`: amount of time it took for the backup to acquire the exclusive lock
|
||||
* `LogOutput`: full log of the application
|
||||
* `Containers`: object containing stats about the docker containers
|
||||
* `All`: total number of containers
|
||||
* `ToStop`: number of containers matched by the stop rule
|
||||
* `Stopped`: number of containers successfully stopped
|
||||
* `StopErrors`: number of containers that were unable to be stopped (equal to `ToStop - Stopped`)
|
||||
* `BackupFile`: object containing information about the backup file
|
||||
* `Name`: name of the backup file (e.g. `backup-2022-02-11T01-00-00.tar.gz`)
|
||||
* `FullPath`: full path of the backup file (e.g. `/archive/backup-2022-02-11T01-00-00.tar.gz`)
|
||||
* `Size`: size in bytes of the backup file
|
||||
* `Storages`: object that holds stats about each storage
|
||||
* `Local`, `S3`, `WebDAV`, `Azure`, `Dropbox` or `SSH`:
|
||||
* `Total`: total number of backup files
|
||||
* `Pruned`: number of backup files that were deleted due to pruning rule
|
||||
* `PruneErrors`: number of backup files that were unable to be pruned
|
||||
|
||||
## Functions
|
||||
|
||||
Some formatting and helper functions are also available:
|
||||
|
||||
* `formatTime`: formats a time object using [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339) format (e.g. `2022-02-11T01:00:00Z`)
|
||||
* `formatBytesBin`: formats an amount of bytes using powers of 1024 (e.g. `7055258` bytes will be `6.7 MiB`)
|
||||
* `formatBytesDec`: formats an amount of bytes using powers of 1000 (e.g. `7055258` bytes will be `7.1 MB`)
|
||||
* `env`: returns the value of the environment variable of the given key if set
|
14
docs/README.md
Normal file
14
docs/README.md
Normal file
@ -0,0 +1,14 @@
|
||||
# Documentation site
|
||||
|
||||
This directory contains the sources for the documentation site published at <https://offen.github.io/docker-volume-backup>.
|
||||
|
||||
Assuming you have Ruby and [`bundler`][bundler] installed, you can run the site locally using the following commands:
|
||||
|
||||
```
|
||||
bundle install
|
||||
bundle exec jekyll serve
|
||||
```
|
||||
|
||||
Note that changes in `_config.yml` require a manual restart to take effect.
|
||||
|
||||
[bundler]: https://bundler.io/
|
35
docs/_config.yml
Normal file
35
docs/_config.yml
Normal file
@ -0,0 +1,35 @@
|
||||
title: docker-volume-backup
|
||||
description: Documentation for the offen/docker-volume-backup Docker image.
|
||||
theme: just-the-docs
|
||||
|
||||
url: https://offen.github.io/docker-volume-backup/
|
||||
|
||||
callouts_level: quiet
|
||||
callouts:
|
||||
highlight:
|
||||
color: yellow
|
||||
important:
|
||||
title: Important
|
||||
color: blue
|
||||
new:
|
||||
title: New
|
||||
color: green
|
||||
note:
|
||||
title: Note
|
||||
color: purple
|
||||
warning:
|
||||
title: Warning
|
||||
color: red
|
||||
|
||||
aux_links:
|
||||
'GitHub Repository':
|
||||
- https://github.com/offen/docker-volume-backup
|
||||
|
||||
nav_external_links:
|
||||
- title: GitHub Repository
|
||||
url: https://github.com/offen/docker-volume-backup
|
||||
|
||||
footer_content: >-
|
||||
Copyright © 2021 Offen Authors and contributors.
|
||||
Distributed under the <a href="https://github.com/offen/docker-volume-backup/tree/main/LICENSE">MPL-2.0 License.</a><br>
|
||||
Something missing, unclear or not working? Open <a href="https://github.com/offen/docker-volume-backup/issues">an issue</a>.
|
7
docs/_sass/custom/custom.scss
Normal file
7
docs/_sass/custom/custom.scss
Normal file
@ -0,0 +1,7 @@
|
||||
.site-title {
|
||||
font-size: unset !important;
|
||||
}
|
||||
|
||||
.main-content pre {
|
||||
font-size: 1.1em;
|
||||
}
|
34
docs/how-tos/automatically-prune-old-backups.md
Normal file
34
docs/how-tos/automatically-prune-old-backups.md
Normal file
@ -0,0 +1,34 @@
|
||||
---
|
||||
title: Automatically prune old backups
|
||||
layout: default
|
||||
parent: How Tos
|
||||
nav_order: 3
|
||||
---
|
||||
|
||||
# Automatically prune old backups
|
||||
|
||||
When `BACKUP_RETENTION_DAYS` is configured, the command will check if there are any archives in the remote storage backend(s) or local archive that are older than the given retention value and rotate these backups away.
|
||||
|
||||
{: .note }
|
||||
Be aware that this mechanism looks at __all files in the target bucket or archive__, which means that other files that are older than the given deadline are deleted as well.
|
||||
In case you need to use a target that cannot be used exclusively for your backups, you can configure `BACKUP_PRUNING_PREFIX` to limit which files are considered eligible for deletion:
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
# ... define other services using the `data` volume here
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
environment:
|
||||
BACKUP_FILENAME: backup-%Y-%m-%dT%H-%M-%S.tar.gz
|
||||
BACKUP_PRUNING_PREFIX: backup-
|
||||
BACKUP_RETENTION_DAYS: '7'
|
||||
volumes:
|
||||
- ${HOME}/backups:/archive
|
||||
- data:/backup/my-app-backup:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
|
||||
volumes:
|
||||
data:
|
||||
```
|
40
docs/how-tos/define-different-retention-schedules.md
Normal file
40
docs/how-tos/define-different-retention-schedules.md
Normal file
@ -0,0 +1,40 @@
|
||||
---
|
||||
title: Define different retention schedules
|
||||
layout: default
|
||||
parent: How Tos
|
||||
nav_order: 9
|
||||
---
|
||||
|
||||
# Define different retention schedules
|
||||
|
||||
If you want to manage backup retention on different schedules, the most straight forward approach is to define a dedicated configuration for retention rule using a different prefix in the `BACKUP_FILENAME` parameter and then run them on different cron schedules.
|
||||
|
||||
For example, if you wanted to keep daily backups for 7 days, weekly backups for a month, and retain monthly backups forever, you could create three configuration files and mount them into `/etc/dockervolumebackup/conf.d`:
|
||||
|
||||
```ini
|
||||
# 01daily.conf
|
||||
BACKUP_FILENAME="daily-backup-%Y-%m-%dT%H-%M-%S.tar.gz"
|
||||
# run every day at 2am
|
||||
BACKUP_CRON_EXPRESSION="0 2 * * *"
|
||||
BACKUP_PRUNING_PREFIX="daily-backup-"
|
||||
BACKUP_RETENTION_DAYS="7"
|
||||
```
|
||||
|
||||
```ini
|
||||
# 02weekly.conf
|
||||
BACKUP_FILENAME="weekly-backup-%Y-%m-%dT%H-%M-%S.tar.gz"
|
||||
# run every monday at 3am
|
||||
BACKUP_CRON_EXPRESSION="0 3 * * 1"
|
||||
BACKUP_PRUNING_PREFIX="weekly-backup-"
|
||||
BACKUP_RETENTION_DAYS="31"
|
||||
```
|
||||
|
||||
```ini
|
||||
# 03monthly.conf
|
||||
BACKUP_FILENAME="monthly-backup-%Y-%m-%dT%H-%M-%S.tar.gz"
|
||||
# run every 1st of a month at 4am
|
||||
BACKUP_CRON_EXPRESSION="0 4 1 * *"
|
||||
```
|
||||
|
||||
{: .note }
|
||||
While it's possible to define colliding cron schedules for each of these configurations, you might need to adjust the value for `LOCK_TIMEOUT` in case your backups are large and might take longer than an hour.
|
17
docs/how-tos/encrypt-backups-using-gpg.md
Normal file
17
docs/how-tos/encrypt-backups-using-gpg.md
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
title: Encrypt backups using GPG
|
||||
layout: default
|
||||
parent: How Tos
|
||||
nav_order: 7
|
||||
---
|
||||
|
||||
# Encrypt backups using GPG
|
||||
|
||||
The image supports encrypting backups using GPG out of the box.
|
||||
In case a `GPG_PASSPHRASE` environment variable is set, the backup archive will be encrypted using the given key and saved as a `.gpg` file instead.
|
||||
|
||||
Assuming you have `gpg` installed, you can decrypt such a backup using (your OS will prompt for the passphrase before decryption can happen):
|
||||
|
||||
```console
|
||||
gpg -o backup.tar.gz -d backup.tar.gz.gpg
|
||||
```
|
44
docs/how-tos/handle-file-uploads-using-third-party-tools.md
Normal file
44
docs/how-tos/handle-file-uploads-using-third-party-tools.md
Normal file
@ -0,0 +1,44 @@
|
||||
---
|
||||
title: Handle file uploads using third party tools
|
||||
layout: default
|
||||
parent: How Tos
|
||||
nav_order: 10
|
||||
---
|
||||
|
||||
# Handle file uploads using third party tools
|
||||
|
||||
If you want to use an unsupported storage backend, or want to use a third party (e.g. rsync, rclone) tool for file uploads, you can build a Docker image containing the required binaries off this one, and call through to these in lifecycle hooks.
|
||||
|
||||
For example, if you wanted to use `rsync`, define your Docker image like this:
|
||||
|
||||
```Dockerfile
|
||||
FROM offen/docker-volume-backup:v2
|
||||
|
||||
RUN apk add rsync
|
||||
```
|
||||
|
||||
Using this image, you can now omit configuring any of the supported storage backends, and instead define your own mechanism in a `docker-volume-backup.copy-post` label:
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
backup:
|
||||
image: your-custom-image
|
||||
restart: always
|
||||
environment:
|
||||
BACKUP_FILENAME: "daily-backup-%Y-%m-%dT%H-%M-%S.tar.gz"
|
||||
BACKUP_CRON_EXPRESSION: "0 2 * * *"
|
||||
labels:
|
||||
- docker-volume-backup.copy-post=/bin/sh -c 'rsync $$COMMAND_RUNTIME_ARCHIVE_FILEPATH /destination'
|
||||
volumes:
|
||||
- app_data:/backup/app_data:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
|
||||
# other services defined here ...
|
||||
volumes:
|
||||
app_data:
|
||||
```
|
||||
|
||||
{: .note }
|
||||
Commands will be invoked with the filepath of the tar archive passed as `COMMAND_RUNTIME_BACKUP_FILEPATH`.
|
8
docs/how-tos/index.md
Normal file
8
docs/how-tos/index.md
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
title: How Tos
|
||||
layout: default
|
||||
nav_order: 3
|
||||
has_children: true
|
||||
---
|
||||
|
||||
## How Tos
|
20
docs/how-tos/manual-trigger.md
Normal file
20
docs/how-tos/manual-trigger.md
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
title: Trigger a backp manually
|
||||
layout: default
|
||||
parent: How Tos
|
||||
nav_order: 8
|
||||
---
|
||||
|
||||
# Trigger a backup manually
|
||||
|
||||
You can manually trigger a backup run outside of the defined cron schedule by executing the `backup` command inside the container:
|
||||
|
||||
```console
|
||||
docker exec <container_ref> backup
|
||||
```
|
||||
|
||||
If the container is configured to run multiple schedules, you can source the respective conf file before invoking the command:
|
||||
|
||||
```console
|
||||
docker exec <container_ref> /bin/sh -c 'set -a; source /etc/dockervolumebackup/conf.d/myconf.env; set +a && backup'
|
||||
```
|
37
docs/how-tos/replace-deprecated-backup-from-snapshot.md
Normal file
37
docs/how-tos/replace-deprecated-backup-from-snapshot.md
Normal file
@ -0,0 +1,37 @@
|
||||
---
|
||||
title: Replace deprecated BACKUP_FROM_SNAPSHOT usage
|
||||
layout: default
|
||||
parent: How Tos
|
||||
nav_order: 16
|
||||
---
|
||||
|
||||
# Replace deprecated `BACKUP_FROM_SNAPSHOT` usage
|
||||
|
||||
Starting with version 2.15.0, the `BACKUP_FROM_SNAPSHOT` feature has been deprecated.
|
||||
If you need to prepare your sources before the backup is taken, use `archive-pre`, `archive-post` and an intermediate volume:
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
my_app:
|
||||
build: .
|
||||
volumes:
|
||||
- data:/var/my_app
|
||||
- backup:/tmp/backup
|
||||
labels:
|
||||
- docker-volume-backup.archive-pre=cp -r /var/my_app /tmp/backup/my-app
|
||||
- docker-volume-backup.archive-post=rm -rf /tmp/backup/my-app
|
||||
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
environment:
|
||||
BACKUP_SOURCES: /tmp/backup
|
||||
volumes:
|
||||
- backup:/backup:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
|
||||
volumes:
|
||||
data:
|
||||
backup:
|
||||
```
|
23
docs/how-tos/replace-deprecated-exec-labels.md
Normal file
23
docs/how-tos/replace-deprecated-exec-labels.md
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
title: Replace deprecated exec-pre and exec-post labels
|
||||
layout: default
|
||||
parent: How Tos
|
||||
nav_order: 17
|
||||
---
|
||||
|
||||
# Replace deprecated `exec-pre` and `exec-post` labels
|
||||
|
||||
Version 2.19.0 introduced the option to run labeled commands at multiple points in time during the backup lifecycle.
|
||||
In order to be able to use more obvious terminology in the new labels, the existing `exec-pre` and `exec-post` labels have been deprecated.
|
||||
If you want to emulate the existing behavior, all you need to do is change `exec-pre` to `archive-pre` and `exec-post` to `archive-post`:
|
||||
|
||||
```diff
|
||||
labels:
|
||||
- - docker-volume-backup.exec-pre=cp -r /var/my_app /tmp/backup/my-app
|
||||
+ - docker-volume-backup.archive-pre=cp -r /var/my_app /tmp/backup/my-app
|
||||
- - docker-volume-backup.exec-post=rm -rf /tmp/backup/my-app
|
||||
+ - docker-volume-backup.archive-post=rm -rf /tmp/backup/my-app
|
||||
```
|
||||
|
||||
The `EXEC_LABEL` setting and the `docker-volume-backup.exec-label` label stay as is.
|
||||
Check the additional documentation on running commands during the backup lifecycle to find out about further possibilities.
|
46
docs/how-tos/restore-volumes-from-backup.md
Normal file
46
docs/how-tos/restore-volumes-from-backup.md
Normal file
@ -0,0 +1,46 @@
|
||||
---
|
||||
title: Restore volumes from a backup
|
||||
layout: default
|
||||
parent: How Tos
|
||||
nav_order: 6
|
||||
---
|
||||
|
||||
# Restore volumes from a backup
|
||||
|
||||
In case you need to restore a volume from a backup, the most straight forward procedure to do so would be:
|
||||
|
||||
- Stop the container(s) that are using the volume
|
||||
- Untar the backup you want to restore
|
||||
```console
|
||||
tar -C /tmp -xvf backup.tar.gz
|
||||
```
|
||||
- Using a temporary once-off container, mount the volume (the example assumes it's named `data`) and copy over the backup. Make sure you copy the correct path level (this depends on how you mount your volume into the backup container), you might need to strip some leading elements
|
||||
```console
|
||||
docker run -d --name temp_restore_container -v data:/backup_restore alpine
|
||||
docker cp /tmp/backup/data-backup temp_restore_container:/backup_restore
|
||||
docker stop temp_restore_container
|
||||
docker rm temp_restore_container
|
||||
```
|
||||
- Restart the container(s) that are using the volume
|
||||
|
||||
Depending on your setup and the application(s) you are running, this might involve other steps to be taken still.
|
||||
|
||||
---
|
||||
|
||||
If you want to rollback an entire volume to an earlier backup snapshot (recommended for database volumes):
|
||||
|
||||
- Trigger a manual backup if necessary (see `Manually triggering a backup`).
|
||||
- Stop the container(s) that are using the volume.
|
||||
- If volume was initially created using docker-compose, find out exact volume name using:
|
||||
```console
|
||||
docker volume ls
|
||||
```
|
||||
- Remove existing volume (the example assumes it's named `data`):
|
||||
```console
|
||||
docker volume rm data
|
||||
```
|
||||
- Create new volume with the same name and restore a snapshot:
|
||||
```console
|
||||
docker run --rm -it -v data:/backup/my-app-backup -v /path/to/local_backups:/archive:ro alpine tar -xvzf /archive/full_backup_filename.tar.gz
|
||||
```
|
||||
- Restart the container(s) that are using the volume.
|
87
docs/how-tos/run-custom-commands.md
Normal file
87
docs/how-tos/run-custom-commands.md
Normal file
@ -0,0 +1,87 @@
|
||||
---
|
||||
title: Run custom commands during the backup lifecycle
|
||||
layout: default
|
||||
nav_order: 5
|
||||
parent: How Tos
|
||||
---
|
||||
|
||||
# Run custom commands during the backup lifecycle
|
||||
|
||||
In certain scenarios it can be required to run specific commands before and after a backup is taken (e.g. dumping a database).
|
||||
When mounting the Docker socket into the `docker-volume-backup` container, you can define pre- and post-commands that will be run in the context of the target container (it is also possible to run commands inside the `docker-volume-backup` container itself using this feature).
|
||||
Such commands are defined by specifying the command in a `docker-volume-backup.[step]-[pre|post]` label where `step` can be any of the following phases of a backup lifecycle:
|
||||
|
||||
- `archive` (the tar archive is created)
|
||||
- `process` (the tar archive is processed, e.g. encrypted - optional)
|
||||
- `copy` (the tar archive is copied to all configured storages)
|
||||
- `prune` (existing backups are pruned based on the defined ruleset - optional)
|
||||
|
||||
Taking a database dump using `mysqldump` would look like this:
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
# ... define other services using the `data` volume here
|
||||
database:
|
||||
image: mariadb
|
||||
volumes:
|
||||
- backup_data:/tmp/backups
|
||||
labels:
|
||||
- docker-volume-backup.archive-pre=/bin/sh -c 'mysqldump --all-databases > /backups/dump.sql'
|
||||
|
||||
volumes:
|
||||
backup_data:
|
||||
```
|
||||
|
||||
{: .note }
|
||||
Due to Docker limitations, you currently cannot use any kind of redirection in these commands unless you pass the command to `/bin/sh -c` or similar.
|
||||
I.e. instead of using `echo "ok" > ok.txt` you will need to use `/bin/sh -c 'echo "ok" > ok.txt'`.
|
||||
|
||||
If you need fine grained control about which container's commands are run, you can use the `EXEC_LABEL` configuration on your `docker-volume-backup` container:
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
database:
|
||||
image: mariadb
|
||||
volumes:
|
||||
- backup_data:/tmp/backups
|
||||
labels:
|
||||
- docker-volume-backup.archive-pre=/bin/sh -c 'mysqldump --all-databases > /tmp/volume/dump.sql'
|
||||
- docker-volume-backup.exec-label=database
|
||||
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
environment:
|
||||
EXEC_LABEL: database
|
||||
volumes:
|
||||
- data:/backup/dump:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
|
||||
volumes:
|
||||
backup_data:
|
||||
```
|
||||
|
||||
|
||||
The backup procedure is guaranteed to wait for all `pre` or `post` commands to finish before proceeding.
|
||||
However, there are no guarantees about the order in which they are run, which could also happen concurrently.
|
||||
|
||||
By default the backup command is executed by the user provided by the container's image.
|
||||
It is possible to specify a custom user that is used to run commands in dedicated labels with the format `docker-volume-backup.[step]-[pre|post].user`:
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
gitea:
|
||||
image: gitea/gitea
|
||||
volumes:
|
||||
- backup_data:/tmp
|
||||
labels:
|
||||
- docker-volume-backup.archive-pre.user=git
|
||||
- docker-volume-backup.archive-pre=/bin/bash -c 'cd /tmp; /usr/local/bin/gitea dump -c /data/gitea/conf/app.ini -R -f dump.zip'
|
||||
```
|
||||
|
||||
Make sure the user exists and is present in `passwd` inside the target container.
|
52
docs/how-tos/run-multiple-schedules.md
Normal file
52
docs/how-tos/run-multiple-schedules.md
Normal file
@ -0,0 +1,52 @@
|
||||
---
|
||||
title: Run multiple backup schedules in the same container
|
||||
layout: default
|
||||
parent: How Tos
|
||||
nav_order: 11
|
||||
---
|
||||
|
||||
# Run multiple backup schedules in the same container
|
||||
|
||||
Multiple backup schedules with different configuration can be configured by mounting an arbitrary number of configuration files (using the `.env` format) into `/etc/dockervolumebackup/conf.d`:
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
# ... define other services using the `data` volume here
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
volumes:
|
||||
- data:/backup/my-app-backup:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
- ./configuration:/etc/dockervolumebackup/conf.d
|
||||
|
||||
volumes:
|
||||
data:
|
||||
```
|
||||
|
||||
A separate cronjob will be created for each config file.
|
||||
If a configuration value is set both in the global environment as well as in the config file, the config file will take precedence.
|
||||
The `backup` command expects to run on an exclusive lock, so in case you provide the same or overlapping schedules in your cron expressions, the runs will still be executed serially, one after the other.
|
||||
The exact order of schedules that use the same cron expression is not specified.
|
||||
In case you need your schedules to overlap, you need to create a dedicated container for each schedule instead.
|
||||
When changing the configuration, you currently need to manually restart the container for the changes to take effect.
|
||||
|
||||
Set `BACKUP_SOURCES` for each config file to control which subset of volume mounts gets backed up:
|
||||
|
||||
```yml
|
||||
# With a volume configuration like this:
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
- ./configuration:/etc/dockervolumebackup/conf.d
|
||||
- app1_data:/backup/app1_data:ro
|
||||
- app2_data:/backup/app2_data:ro
|
||||
```
|
||||
|
||||
```ini
|
||||
# In the 1st config file:
|
||||
BACKUP_SOURCES=/backup/app1_data
|
||||
|
||||
# In the 2nd config file:
|
||||
BACKUP_SOURCES=/backup/app2_data
|
||||
```
|
27
docs/how-tos/set-container-timezone.md
Normal file
27
docs/how-tos/set-container-timezone.md
Normal file
@ -0,0 +1,27 @@
|
||||
---
|
||||
title: Set the timezone the container runs in
|
||||
layout: default
|
||||
parent: How Tos
|
||||
nav_order: 8
|
||||
---
|
||||
|
||||
# Set the timezone the container runs in
|
||||
|
||||
By default a container based on this image will run in the UTC timezone.
|
||||
As the image is designed to be as small as possible, additional timezone data is not included.
|
||||
In case you want to run your cron rules in your local timezone (respecting DST and similar), you can mount your Docker host's `/etc/timezone` and `/etc/localtime` in read-only mode:
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
volumes:
|
||||
- data:/backup/my-app-backup:ro
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
|
||||
volumes:
|
||||
data:
|
||||
```
|
37
docs/how-tos/set-up-drobox.md
Normal file
37
docs/how-tos/set-up-drobox.md
Normal file
@ -0,0 +1,37 @@
|
||||
---
|
||||
title: Set up Dropbox storage backend
|
||||
layout: default
|
||||
parent: How Tos
|
||||
nav_order: 12
|
||||
---
|
||||
|
||||
# Set up Dropbox storage backend
|
||||
|
||||
## Acquiring authentication tokens
|
||||
|
||||
1. Create a new Dropbox App in the [App Console](https://www.dropbox.com/developers/apps)
|
||||
2. Open your new Dropbox App and set `DROPBOX_APP_KEY` and `DROPBOX_APP_SECRET` in your environment (e.g. docker-compose.yml) accordingly
|
||||
3. Click on `Permissions` in your app and make sure, that the following permissions are cranted (or more):
|
||||
- `files.metadata.write`
|
||||
- `files.metadata.read`
|
||||
- `files.content.write`
|
||||
- `files.content.read`
|
||||
4. Replace APPKEY in `https://www.dropbox.com/oauth2/authorize?client_id=APPKEY&token_access_type=offline&response_type=code` with the app key from step 2
|
||||
5. Visit the URL and confirm the access of your app. This gives you an `auth code` -> save it somewhere!
|
||||
6. Replace AUTHCODE, APPKEY, APPSECRET accordingly and perform the request:
|
||||
```
|
||||
curl https://api.dropbox.com/oauth2/token \
|
||||
-d code=AUTHCODE \
|
||||
-d grant_type=authorization_code \
|
||||
-d client_id=APPKEY \
|
||||
-d client_secret=APPSECRET
|
||||
```
|
||||
7. Execute the request. You will get a JSON formatted reply. Use the value of the `refresh_token` for the last environment variable `DROPBOX_REFRESH_TOKEN`
|
||||
8. You should now have `DROPBOX_APP_KEY`, `DROPBOX_APP_SECRET` and `DROPBOX_REFRESH_TOKEN` set. These don't expire.
|
||||
|
||||
Note: Using the "Generated access token" in the app console is not supported, as it is only very short lived and therefore not suitable for an automatic backup solution. The refresh token handles this automatically - the setup procedure above is only needed once.
|
||||
|
||||
## Other parameters
|
||||
|
||||
Important: If you chose `App folder` access during the creation of your Dropbox app in step 1 above, you can only write in the app's directory!
|
||||
This means, that `DROPBOX_REMOTE_PATH` must start with e.g. `/Apps/YOUR_APP_NAME` or `/Apps/YOUR_APP_NAME/some_sub_dir`
|
125
docs/how-tos/set-up-notifications.md
Normal file
125
docs/how-tos/set-up-notifications.md
Normal file
@ -0,0 +1,125 @@
|
||||
---
|
||||
title: Receive notifications
|
||||
layout: default
|
||||
nav_order: 4
|
||||
parent: How Tos
|
||||
---
|
||||
|
||||
# Receive notifications
|
||||
|
||||
## Send email notifications on failed backup runs
|
||||
|
||||
To send out email notifications on failed backup runs, provide SMTP credentials, a sender and a recipient:
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
environment:
|
||||
# ... other configuration values go here
|
||||
NOTIFICATION_URLS=smtp://me:secret@smtp.example.com:587/?fromAddress=no-reply@example.com&toAddresses=you@example.com
|
||||
```
|
||||
|
||||
Notification backends other than email are also supported.
|
||||
Refer to the documentation of [shoutrrr][shoutrrr-docs] to find out about options and configuration.
|
||||
|
||||
[shoutrrr-docs]: https://containrrr.dev/shoutrrr/0.7/services/overview/
|
||||
|
||||
{: .note }
|
||||
If you also want notifications on successful executions, set `NOTIFICATION_LEVEL` to `info`.
|
||||
|
||||
## Customize notifications
|
||||
|
||||
The title and body of the notifications can be tailored to your needs using [Go templates](https://pkg.go.dev/text/template).
|
||||
Template sources must be mounted inside the container in `/etc/dockervolumebackup/notifications.d/`: any file inside this directory will be parsed.
|
||||
|
||||
```yml
|
||||
services:
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
volumes:
|
||||
- ./customized.template:/etc/dockervolumebackup/notifications.d/01.template
|
||||
```
|
||||
|
||||
The files have to define [nested templates](https://pkg.go.dev/text/template#hdr-Nested_template_definitions) in order to override the original values. An example:
|
||||
|
||||
{% raw %}
|
||||
```
|
||||
{{ define "title_success" -}}
|
||||
✅ Successfully ran backup {{ .Config.BackupStopContainerLabel }}
|
||||
{{- end }}
|
||||
|
||||
{{ define "body_success" -}}
|
||||
▶️ Start time: {{ .Stats.StartTime | formatTime }}
|
||||
⏹️ End time: {{ .Stats.EndTime | formatTime }}
|
||||
⌛ Took time: {{ .Stats.TookTime }}
|
||||
🛑 Stopped containers: {{ .Stats.Containers.Stopped }}/{{ .Stats.Containers.All }} ({{ .Stats.Containers.StopErrors }} errors)
|
||||
⚖️ Backup size: {{ .Stats.BackupFile.Size | formatBytesBin }} / {{ .Stats.BackupFile.Size | formatBytesDec }}
|
||||
🗑️ Pruned backups: {{ .Stats.Storages.Local.Pruned }}/{{ .Stats.Storages.Local.Total }} ({{ .Stats.Storages.Local.PruneErrors }} errors)
|
||||
{{- end }}
|
||||
```
|
||||
{% endraw %}
|
||||
|
||||
Template names that can be overridden are:
|
||||
- `title_success` (the title used for a successful execution)
|
||||
- `body_success` (the body used for a successful execution)
|
||||
- `title_failure` (the title used for a failed execution)
|
||||
- `body_failure` (the body used for a failed execution)
|
||||
|
||||
## Notification templates reference
|
||||
|
||||
Configuration, data about the backup run and helper functions will be passed to these templates, this page documents them fully.
|
||||
|
||||
### Data
|
||||
|
||||
Here is a list of all data passed to the template:
|
||||
|
||||
* `Config`: this object holds the configuration that has been passed to the script. The field names are the name of the recognized environment variables converted in PascalCase. (e.g. `BACKUP_STOP_CONTAINER_LABEL` becomes `BackupStopContainerLabel`)
|
||||
* `Error`: the error that made the backup fail. Only available in the `title_failure` and `body_failure` templates
|
||||
* `Stats`: objects that holds stats regarding script execution. In case of an unsuccessful run, some information may not be available.
|
||||
* `StartTime`: time when the script started execution
|
||||
* `EndTime`: time when the backup has completed successfully (after pruning)
|
||||
* `TookTime`: amount of time it took for the backup to run. (equal to `EndTime - StartTime`)
|
||||
* `LockedTime`: amount of time it took for the backup to acquire the exclusive lock
|
||||
* `LogOutput`: full log of the application
|
||||
* `Containers`: object containing stats about the docker containers
|
||||
* `All`: total number of containers
|
||||
* `ToStop`: number of containers matched by the stop rule
|
||||
* `Stopped`: number of containers successfully stopped
|
||||
* `StopErrors`: number of containers that were unable to be stopped (equal to `ToStop - Stopped`)
|
||||
* `BackupFile`: object containing information about the backup file
|
||||
* `Name`: name of the backup file (e.g. `backup-2022-02-11T01-00-00.tar.gz`)
|
||||
* `FullPath`: full path of the backup file (e.g. `/archive/backup-2022-02-11T01-00-00.tar.gz`)
|
||||
* `Size`: size in bytes of the backup file
|
||||
* `Storages`: object that holds stats about each storage
|
||||
* `Local`, `S3`, `WebDAV`, `Azure`, `Dropbox` or `SSH`:
|
||||
* `Total`: total number of backup files
|
||||
* `Pruned`: number of backup files that were deleted due to pruning rule
|
||||
* `PruneErrors`: number of backup files that were unable to be pruned
|
||||
|
||||
### Functions
|
||||
|
||||
Some formatting and helper functions are also available:
|
||||
|
||||
* `formatTime`: formats a time object using [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339) format (e.g. `2022-02-11T01:00:00Z`)
|
||||
* `formatBytesBin`: formats an amount of bytes using powers of 1024 (e.g. `7055258` bytes will be `6.7 MiB`)
|
||||
* `formatBytesDec`: formats an amount of bytes using powers of 1000 (e.g. `7055258` bytes will be `7.1 MB`)
|
||||
* `env`: returns the value of the environment variable of the given key if set
|
||||
|
||||
## Special characters in notification URLs
|
||||
|
||||
The value given to `NOTIFICATION_URLS` is a comma separated list of URLs.
|
||||
If such a URL contains special characters (e.g. commas) these need to be URL encoded.
|
||||
To obtain an encoded version of your URL, you can use the CLI tool provided by `shoutrrr` (which is the library used for sending notifications):
|
||||
|
||||
```
|
||||
docker run --rm -ti containrrr/shoutrrr generate [service]
|
||||
```
|
||||
|
||||
where service is any of the [supported services][shoutrrr-docs], e.g. for SMTP:
|
||||
|
||||
```
|
||||
docker run --rm -ti containrrr/shoutrrr generate smtp
|
||||
```
|
35
docs/how-tos/stop-containers-during-backup.md
Normal file
35
docs/how-tos/stop-containers-during-backup.md
Normal file
@ -0,0 +1,35 @@
|
||||
---
|
||||
title: Stop containers during backup
|
||||
layout: default
|
||||
parent: How Tos
|
||||
nav_order: 1
|
||||
---
|
||||
|
||||
# Stop containers during backup
|
||||
|
||||
In many cases, it will be desirable to stop the services that are consuming the volume you want to backup in order to ensure data integrity.
|
||||
This image can automatically stop and restart containers and services.
|
||||
By default, any container that is labeled `docker-volume-backup.stop-during-backup=true` will be stopped before the backup is being taken and restarted once it has finished.
|
||||
|
||||
In case you need more fine grained control about which containers should be stopped (e.g. when backing up multiple volumes on different schedules), you can set the `BACKUP_STOP_CONTAINER_LABEL` environment variable and then use the same value for labeling:
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
app:
|
||||
# definition for app ...
|
||||
labels:
|
||||
- docker-volume-backup.stop-during-backup=service1
|
||||
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
environment:
|
||||
BACKUP_STOP_CONTAINER_LABEL: service1
|
||||
volumes:
|
||||
- data:/backup/my-app-backup:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
|
||||
volumes:
|
||||
data:
|
||||
```
|
26
docs/how-tos/update-deprecated-email-config.md
Normal file
26
docs/how-tos/update-deprecated-email-config.md
Normal file
@ -0,0 +1,26 @@
|
||||
---
|
||||
title: Update deprecated email configuration
|
||||
layout: default
|
||||
parent: How Tos
|
||||
nav_order: 18
|
||||
---
|
||||
|
||||
# Update deprecated email configuration
|
||||
|
||||
Starting with version 2.6.0, configuring email notifications using `EMAIL_*` keys has been deprecated.
|
||||
Instead of providing multiple values using multiple keys, you can now provide a single URL for `NOTIFICATION_URLS`.
|
||||
|
||||
Before:
|
||||
```ini
|
||||
EMAIL_NOTIFICATION_RECIPIENT="you@example.com"
|
||||
EMAIL_NOTIFICATION_SENDER="no-reply@example.com"
|
||||
EMAIL_SMTP_HOST="posteo.de"
|
||||
EMAIL_SMTP_PASSWORD="secret"
|
||||
EMAIL_SMTP_USERNAME="me"
|
||||
EMAIL_SMTP_PORT="587"
|
||||
```
|
||||
|
||||
After:
|
||||
```ini
|
||||
NOTIFICATION_URLS=smtp://me:secret@posteo.de:587/?fromAddress=no-reply@example.com&toAddresses=you@example.com
|
||||
```
|
17
docs/how-tos/use-custom-docker-host.md
Normal file
17
docs/how-tos/use-custom-docker-host.md
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
title: Use a custom Docker host
|
||||
layout: default
|
||||
parent: How Tos
|
||||
nav_order: 14
|
||||
---
|
||||
|
||||
# Use a custom Docker host
|
||||
|
||||
If you are interfacing with Docker via TCP, set `DOCKER_HOST` to the correct URL.
|
||||
|
||||
```ini
|
||||
DOCKER_HOST=tcp://docker_socket_proxy:2375
|
||||
```
|
||||
|
||||
In case you are using a socket proxy, it must support `GET` and `POST` requests to the `/containers` endpoint. If you are using Docker Swarm, it must also support the `/services` endpoint. If you are using pre/post backup commands, it must also support the `/exec` endpoint.
|
||||
|
23
docs/how-tos/use-rootless-docker.md
Normal file
23
docs/how-tos/use-rootless-docker.md
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
title: Use with rootless Docker
|
||||
layout: default
|
||||
parent: How Tos
|
||||
nav_order: 15
|
||||
---
|
||||
|
||||
# Use with rootless Docker
|
||||
|
||||
It's also possible to use this image with a [rootless Docker installation][rootless-docker].
|
||||
Instead of mounting `/var/run/docker.sock`, mount the user-specific socket into the container:
|
||||
|
||||
```yml
|
||||
services:
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
# ... configuration omitted
|
||||
volumes:
|
||||
- backup:/backup:ro
|
||||
- /run/user/1000/docker.sock:/var/run/docker.sock:ro
|
||||
```
|
||||
|
||||
[rootless-docker]: https://docs.docker.com/engine/security/rootless/
|
27
docs/how-tos/use-with-docker-swarm.md
Normal file
27
docs/how-tos/use-with-docker-swarm.md
Normal file
@ -0,0 +1,27 @@
|
||||
---
|
||||
title: Use with Docker Swarm
|
||||
layout: default
|
||||
parent: How Tos
|
||||
nav_order: 13
|
||||
---
|
||||
|
||||
# Use with Docker Swarm
|
||||
|
||||
By default, Docker Swarm will restart stopped containers automatically, even when manually stopped.
|
||||
If you plan to have your containers / services stopped during backup, this means you need to apply the `on-failure` restart policy to your service's definitions.
|
||||
A restart policy of `always` is not compatible with this tool.
|
||||
|
||||
---
|
||||
|
||||
When running in Swarm mode, it's also advised to set a hard memory limit on your service (~25MB should be enough in most cases, but if you backup large files above half a gigabyte or similar, you might have to raise this in case the backup exits with `Killed`):
|
||||
|
||||
```yml
|
||||
services:
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
deployment:
|
||||
resources:
|
||||
limits:
|
||||
memory: 25M
|
||||
```
|
||||
|
115
docs/index.md
Normal file
115
docs/index.md
Normal file
@ -0,0 +1,115 @@
|
||||
---
|
||||
title: Home
|
||||
layout: home
|
||||
nav_order: 1
|
||||
---
|
||||
|
||||
# offen/docker-volume-backup
|
||||
{:.no_toc}
|
||||
|
||||
Backup Docker volumes locally or to any S3, WebDAV, Azure Blob Storage, Dropbox or SSH compatible storage.
|
||||
{: .fs-6 .fw-300 }
|
||||
|
||||
---
|
||||
|
||||
The [offen/docker-volume-backup](https://hub.docker.com/r/offen/docker-volume-backup) Docker image can be used as a lightweight (below 15MB) companion container to an existing Docker setup.
|
||||
It handles __recurring or one-off backups of Docker volumes__ to a __local directory__, __any S3, WebDAV, Azure Blob Storage, Dropbox or SSH compatible storage (or any combination thereof) and rotates away old backups__ if configured. It also supports __encrypting your backups using GPG__ and __sending notifications for (failed) backup runs__.
|
||||
|
||||
{: .note }
|
||||
Code and documentation for `v1` versions are found on [this branch][v1-branch].
|
||||
|
||||
[v1-branch]: https://github.com/offen/docker-volume-backup/tree/v1
|
||||
|
||||
---
|
||||
|
||||
1. TOC
|
||||
{:toc}
|
||||
|
||||
## 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
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
volume-consumer:
|
||||
build:
|
||||
context: ./my-app
|
||||
volumes:
|
||||
- data:/var/my-app
|
||||
labels:
|
||||
# This means the container will be stopped during backup to ensure
|
||||
# backup integrity. You can omit this label if stopping during backup
|
||||
# not required.
|
||||
- docker-volume-backup.stop-during-backup=true
|
||||
|
||||
backup:
|
||||
# In production, it is advised to lock your image tag to a proper
|
||||
# release version instead of using `latest`.
|
||||
# Check https://github.com/offen/docker-volume-backup/releases
|
||||
# for a list of available releases.
|
||||
image: offen/docker-volume-backup:latest
|
||||
restart: always
|
||||
env_file: ./backup.env # see below for configuration reference
|
||||
volumes:
|
||||
- data:/backup/my-app-backup:ro
|
||||
# Mounting the Docker socket allows the script to stop and restart
|
||||
# the container during backup. You can omit this if you don't want
|
||||
# to stop the container. In case you need to proxy the socket, you can
|
||||
# also provide a location by setting `DOCKER_HOST` in the container
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
# If you mount a local directory or volume to `/archive` a local
|
||||
# copy of the backup will be stored there. You can override the
|
||||
# location inside of the container by setting `BACKUP_ARCHIVE`.
|
||||
# You can omit this if you do not want to keep local backups.
|
||||
- /path/to/local_backups:/archive
|
||||
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="<xxx>" \
|
||||
--env AWS_SECRET_ACCESS_KEY="<xxx>" \
|
||||
--env AWS_S3_BUCKET_NAME="<xxx>" \
|
||||
--entrypoint backup \
|
||||
offen/docker-volume-backup:v2
|
||||
```
|
||||
|
||||
Alternatively, pass a `--env-file` in order to use a full config as described below.
|
||||
|
||||
### Available image registries
|
||||
|
||||
This Docker image is published to both Docker Hub and the GitHub container registry.
|
||||
Depending on your preferences and needs, you can reference both `offen/docker-volume-backup` as well as `ghcr.io/offen/docker-volume-backup`:
|
||||
|
||||
```
|
||||
docker pull offen/docker-volume-backup:v2
|
||||
docker pull ghcr.io/offen/docker-volume-backup:v2
|
||||
```
|
||||
|
||||
Documentation references Docker Hub, but all examples will work using ghcr.io just as well.
|
||||
|
||||
## Differences to `jareware/docker-volume-backup`
|
||||
|
||||
This image is heavily inspired by `jareware/docker-volume-backup`. We decided to publish this image as a simpler and more lightweight alternative because of the following requirements:
|
||||
|
||||
- The original image is based on `ubuntu` and requires additional tools, making it heavy.
|
||||
This version is roughly 1/25 in compressed size (it's ~15MB).
|
||||
- The original image uses a shell script, when this version is written in Go.
|
||||
- The original image proposed to handle backup rotation through AWS S3 lifecycle policies.
|
||||
This image adds the option to rotate away old backups through the same command so this functionality can also be offered for non-AWS storage backends like MinIO.
|
||||
Local copies of backups can also be pruned once they reach a certain age.
|
||||
- InfluxDB specific functionality from the original image was removed.
|
||||
- `arm64` and `arm/v7` architectures are supported.
|
||||
- Docker in Swarm mode is supported.
|
||||
- Notifications on finished backups are supported.
|
||||
- IAM authentication through instance profiles is supported.
|
373
docs/recipes/index.md
Normal file
373
docs/recipes/index.md
Normal file
@ -0,0 +1,373 @@
|
||||
---
|
||||
title: Recipes
|
||||
layout: default
|
||||
nav_order: 4
|
||||
---
|
||||
|
||||
# Recipes
|
||||
{: .no_toc }
|
||||
|
||||
This doc lists configuration for some real-world use cases that you can copy and paste to tweak and match your needs.
|
||||
|
||||
1. TOC
|
||||
{: toc }
|
||||
|
||||
## Backing up to AWS S3
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
# ... define other services using the `data` volume here
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
environment:
|
||||
AWS_S3_BUCKET_NAME: backup-bucket
|
||||
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
|
||||
AWS_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
|
||||
volumes:
|
||||
- data:/backup/my-app-backup:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
|
||||
volumes:
|
||||
data:
|
||||
```
|
||||
|
||||
## Backing up to Filebase
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
# ... define other services using the `data` volume here
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
environment:
|
||||
AWS_ENDPOINT: s3.filebase.com
|
||||
AWS_S3_BUCKET_NAME: filebase-bucket
|
||||
AWS_ACCESS_KEY_ID: FILEBASE-ACCESS-KEY
|
||||
AWS_SECRET_ACCESS_KEY: FILEBASE-SECRET-KEY
|
||||
volumes:
|
||||
- data:/backup/my-app-backup:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
|
||||
volumes:
|
||||
data:
|
||||
```
|
||||
|
||||
## Backing up to MinIO
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
# ... define other services using the `data` volume here
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
environment:
|
||||
AWS_ENDPOINT: minio.example.com
|
||||
AWS_S3_BUCKET_NAME: backup-bucket
|
||||
AWS_ACCESS_KEY_ID: MINIOACCESSKEY
|
||||
AWS_SECRET_ACCESS_KEY: MINIOSECRETKEY
|
||||
volumes:
|
||||
- data:/backup/my-app-backup:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
|
||||
volumes:
|
||||
data:
|
||||
```
|
||||
|
||||
|
||||
## Backing up to MinIO (using Docker secrets)
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
# ... define other services using the `data` volume here
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
environment:
|
||||
AWS_ENDPOINT: minio.example.com
|
||||
AWS_S3_BUCKET_NAME: backup-bucket
|
||||
AWS_ACCESS_KEY_ID_FILE: /run/secrets/minio_access_key
|
||||
AWS_SECRET_ACCESS_KEY_FILE: /run/secrets/minio_secret_key
|
||||
volumes:
|
||||
- data:/backup/my-app-backup:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
secrets:
|
||||
- minio_access_key
|
||||
- minio_secret_key
|
||||
|
||||
volumes:
|
||||
data:
|
||||
|
||||
secrets:
|
||||
minio_access_key:
|
||||
# ... define how secret is accessed
|
||||
minio_secret_key:
|
||||
# ... define how secret is accessed
|
||||
```
|
||||
|
||||
## Backing up to WebDAV
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
# ... define other services using the `data` volume here
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
environment:
|
||||
WEBDAV_URL: https://webdav.mydomain.me
|
||||
WEBDAV_PATH: /my/directory/
|
||||
WEBDAV_USERNAME: user
|
||||
WEBDAV_PASSWORD: password
|
||||
volumes:
|
||||
- data:/backup/my-app-backup:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
|
||||
volumes:
|
||||
data:
|
||||
```
|
||||
|
||||
## Backing up to SSH
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
# ... define other services using the `data` volume here
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
environment:
|
||||
SSH_HOST_NAME: server.local
|
||||
SSH_PORT: 2222
|
||||
SSH_USER: user
|
||||
SSH_REMOTE_PATH: /data
|
||||
volumes:
|
||||
- data:/backup/my-app-backup:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
- /path/to/private_key:/root/.ssh/id_rsa
|
||||
|
||||
volumes:
|
||||
data:
|
||||
```
|
||||
|
||||
## Backing up to Azure Blob Storage
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
# ... define other services using the `data` volume here
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
environment:
|
||||
AZURE_STORAGE_CONTAINER_NAME: backup-container
|
||||
AZURE_STORAGE_ACCOUNT_NAME: account-name
|
||||
AZURE_STORAGE_PRIMARY_ACCOUNT_KEY: Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
|
||||
volumes:
|
||||
- data:/backup/my-app-backup:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
|
||||
volumes:
|
||||
data:
|
||||
```
|
||||
|
||||
## Backing up to Dropbox
|
||||
|
||||
See [Dropbox Setup](#setup-dropbox-storage-backend) on how to get the appropriate environment values.
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
# ... define other services using the `data` volume here
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
environment:
|
||||
DROPBOX_REFRESH_TOKEN: REFRESH_KEY # replace
|
||||
DROPBOX_APP_KEY: APP_KEY # replace
|
||||
DROPBOX_APP_SECRET: APP_SECRET # replace
|
||||
DROPBOX_REMOTE_PATH: /Apps/my-test-app/some_subdir # replace
|
||||
volumes:
|
||||
- data:/backup/my-app-backup:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
|
||||
volumes:
|
||||
data:
|
||||
```
|
||||
|
||||
## Backing up locally
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
# ... define other services using the `data` volume here
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
environment:
|
||||
BACKUP_FILENAME: backup-%Y-%m-%dT%H-%M-%S.tar.gz
|
||||
BACKUP_LATEST_SYMLINK: backup-latest.tar.gz
|
||||
volumes:
|
||||
- data:/backup/my-app-backup:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
- ${HOME}/backups:/archive
|
||||
|
||||
volumes:
|
||||
data:
|
||||
```
|
||||
|
||||
## Backing up to AWS S3 as well as locally
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
# ... define other services using the `data` volume here
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
environment:
|
||||
AWS_S3_BUCKET_NAME: backup-bucket
|
||||
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
|
||||
AWS_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
|
||||
volumes:
|
||||
- data:/backup/my-app-backup:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
- ${HOME}/backups:/archive
|
||||
|
||||
volumes:
|
||||
data:
|
||||
```
|
||||
|
||||
## Running on a custom cron schedule
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
# ... define other services using the `data` volume here
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
environment:
|
||||
# take a backup on every hour
|
||||
BACKUP_CRON_EXPRESSION: "0 * * * *"
|
||||
AWS_S3_BUCKET_NAME: backup-bucket
|
||||
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
|
||||
AWS_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
|
||||
volumes:
|
||||
- data:/backup/my-app-backup:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
|
||||
volumes:
|
||||
data:
|
||||
```
|
||||
|
||||
## Rotating away backups that are older than 7 days
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
# ... define other services using the `data` volume here
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
environment:
|
||||
AWS_S3_BUCKET_NAME: backup-bucket
|
||||
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
|
||||
AWS_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
|
||||
BACKUP_FILENAME: backup-%Y-%m-%dT%H-%M-%S.tar.gz
|
||||
BACKUP_PRUNING_PREFIX: backup-
|
||||
BACKUP_RETENTION_DAYS: 7
|
||||
volumes:
|
||||
- data:/backup/my-app-backup:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
|
||||
volumes:
|
||||
data:
|
||||
```
|
||||
|
||||
## Encrypting your backups using GPG
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
# ... define other services using the `data` volume here
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
environment:
|
||||
AWS_S3_BUCKET_NAME: backup-bucket
|
||||
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
|
||||
AWS_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
|
||||
GPG_PASSPHRASE: somesecretstring
|
||||
volumes:
|
||||
- data:/backup/my-app-backup:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
|
||||
volumes:
|
||||
data:
|
||||
```
|
||||
|
||||
## Using mysqldump to prepare the backup
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
database:
|
||||
image: mariadb:latest
|
||||
labels:
|
||||
- docker-volume-backup.archive-pre=/bin/sh -c 'mysqldump -psecret --all-databases > /tmp/dumps/dump.sql'
|
||||
volumes:
|
||||
- data:/tmp/dumps
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
environment:
|
||||
BACKUP_FILENAME: db.tar.gz
|
||||
BACKUP_CRON_EXPRESSION: "0 2 * * *"
|
||||
volumes:
|
||||
- ./local:/archive
|
||||
- data:/backup/data:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
|
||||
volumes:
|
||||
data:
|
||||
```
|
||||
|
||||
## Running multiple instances in the same setup
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
# ... define other services using the `data_1` and `data_2` volumes here
|
||||
backup_1: &backup_service
|
||||
image: offen/docker-volume-backup:v2
|
||||
environment: &backup_environment
|
||||
BACKUP_CRON_EXPRESSION: "0 2 * * *"
|
||||
AWS_S3_BUCKET_NAME: backup-bucket
|
||||
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
|
||||
AWS_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
|
||||
# Label the container using the `data_1` volume as `docker-volume-backup.stop-during-backup=service1`
|
||||
BACKUP_STOP_CONTAINER_LABEL: service1
|
||||
volumes:
|
||||
- data_1:/backup/data-1-backup:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
backup_2:
|
||||
<<: *backup_service
|
||||
environment:
|
||||
<<: *backup_environment
|
||||
# Label the container using the `data_2` volume as `docker-volume-backup.stop-during-backup=service2`
|
||||
BACKUP_CRON_EXPRESSION: "0 3 * * *"
|
||||
BACKUP_STOP_CONTAINER_LABEL: service2
|
||||
volumes:
|
||||
- data_2:/backup/data-2-backup:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
|
||||
volumes:
|
||||
data_1:
|
||||
data_2:
|
||||
```
|
417
docs/reference/index.md
Normal file
417
docs/reference/index.md
Normal file
@ -0,0 +1,417 @@
|
||||
---
|
||||
title: Configuration Reference
|
||||
layout: default
|
||||
nav_order: 2
|
||||
---
|
||||
|
||||
# Configuration reference
|
||||
|
||||
Backup targets, schedule and retention are configured using environment variables.
|
||||
|
||||
{: .note }
|
||||
You can use any environment variable from below also with a `_FILE` suffix to be able to load the value from a file. This is usually useful when using [Docker Secrets](https://docs.docker.com/engine/swarm/secrets/) or similar.
|
||||
|
||||
{: .warning }
|
||||
In case you encounter double quoted values in your runtime configuration you might still be using an [older version of `docker-compose`][compose-issue].
|
||||
You can work around this by either updating `docker-compose` or unquoting your configuration values.
|
||||
|
||||
You can populate below template according to your requirements and use it as your `env_file`:
|
||||
|
||||
{% raw %}
|
||||
```
|
||||
########### BACKUP SCHEDULE
|
||||
|
||||
# Backups run on the given cron schedule in `busybox` flavor. If no
|
||||
# value is set, `@daily` will be used. If you do not want the cron
|
||||
# to ever run, use `0 0 5 31 2 ?`.
|
||||
|
||||
# BACKUP_CRON_EXPRESSION="0 2 * * *"
|
||||
|
||||
# The compression algorithm used in conjunction with tar.
|
||||
# Valid options are: "gz" (Gzip) and "zst" (Zstd).
|
||||
# Note that the selection affects the file extension.
|
||||
|
||||
# BACKUP_COMPRESSION="gz"
|
||||
|
||||
# Parallelism level for "gz" (Gzip) compression.
|
||||
# Defines how many blocks of data are concurrently processed.
|
||||
# Higher values result in faster compression. No effect on decompression
|
||||
# Default = 1. Setting this to 0 will use all available threads.
|
||||
|
||||
# GZIP_PARALLELISM=1
|
||||
|
||||
# The name of the backup file including the extension.
|
||||
# Format verbs will be replaced as in `strftime`. Omitting them
|
||||
# will result in the same filename for every backup run, which means previous
|
||||
# versions will be overwritten on subsequent runs.
|
||||
# Extension can be defined literally or via "{{ .Extension }}" template,
|
||||
# in which case it will become either "tar.gz" or "tar.zst" (depending
|
||||
# on your BACKUP_COMPRESSION setting).
|
||||
# The default results in filenames like: `backup-2021-08-29T04-00-00.tar.gz`.
|
||||
|
||||
# BACKUP_FILENAME="backup-%Y-%m-%dT%H-%M-%S.{{ .Extension }}"
|
||||
|
||||
# Setting BACKUP_FILENAME_EXPAND to true allows for environment variable
|
||||
# placeholders in BACKUP_FILENAME, BACKUP_LATEST_SYMLINK and in
|
||||
# BACKUP_PRUNING_PREFIX that will get expanded at runtime,
|
||||
# e.g. `backup-$HOSTNAME-%Y-%m-%dT%H-%M-%S.tar.gz`. Expansion happens before
|
||||
# interpolating strftime tokens. It is disabled by default.
|
||||
# Please note that you will need to escape the `$` when providing the value
|
||||
# in a docker-compose.yml file, i.e. using $$VAR instead of $VAR.
|
||||
|
||||
# BACKUP_FILENAME_EXPAND="true"
|
||||
|
||||
# When storing local backups, a symlink to the latest backup can be created
|
||||
# in case a value is given for this key. This has no effect on remote backups.
|
||||
|
||||
# BACKUP_LATEST_SYMLINK="backup.latest.tar.gz"
|
||||
|
||||
# ************************************************************************
|
||||
# The BACKUP_FROM_SNAPSHOT option has been deprecated and will be removed
|
||||
# in the next major version. Please use exec-pre and exec-post
|
||||
# as documented below instead.
|
||||
# ************************************************************************
|
||||
# Whether to copy the content of backup folder before creating the tar archive.
|
||||
# In the rare scenario where the content of the source backup volume is continuously
|
||||
# updating, but we do not wish to stop the container while performing the backup,
|
||||
# this setting can be used to ensure the integrity of the tar.gz file.
|
||||
|
||||
# BACKUP_FROM_SNAPSHOT="false"
|
||||
|
||||
# By default, the `/backup` directory inside the container will be backed up.
|
||||
# In case you need to use a custom location, set `BACKUP_SOURCES`.
|
||||
|
||||
# BACKUP_SOURCES="/other/location"
|
||||
|
||||
# When given, all files in BACKUP_SOURCES whose full path matches the given
|
||||
# regular expression will be excluded from the archive. Regular Expressions
|
||||
# can be used as from the Go standard library https://pkg.go.dev/regexp
|
||||
|
||||
# BACKUP_EXCLUDE_REGEXP="\.log$"
|
||||
|
||||
# Exclude one or many storage backends from the pruning process.
|
||||
# E.g. with one backend excluded: BACKUP_SKIP_BACKENDS_FROM_PRUNE=s3
|
||||
# E.g. with multiple backends excluded: BACKUP_SKIP_BACKENDS_FROM_PRUNE=s3,webdav
|
||||
# Available backends are: S3, WebDAV, SSH, Local, Dropbox, Azure
|
||||
# Note: The name of the backends is case insensitive.
|
||||
# Default: All backends get pruned.
|
||||
|
||||
# BACKUP_SKIP_BACKENDS_FROM_PRUNE=
|
||||
|
||||
########### BACKUP STORAGE
|
||||
|
||||
# The name of the remote bucket that should be used for storing backups. If
|
||||
# this is not set, no remote backups will be stored.
|
||||
|
||||
# AWS_S3_BUCKET_NAME="backup-bucket"
|
||||
|
||||
# If you want to store the backup in a non-root location on your bucket
|
||||
# you can provide a path. The path must not contain a leading slash.
|
||||
|
||||
# AWS_S3_PATH="my/backup/location"
|
||||
|
||||
# Define credentials for authenticating against the backup storage and a bucket
|
||||
# name. Although all of these keys are `AWS`-prefixed, the setup can be used
|
||||
# with any S3 compatible storage.
|
||||
|
||||
# AWS_ACCESS_KEY_ID="<xxx>"
|
||||
# AWS_SECRET_ACCESS_KEY="<xxx>"
|
||||
|
||||
# Instead of providing static credentials, you can also use IAM instance profiles
|
||||
# or similar to provide authentication. Some possible configuration options on AWS:
|
||||
# - EC2: http://169.254.169.254
|
||||
# - ECS: http://169.254.170.2
|
||||
|
||||
# AWS_IAM_ROLE_ENDPOINT="http://169.254.169.254"
|
||||
|
||||
# This is the FQDN of your storage server, e.g. `storage.example.com`.
|
||||
# Do not set this when working against AWS S3 (the default value is
|
||||
# `s3.amazonaws.com`). If you need to set a specific (non-https) protocol, you
|
||||
# will need to use the option below.
|
||||
|
||||
# AWS_ENDPOINT="storage.example.com"
|
||||
|
||||
# The protocol to be used when communicating with your storage server.
|
||||
# Defaults to "https". You can set this to "http" when communicating with
|
||||
# a different Docker container on the same host for example.
|
||||
|
||||
# AWS_ENDPOINT_PROTO="https"
|
||||
|
||||
# Setting this variable to `true` will disable verification of
|
||||
# SSL certificates for AWS_ENDPOINT. You shouldn't use this unless you use
|
||||
# self-signed certificates for your remote storage backend. This can only be
|
||||
# used when AWS_ENDPOINT_PROTO is set to `https`.
|
||||
|
||||
# AWS_ENDPOINT_INSECURE="true"
|
||||
|
||||
# If you wish to use self signed certificates your S3 server, you can pass
|
||||
# the location of a PEM encoded CA certificate and it will be used for
|
||||
# validating your certificates.
|
||||
# Alternatively, pass a PEM encoded string containing the certificate.
|
||||
|
||||
# AWS_ENDPOINT_CA_CERT="/path/to/cert.pem"
|
||||
|
||||
# Setting this variable will change the S3 storage class header.
|
||||
# Defaults to "STANDARD", you can set this value according to your needs.
|
||||
|
||||
# AWS_STORAGE_CLASS="GLACIER"
|
||||
|
||||
# Setting this variable will change the S3 default part size for the copy step.
|
||||
# This value is useful when you want to upload large files.
|
||||
# NB : While using Scaleway as S3 provider, be aware that the parts counter is set to 1.000.
|
||||
# While Minio uses a hard coded value to 10.000. As a workaround, try to set a higher value.
|
||||
# Defaults to "16" (MB) if unset (from minio), you can set this value according to your needs.
|
||||
# The unit is in MB and an integer.
|
||||
|
||||
# AWS_PART_SIZE=16
|
||||
|
||||
# You can also backup files to any WebDAV server:
|
||||
|
||||
# The URL of the remote WebDAV server
|
||||
|
||||
# WEBDAV_URL="https://webdav.example.com"
|
||||
|
||||
# The Directory to place the backups to on the WebDAV server.
|
||||
# If the path is not present on the server it will be created.
|
||||
|
||||
# WEBDAV_PATH="/my/directory/"
|
||||
|
||||
# The username for the WebDAV server
|
||||
|
||||
# WEBDAV_USERNAME="user"
|
||||
|
||||
# The password for the WebDAV server
|
||||
|
||||
# WEBDAV_PASSWORD="password"
|
||||
|
||||
# Setting this variable to `true` will disable verification of
|
||||
# SSL certificates for WEBDAV_URL. You shouldn't use this unless you use
|
||||
# self-signed certificates for your remote storage backend.
|
||||
|
||||
# WEBDAV_URL_INSECURE="true"
|
||||
|
||||
# You can also backup files to any SSH server:
|
||||
|
||||
# The URL of the remote SSH server
|
||||
|
||||
# SSH_HOST_NAME="server.local"
|
||||
|
||||
# The port of the remote SSH server
|
||||
# Optional variable default value is `22`
|
||||
|
||||
# SSH_PORT=2222
|
||||
|
||||
# The Directory to place the backups to on the SSH server.
|
||||
|
||||
# SSH_REMOTE_PATH="/my/directory/"
|
||||
|
||||
# The username for the SSH server
|
||||
|
||||
# SSH_USER="user"
|
||||
|
||||
# The password for the SSH server
|
||||
|
||||
# SSH_PASSWORD="password"
|
||||
|
||||
# The private key path in container for SSH server
|
||||
# Default value: /root/.ssh/id_rsa
|
||||
# If file is mounted to /root/.ssh/id_rsa path it will be used. Non-RSA keys will
|
||||
# also work.
|
||||
|
||||
# SSH_IDENTITY_FILE="/root/.ssh/id_rsa"
|
||||
|
||||
# The passphrase for the identity file
|
||||
|
||||
# SSH_IDENTITY_PASSPHRASE="pass"
|
||||
|
||||
# The credential's account name when using Azure Blob Storage. This has to be
|
||||
# set when using Azure Blob Storage.
|
||||
|
||||
# AZURE_STORAGE_ACCOUNT_NAME="account-name"
|
||||
|
||||
# The credential's primary account key when using Azure Blob Storage. If this
|
||||
# is not given, the command tries to fall back to using a managed identity.
|
||||
|
||||
# AZURE_STORAGE_PRIMARY_ACCOUNT_KEY="<xxx>"
|
||||
|
||||
# The container name when using Azure Blob Storage.
|
||||
|
||||
# AZURE_STORAGE_CONTAINER_NAME="container-name"
|
||||
|
||||
# The service endpoint when using Azure Blob Storage. This is a template that
|
||||
# can be passed the account name as shown in the default value below.
|
||||
|
||||
# AZURE_STORAGE_ENDPOINT="https://{{ .AccountName }}.blob.core.windows.net/"
|
||||
|
||||
# Absolute remote path in your Dropbox where the backups shall be stored.
|
||||
# Note: Use your app's subpath in Dropbox, if it doesn't have global access.
|
||||
# Consulte the README for further information.
|
||||
|
||||
# DROPBOX_REMOTE_PATH="/my/directory"
|
||||
|
||||
# Number of concurrent chunked uploads for Dropbox.
|
||||
# Values above 6 usually result in no enhancements.
|
||||
|
||||
# DROPBOX_CONCURRENCY_LEVEL="6"
|
||||
|
||||
# App key and app secret from your app created at https://www.dropbox.com/developers/apps/info
|
||||
|
||||
# DROPBOX_APP_KEY=""
|
||||
# DROPBOX_APP_SECRET=""
|
||||
|
||||
# Refresh token to request new short-lived tokens (OAuth2). Consult README to see how to get one.
|
||||
|
||||
# DROPBOX_REFRESH_TOKEN=""
|
||||
|
||||
# In addition to storing backups remotely, you can also keep local copies.
|
||||
# Pass a container-local path to store your backups if needed. You also need to
|
||||
# mount a local folder or Docker volume into that location (`/archive`
|
||||
# by default) when running the container. In case the specified directory does
|
||||
# not exist (nothing is mounted) in the container when the backup is running,
|
||||
# local backups will be skipped. Local paths are also be subject to pruning of
|
||||
# old backups as defined below.
|
||||
|
||||
# BACKUP_ARCHIVE="/archive"
|
||||
|
||||
########### BACKUP PRUNING
|
||||
|
||||
# **IMPORTANT, PLEASE READ THIS BEFORE USING THIS FEATURE**:
|
||||
# The mechanism used for pruning old backups is not very sophisticated
|
||||
# and applies its rules to **all files in the target directory** by default,
|
||||
# which means that if you are storing your backups next to other files,
|
||||
# these might become subject to deletion too. When using this option
|
||||
# make sure the backup files are stored in a directory used exclusively
|
||||
# for such files, or to configure BACKUP_PRUNING_PREFIX to limit
|
||||
# removal to certain files.
|
||||
|
||||
# Define this value to enable automatic rotation of old backups. The value
|
||||
# declares the number of days for which a backup is kept.
|
||||
|
||||
# BACKUP_RETENTION_DAYS="7"
|
||||
|
||||
# In case the duration a backup takes fluctuates noticeably in your setup
|
||||
# you can adjust this setting to make sure there are no race conditions
|
||||
# between the backup finishing and the rotation not deleting backups that
|
||||
# sit on the edge of the time window. Set this value to a duration
|
||||
# that is expected to be bigger than the maximum difference of backups.
|
||||
# Valid values have a suffix of (s)econds, (m)inutes or (h)ours. By default,
|
||||
# one minute is used.
|
||||
|
||||
# BACKUP_PRUNING_LEEWAY="1m"
|
||||
|
||||
# In case your target bucket or directory contains other files than the ones
|
||||
# managed by this container, you can limit the scope of rotation by setting
|
||||
# a prefix value. This would usually be the non-parametrized part of your
|
||||
# BACKUP_FILENAME. E.g. if BACKUP_FILENAME is `db-backup-%Y-%m-%dT%H-%M-%S.tar.gz`,
|
||||
# you can set BACKUP_PRUNING_PREFIX to `db-backup-` and make sure
|
||||
# unrelated files are not affected by the rotation mechanism.
|
||||
|
||||
# BACKUP_PRUNING_PREFIX="backup-"
|
||||
|
||||
########### BACKUP ENCRYPTION
|
||||
|
||||
# Backups can be encrypted using gpg in case a passphrase is given.
|
||||
|
||||
# GPG_PASSPHRASE="<xxx>"
|
||||
|
||||
########### STOPPING CONTAINERS DURING BACKUP
|
||||
|
||||
# Containers can be stopped by applying a
|
||||
# `docker-volume-backup.stop-during-backup` label. By default, all containers
|
||||
# that are labeled with `true` will be stopped. If you need more fine grained
|
||||
# control (e.g. when running multiple containers based on this image), you can
|
||||
# override this default by specifying a different value here.
|
||||
|
||||
# BACKUP_STOP_CONTAINER_LABEL="service1"
|
||||
|
||||
########### EXECUTING COMMANDS IN CONTAINERS PRE/POST BACKUP
|
||||
|
||||
# It is possible to define commands to be run in any container before and after
|
||||
# a backup is conducted. The commands themselves are defined in labels like
|
||||
# `docker-volume-backup.archive-pre=/bin/sh -c 'mysqldump [options] > dump.sql'.
|
||||
# Several options exist for controlling this feature:
|
||||
|
||||
# By default, any output of such a command is suppressed. If this value
|
||||
# is configured to be "true", command execution output will be forwarded to
|
||||
# the backup container's stdout and stderr.
|
||||
|
||||
# EXEC_FORWARD_OUTPUT="true"
|
||||
|
||||
# Without any further configuration, all commands defined in labels will be
|
||||
# run before and after a backup. If you need more fine grained control, you
|
||||
# can use this option to set a label that will be used for narrowing down
|
||||
# the set of eligible containers. When set, an eligible container will also need
|
||||
# to be labeled as `docker-volume-backup.exec-label=database`.
|
||||
|
||||
# EXEC_LABEL="database"
|
||||
|
||||
########### NOTIFICATIONS
|
||||
|
||||
# Notifications (email, Slack, etc.) can be sent out when a backup run finishes.
|
||||
# Configuration is provided as a comma-separated list of URLs as consumed
|
||||
# by `shoutrrr`: https://containrrr.dev/shoutrrr/0.7/services/overview/
|
||||
# The content of such notifications can be customized. Dedicated documentation
|
||||
# on how to do this can be found in the README. When providing multiple URLs or
|
||||
# an URL that contains a comma, the values can be URL encoded to avoid ambiguities.
|
||||
|
||||
# The below URL demonstrates how to send an email using the provided SMTP
|
||||
# configuration and credentials.
|
||||
|
||||
# NOTIFICATION_URLS=smtp://username:password@host:587/?fromAddress=sender@example.com&toAddresses=recipient@example.com
|
||||
|
||||
# By default, notifications would only be sent out when a backup run fails
|
||||
# To receive notifications for every run, set `NOTIFICATION_LEVEL` to `info`
|
||||
# instead of the default `error`.
|
||||
|
||||
# NOTIFICATION_LEVEL="error"
|
||||
|
||||
########### DOCKER HOST
|
||||
|
||||
# If you are interfacing with Docker via TCP you can set the Docker host here
|
||||
# instead of mounting the Docker socket as a volume. This is unset by default.
|
||||
|
||||
# DOCKER_HOST="tcp://docker_socket_proxy:2375"
|
||||
|
||||
########### LOCK_TIMEOUT
|
||||
|
||||
# In the case of overlapping cron schedules run by the same container,
|
||||
# subsequent invocations will wait for previous runs to finish before starting.
|
||||
# By default, this will time out and fail in case the lock could not be acquired
|
||||
# after 60 minutes. In case you need to adjust this timeout, supply a duration
|
||||
# value as per https://pkg.go.dev/time#ParseDuration to `LOCK_TIMEOUT`
|
||||
|
||||
# LOCK_TIMEOUT="60m"
|
||||
|
||||
########### EMAIL NOTIFICATIONS
|
||||
|
||||
# ************************************************************************
|
||||
# Providing notification configuration like this has been deprecated
|
||||
# and will be removed in the next major version. Please use NOTIFICATION_URLS
|
||||
# as documented above instead.
|
||||
# ************************************************************************
|
||||
|
||||
# In case SMTP credentials are provided, notification emails can be sent out when
|
||||
# a backup run finished. These emails will contain the start time, the error
|
||||
# message on failure and all prior log output.
|
||||
|
||||
# The recipient(s) of the notification. Supply a comma separated list
|
||||
# of addresses if you want to notify multiple recipients. If this is
|
||||
# not set, no emails will be sent.
|
||||
|
||||
# EMAIL_NOTIFICATION_RECIPIENT="you@example.com"
|
||||
|
||||
# The "From" header of the sent email. Defaults to `noreply@nohost`.
|
||||
|
||||
# EMAIL_NOTIFICATION_SENDER="no-reply@example.com"
|
||||
|
||||
# Configuration and credentials for the SMTP server to be used.
|
||||
# EMAIL_SMTP_PORT defaults to 587.
|
||||
|
||||
# EMAIL_SMTP_HOST="posteo.de"
|
||||
# EMAIL_SMTP_PASSWORD="<xxx>"
|
||||
# EMAIL_SMTP_USERNAME="no-reply@example.com"
|
||||
# EMAIL_SMTP_PORT="<port>"
|
||||
```
|
||||
{% endraw %}
|
||||
|
||||
[compose-issue]: https://github.com/docker/compose/issues/2854
|
Loading…
Reference in New Issue
Block a user