Skip to main content

Production-grade backup engine for files, PostgreSQL, MySQL, MongoDB and MSSQL — with a built-in web dashboard, login system and pluggable database backends.

Project description

pybackup-engine

Production-grade backup engine for files and databases — with a built-in web dashboard, user login system, and pluggable database backends.

PyPI version Python 3.10+ License: MIT Tests


Features

Feature Detail
Backup engines Files, PostgreSQL (pg_dump), MySQL (mysqldump), MongoDB (mongodump), MS SQL Server (sqlcmd)
Web dashboard Built-in pure Python HTTP server — no Flask, FastAPI or Django
Login system PBKDF2 password hashing, session tokens, admin/viewer roles
User management Create, list, delete users via CLI or web UI
Change password Users can change their own password in the dashboard
Database backends SQLite (default), PostgreSQL, MySQL, MongoDB, MSSQL — like Django's DATABASES
CLI run, serve, verify, checksum, config-check, user add/list/delete
Fonts Space Grotesk headings · Inter body
Theme Dark / Light toggle

Install

pip install pybackup-engine

With optional database backend support:

pip install pybackup-engine[postgresql]   # psycopg2-binary
pip install pybackup-engine[mysql]        # PyMySQL
pip install pybackup-engine[mongodb]      # pymongo
pip install pybackup-engine[mssql]        # pyodbc
pip install pybackup-engine[all]          # all backends

Quick Start

1. Create the first admin user

pybackup user add --username admin --role admin

2. Write a config

# pybackup.yaml
version: 1

global:
  backup_root: /backups
  retention_days: 7
  compress: true

# Internal metadata database (SQLite by default, switch to postgres/mysql/etc)
database:
  backend: sqlite
  name: /var/lib/pybackup/pybackup.db

postgresql:
  enabled: true
  jobs:
    - name: prod-db
      host: localhost
      database: myapp
      username: backup_user
      password: ${PGPASSWORD}

files:
  enabled: true
  jobs:
    - name: configs
      source: /etc/myapp
      exclude: ["*.log", "*.tmp"]

3. Run backups

pybackup run --config pybackup.yaml

4. Start the dashboard

pybackup serve --port 8200

Open http://localhost:8200 → login with your admin credentials.


CLI Reference

pybackup run           -c config.yaml [--dry-run]
pybackup serve         [--host 0.0.0.0] [--port 8200] [-c config.yaml]
pybackup verify        FILE --checksum SHA256 [--algorithm sha256]
pybackup checksum      FILE [--algorithm sha256]
pybackup config-check  -c config.yaml

pybackup user add          --username USER --role admin|viewer
pybackup user list
pybackup user delete       --username USER
pybackup user set-password --username USER

Database Backends

Inspired by Django's DATABASES setting — just change the backend: value:

# SQLite (default, zero config)
database:
  backend: sqlite
  name: /var/lib/pybackup/pybackup.db

# PostgreSQL
database:
  backend:  postgresql
  host:     localhost
  port:     5432
  name:     pybackup
  user:     pybackup_user
  password: ${DB_PASSWORD}

# MySQL / MariaDB
database:
  backend:  mysql
  host:     localhost
  name:     pybackup
  user:     pybackup_user
  password: ${MYSQL_PASSWORD}

# MongoDB
database:
  backend:  mongodb
  host:     localhost
  name:     pybackup
  user:     pybackup_user
  password: ${MONGO_PASSWORD}

# MS SQL Server
database:
  backend:  mssql
  host:     localhost
  name:     pybackup
  user:     sa
  password: ${MSSQL_PASSWORD}

REST API

All endpoints under /api/ — authenticated via Authorization: Bearer <token>:

Method Path Auth Description
POST /api/auth/login Public Login, returns session token
POST /api/auth/logout Session Logout
GET /api/auth/me Session Current user info
POST /api/auth/change-password Session Change own password
GET /api/users Admin List all users
POST /api/users Admin Create user
DELETE /api/users/:id Admin Delete user
GET /api/stats Session Dashboard statistics
GET /api/runs Session Paginated run list
POST /api/runs Session Create a run entry
GET /api/runs/:id Session Run detail + files
DELETE /api/runs/:id Admin Delete a run
GET /api/settings Session Get settings
POST /api/settings Session Update settings

Project Structure

pybackup/
├── cli.py                    # Click CLI (run/serve/verify/user)
├── auth.py                   # PBKDF2 passwords, session tokens, UserDB
├── constants.py
├── config/loader.py          # YAML + env var expansion
├── engine/
│   ├── base.py               # BaseBackupEngine (prepare/run/finalize)
│   ├── files.py              # File/dir backup with tar.gz support
│   ├── mongo.py / postgres.py / mysql.py / mssql.py
│   ├── verify.py             # SHA-256/512 checksums
│   └── manifest.py           # JSON sidecar manifests
├── db/
│   ├── database.py           # SQLite implementation
│   └── backends/
│       ├── __init__.py       # get_database() factory
│       ├── postgres_backend.py
│       ├── mysql_backend.py
│       ├── mongo_backend.py
│       └── mssql_backend.py
├── server/
│   ├── httpserver.py         # Pure stdlib ThreadingHTTPServer + Router
│   └── handlers.py           # All REST API handlers
└── static/
    ├── login.html            # Login page
    ├── index.html            # SPA dashboard
    ├── css/app.css           # Space Grotesk + Inter · dark/light
    └── js/app.js             # Vanilla JS SPA

Security

  • Passwords hashed with PBKDF2-HMAC-SHA256 (600,000 iterations, 32-byte salt)
  • Session tokens are cryptographically random 32-byte hex strings
  • Sessions expire after 8 hours
  • Database credentials resolved from environment variables (${VAR} syntax)
  • Constant-time password comparison to prevent timing attacks

License

MIT © PyBackup Contributors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybackup_engine-2.0.0.tar.gz (68.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pybackup_engine-2.0.0-py3-none-any.whl (72.4 kB view details)

Uploaded Python 3

File details

Details for the file pybackup_engine-2.0.0.tar.gz.

File metadata

  • Download URL: pybackup_engine-2.0.0.tar.gz
  • Upload date:
  • Size: 68.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pybackup_engine-2.0.0.tar.gz
Algorithm Hash digest
SHA256 9e72077bc869c3599ca80fe6f487159c6935bfed3e53adad4c684accf8afdafc
MD5 3a1c962453ad3d64409f5cdb333a5496
BLAKE2b-256 52d1487ca2b9ead24ba60c2089865c9a1acf90acee5aa63de57115ee56cf384a

See more details on using hashes here.

File details

Details for the file pybackup_engine-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pybackup_engine-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 efdb555a26b2e382302027382ee722dea3d60ea551e185e6ee829af14e6d7f58
MD5 de501b3fc2b2959b402ae35cac6af354
BLAKE2b-256 41b47533e43c689fec7c492787a8fddfbd9c09960ef422ea30d865813a49ab22

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page