Skip to content

Backup: replace rclone with restic, close backup gaps - #37

Merged
jurczykpawel merged 10 commits into
mainfrom
feat/backup-restic
Nov 26, 2026
Merged

jurczykpawel merged 10 commits into
mainfrom
feat/backup-restic

Conversation

@jurczykpawel

Copy link
Copy Markdown
Owner

Summary

Backups move entirely to restic: encrypted, versioned, deduplicated snapshots with 14 daily / 8 weekly / 12 monthly retention. No backward compatibility: rclone, rclone crypt and Google Drive/Dropbox/OneDrive OAuth are removed.

  • Wizard local/setup-backup.sh: Cloudflare R2 (default), Backblaze B2, any S3 endpoint, SFTP, local directory. Generates the repository password (shown once) or reuses an existing one on a new server; the working config is replaced only after the repository opens.
  • Engine system/backup-core.sh (installed as /usr/local/sbin/stackpilot-backup): app files, named and anonymous Docker volumes, database dumps detected by image (Postgres pg_dumpall, MySQL/MariaDB, MongoDB), consistent SQLite snapshots, external databases, /etc/caddy, /var/www; heartbeat ping on success/failure; weekly restic check; restic 0.19.1 pinned by SHA256.
  • Restore local/restore.sh: pick a snapshot, restore everything or one app, explicit confirmation.
  • Removes the old jobs (stackpilot-db-backup cron, crontab entry) during setup.
  • Fix (pre-existing): WordPress with --db-source=bundled had no database service.

Test plan

  • ./tests/run.sh: 406 passed, 0 failed
  • E2E on a Debian 13 test server (Docker-in-Docker, real scripts over SSH): local directory and S3 (MinIO, missing bucket), "new server" restore with the existing password, single-app restore, wrong password rejected; Umami (Postgres), Vaultwarden (SQLite), Notifuse (volume), WordPress (MySQL), MongoDB
  • Real VPS (Ubuntu 24.04) + real Cloudflare R2: wizard created the bucket, installed restic, backup, destroy, single-app and full restore, all markers back
  • CI green

🤖 Generated with Claude Code

jurczykpawel and others added 10 commits November 26, 2026 15:35
…QLite snapshots

One encrypted restic snapshot per run: stack files, named Docker volumes,
consistent dumps of running Postgres/MySQL/MongoDB containers, external
databases and online SQLite copies. Restore recreates databases from their
dumps, restores volume data and starts the stack again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
setup-backup.sh now configures restic with Cloudflare R2 (default),
Backblaze B2, any S3 endpoint, SFTP or a local directory, generates the
repository password, writes a private config and schedules the daily run
that also covers databases. restore.sh lists snapshots and restores all
apps or one. The rclone scripts, the separate database backup setup and
the unused Mikrus attic script are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ket fails or is created at once

restic cat config retries a missing S3 bucket for many minutes. restic init
creates the bucket, or fails immediately on bad keys; an existing repository
is then opened to check the password.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…en the repository

The wizard writes backup.env.new and moves it over backup.env only after
init succeeds, so a mistyped password no longer replaces a working setup.
The heartbeat URL must be an http(s) address.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Database dumps and SQLite copies are in the snapshot; keeping them in
/opt/backups/stackpilot until the next night doubled the database size on
disk. They stay when restic backup fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Images that declare VOLUME (mongo: /data/configdb) get a random volume name
that does not exist after the stack is recreated, which aborted the restore.
Such volumes are recorded as @service:/path and found in the new container.
A volume that cannot be found is reported and the restore exits non-zero.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
deploy.sh --db-source=bundled reported a bundled MySQL but the compose file
had no db service, so WordPress could not reach db:3306. MySQL 8.0 used
427 MiB in a test install, so the limit is 512M.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Servers set up with the old backup kept /etc/cron.d/stackpilot-db-backup
(nightly local dumps) and a root crontab entry for backup-core.sh, which now
points at the restic engine and would fail nightly. Found on a real test VPS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jurczykpawel
jurczykpawel merged commit 94471e2 into main Nov 26, 2026
1 check passed
@jurczykpawel
jurczykpawel deleted the feat/backup-restic branch November 26, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant