mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2026-08-01 12:34:50 +00:00
Backing up a live volume with rsync copies a moving target: a database
written to mid-copy lands on disk in a state no engine ever committed.
Stopping the container avoids that at the cost of downtime.
A snapshot removes both. `--snapshot {btrfs,zfs}` with `--snapshot-subject`
freezes the docker root once per run, and every volume copy is then read
from that frozen tree while the containers keep serving. A restore of such
a copy is an ordinary crash recovery, which every supported engine performs
on its own at startup.
An unsupported filesystem or an unknown snapshot kind fails loudly rather
than degrading to a live copy, since a silent fallback would return exactly
the torn backup the mode exists to prevent. `--shutdown` is rejected
alongside `--snapshot` instead of being ignored: under a snapshot no
container is ever stopped, so accepting the flag would promise downtime
semantics the run does not deliver.
Copies out of a snapshot skip rsync's --checksum verification. The source
is immutable for the lifetime of the copy, so size-and-mtime cannot race,
and dropping the second full read roughly halves the I/O per volume.
backup/app.py grew past what one module could carry and is split into
layout, policy and dumps along the lines it already had internally.
Tests: unit coverage for the new snapshot, layout, policy, volume and cli
units; e2e cases drive real btrfs, zfs and ext4 filesystems on loop devices
in a privileged container, including a MariaDB that is written to across
the snapshot and must recover from the restored copy without losing a
committed row. CI installs zfs and sets E2E_REQUIRE_FILESYSTEMS so a
missing kernel module fails the build instead of silently skipping a
filesystem.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
101 lines
2.8 KiB
YAML
101 lines
2.8 KiB
YAML
name: CI (make tests, stable, publish)
|
|
|
|
on:
|
|
push:
|
|
branches: ["**"]
|
|
tags: ["v*.*.*"] # SemVer tags like v1.2.3
|
|
pull_request:
|
|
|
|
permissions:
|
|
contents: write # push/update 'stable' tag
|
|
packages: write # push to GHCR
|
|
|
|
env:
|
|
IMAGE_NAME: baudolo
|
|
REGISTRY: ghcr.io
|
|
IMAGE_REPO: ${{ github.repository }}
|
|
|
|
jobs:
|
|
test:
|
|
name: make test
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
|
|
- name: Show docker info
|
|
run: |
|
|
docker version
|
|
docker info
|
|
|
|
- name: Provide zfs so the snapshot suite covers every filesystem
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y --no-install-recommends zfsutils-linux
|
|
sudo modprobe zfs
|
|
zpool version
|
|
|
|
- name: Run all tests via Makefile
|
|
env:
|
|
E2E_REQUIRE_FILESYSTEMS: "btrfs ext4 zfs"
|
|
run: |
|
|
make test
|
|
|
|
- name: Upload E2E artifacts (always)
|
|
if: always()
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: e2e-artifacts
|
|
path: artifacts
|
|
if-no-files-found: ignore
|
|
|
|
stable_and_publish:
|
|
name: Mark stable + publish image (SemVer tags only)
|
|
needs: [test]
|
|
runs-on: ubuntu-latest
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
|
|
steps:
|
|
- name: Checkout (full history for tags)
|
|
uses: actions/checkout@v7
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Derive version from tag
|
|
id: ver
|
|
run: |
|
|
TAG="${GITHUB_REF#refs/tags/}" # v1.2.3
|
|
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Mark 'stable' git tag (force update)
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git tag -f stable "${GITHUB_SHA}"
|
|
git push -f origin stable
|
|
|
|
- name: Login to GHCR
|
|
uses: docker/login-action@v4
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build image (Makefile)
|
|
run: |
|
|
make build
|
|
|
|
- name: Tag image for registry
|
|
run: |
|
|
# local image built by Makefile is: baudolo:local
|
|
docker tag "${IMAGE_NAME}:local" "${REGISTRY}/${IMAGE_REPO}:${{ steps.ver.outputs.tag }}"
|
|
docker tag "${IMAGE_NAME}:local" "${REGISTRY}/${IMAGE_REPO}:stable"
|
|
docker tag "${IMAGE_NAME}:local" "${REGISTRY}/${IMAGE_REPO}:sha-${GITHUB_SHA::12}"
|
|
|
|
- name: Push image
|
|
run: |
|
|
docker push "${REGISTRY}/${IMAGE_REPO}:${{ steps.ver.outputs.tag }}"
|
|
docker push "${REGISTRY}/${IMAGE_REPO}:stable"
|
|
docker push "${REGISTRY}/${IMAGE_REPO}:sha-${GITHUB_SHA::12}"
|