Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Feature Request: Pre/Post-Backup Hooks and Ordered Backup Execution

Abierto
#108 1 comentario 0 reacciones 0 asignados Ver en GitHub

@muebau ya está trabajando en esto.

Desde el 17/3/2026.

  • #109 de @muebau — abierto

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

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: continue to log and proceed instead
  • context is optional and defaults to the container where the label is defined
  • pre hooks run in sequence before the backup
  • post hooks run only if all pre hooks and the backup itself succeeded
  • error hooks run only if a hook or the backup itself failed
  • finally hooks 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: true set but no order.n labels 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

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de lawndoc/stack-back

Todos los issues de lawndoc/stack-back

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.