diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml new file mode 100644 index 0000000..d6f7d4e --- /dev/null +++ b/.github/workflows/demo.yml @@ -0,0 +1,111 @@ +name: Demo + +# Records the terminal demo (docs/assets/demo.gif, demo.mp4) and a real +# sample report (docs/assets/sample-report.json) from a synthetic Vaultwarden +# fixture, then commits them. On a pull request that touches the demo, the +# assets land on the PR branch; on a version tag or a manual run, on main. +# (It listens for the tag push, not the release: the release is created with +# GITHUB_TOKEN, and events from that token never start other workflows.) + +on: + pull_request: + paths: + - "demo/**" + - ".github/workflows/demo.yml" + push: + tags: ["v*"] + workflow_dispatch: + +permissions: + contents: write + +concurrency: + group: demo-${{ github.head_ref || 'main' }} + cancel-in-progress: true + +jobs: + demo: + name: Record demo and sample report + # Fork PRs get a read-only token and cannot push the assets back. + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository + runs-on: ubuntu-latest + env: + RESTIC_VERSION: 0.18.0 + RESTIC_PASSWORD: demo-only + steps: + - uses: actions/checkout@v7 + with: + ref: ${{ github.head_ref || 'main' }} + fetch-depth: 0 + + - uses: actions/setup-go@v6 + with: + go-version-file: agent/go.mod + cache-dependency-path: agent/go.sum + + - name: Install restic + run: | + curl -fsSL -o restic.bz2 \ + "https://github.com/restic/restic/releases/download/v${RESTIC_VERSION}/restic_${RESTIC_VERSION}_linux_amd64.bz2" + bunzip2 restic.bz2 && chmod +x restic && sudo mv restic /usr/local/bin/restic + + - name: Build and install the agent + working-directory: agent + env: + CGO_ENABLED: "0" + run: | + VERSION="${{ github.ref_type == 'tag' && github.ref_name || '' }}" + [ -n "$VERSION" ] || VERSION="$(git describe --tags 2>/dev/null || echo dev)" + go build -trimpath -ldflags "-s -w -X github.com/restorable-dev/restorable/agent/cmd.version=${VERSION}" -o /tmp/restorable . + sudo install -m 0755 /tmp/restorable /usr/local/bin/restorable + restorable version + + # The recording can't assert anything, so prove the story first on a + # scratch copy: a good snapshot passes, a half-copied database fails + # with exit 1. If either is false the job stops before recording. + - name: Dry run the demo scenario + run: | + demo/setup.sh /tmp/check + mkdir -p /tmp/check/run && cd /tmp/check/run + restorable init --repo /tmp/check/backups/restic --yes > pass.out 2>&1 || { cat pass.out; exit 1; } + cat pass.out + grep -q "restorable: PASS" pass.out + truncate -s 64K /tmp/check/vaultwarden/db.sqlite3 + restic backup -q -r /tmp/check/backups/restic /tmp/check/vaultwarden + set +e + restorable test --config agent.yaml > fail.out 2>&1 + code=$? + set -e + cat fail.out + [ "$code" = 1 ] || { echo "expected exit 1 after the broken backup, got $code"; exit 1; } + grep -q "✗ vaultwarden/sqlite" fail.out + + - name: Build the fixture under /srv + run: | + sudo mkdir -p /srv && sudo chown "$USER" /srv + demo/setup.sh /srv + mkdir -p /srv/demo + + - name: Write the sample report (before the recording breaks the backup) + run: | + mkdir -p /tmp/report docs/assets + (cd /tmp/report && restorable init --repo /srv/backups/restic --yes > /dev/null 2>&1) + restorable test --config /tmp/report/agent.yaml --json > docs/assets/sample-report.json + python3 -c "import json,sys; r=json.load(open(sys.argv[1])); assert r['status']=='pass', r['status']" docs/assets/sample-report.json + cat docs/assets/sample-report.json + + - uses: charmbracelet/vhs-action@v2 + with: + path: demo/demo.tape + + - name: Commit the assets + env: + TARGET: ${{ github.head_ref || 'main' }} + run: | + ls -la docs/assets + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add docs/assets/demo.gif docs/assets/demo.mp4 docs/assets/sample-report.json + if git diff --cached --quiet; then echo "no changes"; exit 0; fi + git commit -m "docs: refresh demo recording and sample report" + git push origin "HEAD:${TARGET}" diff --git a/README.md b/README.md index 1e5fa90..b746fab 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ > A backup you've never restored is a hope, not a backup. +![Restorable restoring a Vaultwarden backup: a good snapshot passes, then a half-copied database that restic happily backed up fails the check](docs/assets/demo.gif) + Your backups run every night. **Restorable proves they'd actually restore.** On a schedule, it restores your latest restic snapshot into a disposable sandbox, verifies the data actually works — files present, databases load, diff --git a/demo/demo.tape b/demo/demo.tape new file mode 100644 index 0000000..c63f0b1 --- /dev/null +++ b/demo/demo.tape @@ -0,0 +1,58 @@ +# Records docs/assets/demo.gif and demo.mp4. Run by .github/workflows/demo.yml +# after demo/setup.sh /srv has built the fixture. Every command shown is real. + +Output docs/assets/demo.gif +Output docs/assets/demo.mp4 + +Require restorable +Require restic + +Set Shell "bash" +Set FontSize 17 +Set Width 1440 +Set Height 760 +Set Padding 30 +Set TypingSpeed 40ms +Set Theme { "name": "Restorable", "black": "#151518", "red": "#E63B5A", "green": "#7FC88A", "yellow": "#E8C37A", "blue": "#8AAFE0", "magenta": "#C792C6", "cyan": "#7FC4C8", "white": "#F2E9D8", "brightBlack": "#6F6A62", "brightRed": "#FF5C77", "brightGreen": "#9EE0A8", "brightYellow": "#F5D79A", "brightBlue": "#A9C6F0", "brightMagenta": "#DDB0DC", "brightCyan": "#9ED9DC", "brightWhite": "#FFFFFF", "background": "#0B0B0D", "foreground": "#F2E9D8", "selection": "#3A1A22", "cursor": "#E63B5A" } + +Hide +Type "export PS1='$ ' RESTIC_PASSWORD=demo-only && cd /srv/demo && clear" +Enter +Sleep 500ms +Show + +Type "# A Vaultwarden server, backed up nightly with restic." +Enter +Sleep 600ms +Type "# Backups you've never restored aren't backups. Let's restore one." +Enter +Sleep 900ms + +Type "restorable init --repo /srv/backups/restic --yes" +Sleep 400ms +Enter +Wait@60s /\$\s*$/ +Sleep 6s + +Type "clear" +Enter +Type "# Night two: the backup job copies the database mid-write." +Enter +Sleep 600ms +Type "truncate -s 64K /srv/vaultwarden/db.sqlite3 && restic backup -q -r /srv/backups/restic /srv/vaultwarden" +Sleep 400ms +Enter +Wait@60s /\$\s*$/ +Sleep 800ms + +Type "# restic says the backup succeeded. Restorable restores it and checks." +Enter +Sleep 700ms +Type "restorable test --config agent.yaml" +Sleep 400ms +Enter +Wait@60s /\$\s*$/ +Sleep 1s +Type "echo exit code $?" +Enter +Sleep 7s diff --git a/demo/setup.sh b/demo/setup.sh new file mode 100755 index 0000000..de8c14f --- /dev/null +++ b/demo/setup.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +# Builds the demo fixture: a small Vaultwarden-shaped data directory and a +# restic repository holding one good snapshot of it. Used by the demo workflow +# to record docs/assets/demo.gif and to produce docs/assets/sample-report.json. +# +# demo/setup.sh +# +# creates /vaultwarden (the app data) and /backups/restic (the +# repository). Needs restic and python3. RESTIC_PASSWORD must be set. +set -euo pipefail + +ROOT="${1:?usage: demo/setup.sh }" +: "${RESTIC_PASSWORD:?RESTIC_PASSWORD must be set}" + +APP="$ROOT/vaultwarden" +REPO="$ROOT/backups/restic" +rm -rf "$APP" "$REPO" +mkdir -p "$APP/attachments/7f3c" "$APP/icon_cache" "$(dirname "$REPO")" + +# A real SQLite database with enough rows to span many pages, so a partial +# copy of it is detectably broken rather than accidentally valid. +python3 - "$APP/db.sqlite3" <<'PY' +import sqlite3, sys, uuid +db = sqlite3.connect(sys.argv[1]) +db.execute("create table users (uuid text primary key, email text, created_at text)") +db.execute("create table ciphers (uuid text primary key, user_uuid text, name text, data blob)") +for i in range(40): + db.execute("insert into users values (?, ?, datetime('now'))", (str(uuid.uuid4()), f"user{i}@example.com")) +for i in range(2500): + db.execute("insert into ciphers values (?, ?, ?, randomblob(64))", (str(uuid.uuid4()), "demo", f"login-{i}")) +db.commit() +db.close() +PY + +openssl genrsa -out "$APP/rsa_key.pem" 2048 2>/dev/null +cat > "$APP/config.json" <<'EOF' +{"domain": "https://vault.example.com", "signups_allowed": false} +EOF +head -c 24000 /dev/urandom > "$APP/attachments/7f3c/receipt.pdf" +for site in github.com example.com wikipedia.org; do + head -c 2000 /dev/urandom > "$APP/icon_cache/$site.png" +done + +restic init -q -r "$REPO" +restic backup -q -r "$REPO" "$APP" +echo "fixture ready: app $APP, repo $REPO" diff --git a/docs/assets/demo.gif b/docs/assets/demo.gif new file mode 100644 index 0000000..e70b05b Binary files /dev/null and b/docs/assets/demo.gif differ diff --git a/docs/assets/demo.mp4 b/docs/assets/demo.mp4 new file mode 100644 index 0000000..06e00ab Binary files /dev/null and b/docs/assets/demo.mp4 differ diff --git a/docs/assets/sample-report.json b/docs/assets/sample-report.json new file mode 100644 index 0000000..4f6ef2b --- /dev/null +++ b/docs/assets/sample-report.json @@ -0,0 +1,25 @@ +{ + "agent_version": "v0.1.2-9-ge1229e9", + "repo": "/srv/backups/restic", + "snapshot_id": "a7fee3b5997e0731ddf1d8065f72872c4458f456f414b8f767a1c12dfed6d562", + "status": "pass", + "started_at": "2026-11-16T18:41:34.242456951Z", + "finished_at": "2026-11-16T18:41:37.80987776Z", + "restore_duration_ms": 719, + "checks": [ + { + "recipe": "vaultwarden", + "type": "files", + "status": "pass", + "message": "5 required path(s) present, 3 sampled checksum(s) match repository", + "duration_ms": 2141 + }, + { + "recipe": "vaultwarden", + "type": "sqlite", + "status": "pass", + "message": "\"db.sqlite3\" passes integrity_check", + "duration_ms": 2 + } + ] +}