Files
shopdb-flask/scripts/backup
Proudlock bd48814021 Reorganize repository structure and clean up documentation
Clean up and organize the flask-shopdb repository for better
maintainability and discoverability:

## Changes

- Update .gitignore for build artifacts (publish/, data/, 122M total)
- Reorganize .claude/ into 6 subdirectories with README navigation
- Consolidate overlapping MCP setup guides into MCP-QUICK-START.md
- Move deployment docs from root to docs/deployment/
- Archive dated status reports to .claude/archived/
- Delete temporary files (logs, backups, empty reports, ~50K)

## New Structure

.claude/ organized into:
- setup/ - MCP, VM, Hyper-V, GitHub setup guides + scripts (17 files)
- plans/ - Feature plans and protocols (5 files)
- maintenance/ - Deployment checklists and reports (4 files)
- archived/ - Historical documentation (9 files)
- skills/ - Claude Code automation (5 files)
- workflows/ - Security audit workflow (1 file)

docs/deployment/ created with 6 deployment guides:
- LOCAL-DEV-SETUP.md, DOCKER-SETUP.md, DOCKER-PREBUILT-APPROACH.md
- PRODUCTION-READINESS.md, DEPLOY-TO-VM.md, README.md

Root directory cleaned to essential docs only:
- CLAUDE.md, README.md, CONTRIBUTING.md, CHANGELOG.md

Benefits:
- Clear navigation via README.md in each subdirectory
- No duplicate/overlapping documentation
- Large artifacts properly gitignored (won't bloat repository)
- Historical context preserved in archived/

See .claude/CLEANUP-SUMMARY.md for complete details.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-09-11 15:45:05 -04:00
..

ShopDB Backup & Restore

The backup system provides automated database and instance backups with restore capability.

Quick Start

# Trigger a backup via docker-compose
docker compose -f docker-compose.backup.yml up backup

# Or via API (requires admin JWT token)
curl -X POST http://localhost:5001/api/shopdbbackups \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Configuration

By default, backups are stored in /backups volume (local to Docker host).

For production, configure storage in Settings > Backups web UI:

  • Local: Default, no configuration needed
  • SMB: Network share (requires hostname, share, credentials)
  • AWS S3: Cloud storage (requires region, bucket, credentials)

Retention Policy

  • 5 daily backups
  • 4 weekly backups
  • 6 monthly backups

Backup Contents

Each backup set includes:

  • db.sql.gz - Compressed MySQL dump
  • instance/ - Uploaded files, branding, floor plans, maps
  • manifest.json - Schema revisions for compatibility checking

Restore

  1. Go to Settings > Backups in web UI
  2. Select a backup set
  3. Click Restore
  4. System validates schema compatibility and restores database + files

Local Development Setup

For local dev on Windows, configure a local backup directory:

  1. Add to .env:

    SHOPDB_BACKUPS_ROOT=C:/Users/YOUR_USERNAME/Documents/github/flask-shopdb/backups
    
  2. Create the directory:

    mkdir backups
    
  3. Restart Flask

Note: Actual backup execution requires Docker (the backup container). The API can queue backups but won't execute them without the sidecar container.

First Deployment

On fresh install, /api/shopdbbackups returns empty list - this is normal. No backups exist until first backup runs.

Troubleshooting

"No backups found"

  • Check /backups volume is mounted
  • Verify backup container ran: docker logs shopdb-backup-1

"500 error on backup endpoint"

  • Must be logged in as admin
  • Check Flask logs for details

"Restore failed: incompatible schema"

  • Backup is from newer ShopDB version
  • Update code first, then restore

API Endpoints

All require admin role:

  • GET /api/shopdbbackups - List backups
  • POST /api/shopdbbackups - Trigger backup
  • POST /api/shopdbbackups/<id>/restore - Restore backup
  • GET /api/shopdbbackups/status - Current status
  • GET /api/shopdbbackups/history - Backup history

Security

  • Backups contain sensitive data (DB dump, uploads)
  • Secure /backups volume with appropriate permissions
  • Use encrypted storage for offsite backups
  • Only admin role can access backup endpoints