Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Feature request: Atomic backup mode for single snapshot for volumes + databases

Đang mở
#110 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

@muebau đang làm issue này rồi.

Từ ngày 17/3/2026.

  • #111 của @muebau — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
docker, docker-compose, python

Hướng nghiên cứu

Không có tệp hoặc kiểm thử nào được nêu tên, vì vậy hãy bắt đầu bằng cách xác định phần điều phối backup và các đường dẫn hiện có của các bản dump volume và cơ sở dữ liệu. So sánh các lệnh gọi restic riêng biệt hiện tại với branch ATOMIC_BACKUP được đề xuất, sau đó xác minh rằng chế độ nguyên tử tạo một snapshot, dọn dẹp /databases khi thành công hoặc thất bại, và giữ nguyên hành vi mặc định hiện có.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Problem

Currently, volumes and database dumps are backed up as separate restic snapshots. A volume backup produces one snapshot, and each database dump (restic backup --stdin) produces another. This was mentioned also in #106 . This means:

  • A restore requires identifying and matching the correct volume snapshot with the correct database snapshot(s)
  • There is no guarantee they represent the same point in time
  • For applications like Nextcloud — where the data directory and database must be consistent — this creates a real risk of restoring into an inconsistent state

Proposed solution

A new environment variable ATOMIC_BACKUP (true/false, default false).

When enabled, the backup process changes from:

restic backup /volumes              → snapshot 1
restic backup --stdin db1.sql       → snapshot 2
restic backup --stdin db2.sql       → snapshot 3

to:

docker exec db1 dump > /databases/db1/all_databases.sql   (write to disk)
docker exec db2 dump > /databases/db2/mydb.sql            (write to disk)
restic backup /volumes /databases                          → snapshot 1 (everything)
rm -rf /databases                                          (cleanup)

The resulting snapshot contains:

/volumes/{service}/{path}/...            ← volume data
/databases/{service}/all_databases.sql   ← SQL dumps

A single restic restore retrieves everything needed to reconstruct the stack.

Example usage

backup:
  image: ghcr.io/lawndoc/stack-back
  environment:
    ATOMIC_BACKUP: "true"
    # ... other env vars

No changes to container labels needed — the feature is purely opt-in via the backup container's environment.

Behavior details

  • Default off: When ATOMIC_BACKUP is unset or false, existing behavior is fully preserved (separate snapshots, --stdin piping). No breaking changes.
  • Dump to disk: In atomic mode, each database container's dump command is streamed via docker exec to a file on the backup container's filesystem under /databases/.
  • Single restic call: Both /volumes and /databases are passed to one restic backup invocation, producing one snapshot.
  • Cleanup: The /databases/ directory is removed after the backup completes (regardless of success/failure).
  • Error handling: If a database dump fails, the error is logged and tracked, but remaining dumps and the restic backup still run (consistent with current behavior where one DB failure doesn't block others). The process exits with a non-zero code if any step failed.

Why this matters

For any stack where application data and database state must be consistent (Nextcloud, Gitea, WordPress, etc.), atomic snapshots eliminate the gap between volume and database backups and make restores straightforward — one snapshot, one restore, guaranteed consistency.

Ngôn ngữ chính
Python
Star
181
Fork
13
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của lawndoc/stack-back

Tất cả issue của lawndoc/stack-back

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.