mirror of
https://github.com/offen/docker-volume-backup.git
synced 2024-11-22 21:30:28 +01:00
Frederik Ring
c3daeacecb
* Query for labeled services as well * Try scaling down services * Scale services back up * Use progress tool from Docker CLI * In test, label both services * Clean up error and log messages * Document scale-up/down approach in docs * Downgrade Docker CLI to match client * Document services stats * Do not rely on PreviousSpec for storing desired replica count * Log warnings from Docker when updating services * Check whether container and service labels collide * Document script behavior on label collision * Add additional check if all containers have been removed * Scale services concurrently * Move docker interaction code into own file * Factor out code for service updating * Time out after five minutes of not reaching desired container count * Inline handling of in-swarm container level restart * Timer is more suitable for timeout race * Timeout when scaling down services should be configurable * Choose better filename * Reflect changes in naming * Rename and deprecate BACKUP_STOP_CONTAINER_LABEL * Improve logging * Further simplify logging
39 lines
1.3 KiB
Markdown
39 lines
1.3 KiB
Markdown
---
|
|
title: Stop containers during backup
|
|
layout: default
|
|
parent: How Tos
|
|
nav_order: 1
|
|
---
|
|
|
|
# Stop containers during backup
|
|
|
|
{: .note }
|
|
In case you are running Docker in Swarm mode, [dedicated documentation](./use-with-docker-swarm.html) on service and container restart applies.
|
|
|
|
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_DURING_BACKUP_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_DURING_BACKUP_LABEL: service1
|
|
volumes:
|
|
- data:/backup/my-app-backup:ro
|
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
|
|
|
volumes:
|
|
data:
|
|
```
|