-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow backup to be run as non-root user
- Loading branch information
Showing
11 changed files
with
131 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
title: Use the image as a non-root user | ||
layout: default | ||
parent: How Tos | ||
nav_order: 16 | ||
--- | ||
|
||
# Use the image as a non-root user | ||
|
||
{: .important } | ||
Running as a non-root user limits interaction with the Docker Daemon. | ||
If you want to stop and restart containers and services during backup, and the host's Docker daemon is running as root, you will also need to run this tool as root. | ||
|
||
By default, this image executes backups using the `root` user. | ||
In case you prefer to use a different user, you can use Docker's [`user`](https://docs.docker.com/engine/reference/run/#user) option, passing the user and group id: | ||
|
||
```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 \ | ||
--user 1000:1000 \ | ||
offen/docker-volume-backup:v2 | ||
``` | ||
|
||
or in a compose file: | ||
|
||
```yml | ||
services: | ||
backup: | ||
image: offen/docker-volume-backup:v2 | ||
user: 1000:1000 | ||
# further configuration omitted ... | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
AWS_ACCESS_KEY_ID="test" | ||
AWS_SECRET_ACCESS_KEY="GMusLtUmILge2by+z890kQ" | ||
AWS_ENDPOINT="minio:9000" | ||
AWS_ENDPOINT_PROTO="http" | ||
AWS_S3_BUCKET_NAME="backup" | ||
BACKUP_CRON_EXPRESSION="0 0 5 31 2 ?" | ||
BACKUP_FILENAME="test.tar.gz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
version: '3' | ||
|
||
services: | ||
minio: | ||
image: minio/minio:RELEASE.2020-08-04T23-10-51Z | ||
environment: | ||
MINIO_ROOT_USER: test | ||
MINIO_ROOT_PASSWORD: test | ||
MINIO_ACCESS_KEY: test | ||
MINIO_SECRET_KEY: GMusLtUmILge2by+z890kQ | ||
entrypoint: /bin/ash -c 'mkdir -p /data/backup && minio server /data' | ||
volumes: | ||
- ${LOCAL_DIR:-local}:/data | ||
|
||
backup: | ||
image: offen/docker-volume-backup:${TEST_VERSION:-canary} | ||
user: 1000:1000 | ||
depends_on: | ||
- minio | ||
restart: always | ||
volumes: | ||
- app_data:/backup/app_data:ro | ||
- ./01conf.env:/etc/dockervolumebackup/conf.d/01conf.env | ||
|
||
offen: | ||
image: offen/offen:latest | ||
labels: | ||
- docker-volume-backup.stop-during-backup=true | ||
volumes: | ||
- app_data:/var/opt/offen | ||
|
||
volumes: | ||
app_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
cd "$(dirname "$0")" | ||
. ../util.sh | ||
current_test=$(basename $(pwd)) | ||
|
||
export LOCAL_DIR=$(mktemp -d) | ||
|
||
docker compose up -d --quiet-pull | ||
sleep 5 | ||
|
||
docker compose logs backup | ||
|
||
# conf.d is used to confirm /etc files are also accessible for non-root users | ||
docker compose exec backup /bin/sh -c 'set -a; source /etc/dockervolumebackup/conf.d/01conf.env; set +a && backup' | ||
|
||
sleep 5 | ||
|
||
expect_running_containers "3" | ||
|
||
if [ ! -f "$LOCAL_DIR/backup/test.tar.gz" ]; then | ||
fail "Could not find archive." | ||
fi | ||
pass "Archive was created." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters