Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated README.md #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 43 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,60 @@ A script to automatically back up all databases running under docker on a host

## Installation

This container requires access to the docker socket. This can be done either by mounting `/var/lib/docker.sock`, or using a HTTP proxy to provide it through `$DOCKER_HOST`.
This container requires access to the docker socket. This should always be done, for security reasons, using a [HTTP proxy](https://github.com/Tecnativa/docker-socket-proxy) which this container can then access through the `DOCKER_HOST` environment variable.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of wording change here, which doesn't seem to add much. I'm ok with talking about the socket before using a proxy (even if it is worse).

I personally always use $ as a prefix for environment variables, although I agree that might not be clear. I'd be ok with a simpler patch which just rewords around that instead.


Mount your backup directory as `/var/backups` (or override `$BACKUP_DIR`). Backups will be saved here based on the name of the container. Backups are not dated or compressed.
You can use this container by directly mounting `/var/lib/docker.sock` but this is not recommended.

Backups run daily at midnight. To change this, add a cron-style schedule to `$SCHEDULE`. For more information on the format of the cron strings, please see the [croniter documentation on PyPI](https://pypi.org/project/croniter/).
Mount your backup directory as `/var/backups` (or override `BACKUP_DIR`). Backups will be saved here based on the name of the container. Backups are not dated or compressed.

Additionally, there is support for [healthchecks.io](https://healthchecks.io). `$HEALTHCHECKS_ID` can be used to specify the id to ping. If you're using a self-hosted instance, set `$HEALTHCHECKS_HOST`.
Backups run daily at midnight. To change this, add a cron-style schedule to `SCHEDULE`. For more information on the format of the cron strings, please see the [croniter documentation on PyPI](https://pypi.org/project/croniter/).

### Example `docker-compose.yml`
Additionally, there is support for [healthchecks.io](https://healthchecks.io). `HEALTHCHECKS_ID` can be used to specify the id to ping. If you're using a self-hosted instance, set `HEALTHCHECKS_HOST`.

```yml
version: "2.3"
### Example `docker-compose.yml`

```yml
---
version: "3.8"

services:
backup:

db-auto-backup:
image: ghcr.io/realorangeone/db-auto-backup:latest
restart: unless-stopped
container_name: db-auto-backup
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./backups:/var/backups
- /mnt/db-backups:/var/backups:rw
environment:
- DOCKER_HOST=tcp://docker-socket-proxy:2375
depends_on:
- docker-socket-proxy
networks:
- docker-socket-proxy-net
restart: unless-stopped

docker-socket-proxy:
image: tecnativa/docker-socket-proxy:latest
container_name: docker-socket-proxy
environment:
- HEALTHCHECKS_ID=id
- POST=1
- CONTAINERS=1
- IMAGES=1
- EXEC=1
networks:
- docker-socket-proxy-net
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
restart: unless-stopped

networks:
docker-socket-proxy-net:
internal: true
```

### Oneshot

You may want to use this container to run backups just once, rather than on a schedule. To achieve this, set `$SCHEDULE` to an empty string, and the backup will run just once. This may be useful in conjunction with an external scheduler.
You may want to use this container to run backups just once, rather than on a schedule (or perhaps with an external scheduler). To achieve this, run these commands on the host running docker:

`docker exec db-auto-backup SCHEDULE=`

`docker exec ./db-auto-backup.py`
Comment on lines +70 to +72
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: I'm not sure these commands will actually work, the new SCHEDULE value won't persist. You probably want:

docker-compose exec backup SCHEDULE= ./db-auto-backup.py