Feature Request: Pre/Post-Backup Hooks and Ordered Backup Execution
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- docker, docker-compose, python
- Área
- devops, infrastructure
Línea de trabajo
No se indican archivos ni pruebas. Empieza localizando los puntos de entrada del análisis de etiquetas de Docker Compose y de la ejecución de copias de seguridad; después, relaciona el comportamiento propuesto para pre, post, error, finally, hook-order y container-order con el flujo existente. Done debe cubrir con pruebas el orden especificado, los contextos, el manejo de errores, las advertencias y los casos de fallback.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Hello,
first of all, a big thank you to the maintainer for forking the project, keeping it alive, and continuing to drive it forward!
Some applications require specific commands to be run before a backup can safely proceed. For example, Nextcloud requires occ maintenance:mode --on to be called before backing up to ensure data consistency. Similarly, certain setups may require backups to run in a specific order across services or directories.
It would be great to have support for:
- Pre- and post-backup hooks: user-defined commands that run before and after the backup process
- Ordered backup execution: the ability to define the sequence in which components are backed up
- Ordered hook execution: the ability to define the sequence in which hooks run within a stage (e.g. pre, post, container context)
What do you think about a solution like this?
backup:
image: ghcr.io/lawndoc/stack-back
labels:
stack-back.ordered: true
stack-back.order.1: "nextcloud-app"
stack-back.order.2: "nextcloud-database"
stack-back.hooks.pre.1.cmd: "sudo -E -u www-data php occ maintenance:mode --on"
stack-back.hooks.pre.1.context: "nextcloud-app" # (optional) run inside this container
stack-back.hooks.pre.2.cmd: "some-global-script.sh"
stack-back.hooks.pre.2.context: "host" # (optional) run on host / global context
stack-back.hooks.pre.3.cmd: "this-container-script.sh" # runs in this (backup) container
stack-back.hooks.post.1.cmd: "sudo -E -u www-data php occ maintenance:mode --off"
stack-back.hooks.post.1.context: "nextcloud-app" # (optional) run inside this container
stack-back.hooks.error.1.cmd: "notify-admin.sh 'backup failed'"
stack-back.hooks.error.1.context: "host"
stack-back.hooks.finally.1.cmd: "sudo -E -u www-data php occ maintenance:mode --off"
stack-back.hooks.finally.1.context: "nextcloud-app"
nextcloud-app:
image: nextcloud:stable
labels:
stack-back.volumes: true
stack-back.volumes.include: "data"
stack-back.hooks.pre.1.cmd: "sudo -E -u www-data php occ maintenance:mode --on" # runs in this container
stack-back.hooks.post.1.cmd: "sudo -E -u www-data php occ maintenance:mode --off" # runs in this container
nextcloud-database:
image: ...
labels:
....
stack-back.hooks.pre.1.cmd: "prepare-db-for-backup.sh" # runs in this container
stack-back.hooks.pre.1.on-error: "abort" # abort the backup (default)
# stack-back.hooks.pre.1.on-error: "continue" # log and proceed anyway
stack-back.hooks.post.1.cmd: "resume-db-to-production.sh" # runs in this container
A few notes on the intended behavior:
- hook execution order: all backup-container-defined hooks run first, target-container-defined hooks run second
- execution abort on error by default; set
on-error: continueto log and proceed instead contextis optional and defaults to the container where the label is definedprehooks run in sequence before the backupposthooks run only if allprehooks and the backup itself succeedederrorhooks run only if a hook or the backup itself failedfinallyhooks always run, regardless of outcome
This follows the same logic as a try/catch/finally pattern which hopefully makes it intuitive to reason about
Container backup order: if stack-back.ordered: true is set, containers are backed up in the sequence defined by stack-back.order.1..n
- container missing from the list: backed up after the ordered ones (warning logged)
- gaps in numbering: gap is skipped, next found number is used (warning logged)
- duplicate label keys (e.g. two
order.1): Docker/YAML constraint, last value silently wins - unknown container name: skipped (warning logged)
- duplicate container name in the list: backed up once (warning logged)
ordered: trueset but noorder.nlabels defined: falls back to unordered execution (warning logged)
The individual additions are relatively small but I think they unlock some powerful and flexible backup workflows.
Would love to hear your thoughts!
- Lenguaje dominante
- Python
- Estrellas
- 181
- Forks
- 13
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de lawndoc/stack-back
-
Maintenance QuestionAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 20/100
lawndoc/stack-back#119 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
lawndoc/stack-back#115 ·
-
Feature request: Atomic backup mode for single snapshot for volumes + databasesPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
lawndoc/stack-back#110 · 1 comentario ·
-
feat: Create backup/snapshot per container/compose projectPosiblemente ocupada @Abestanis la tomó hace 42 días. Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
lawndoc/stack-back#106 · 1 comentario ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 48/100
lawndoc/stack-back#104 · 1 comentario ·
Todos los issues de lawndoc/stack-back
Issues similares
-
`LazyFrameRemote` and `ExecuteRemote` sinks do not accept `Path`, like `LazyFrame` sinks do.Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
WingedGuardian/GENesis-AGI#3375 ·
Los mantenedores suelen responder en 1 día
-
curriculum documentation quality
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
githubnext/gh-aw-workshop#4601 ·
Los mantenedores suelen responder en 1 día
-
approved Good First Issue scope: docs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
hiero-ledger/hiero-sdk-python#2730 · 3 comentarios ·
Los mantenedores suelen responder en 1 día