Skip to main content

edwh plugin for quick database snapshot creation and recovery

Project description

EDWH Development Database (devdb) Plugin

Overview

The EDWH Development Database Plugin provides a comprehensive set of tools for managing snapshots of the development database. This plugin allows developers to create, push, pop, recover, and list database snapshots efficiently.

Features

  • Snapshot Management: Create and manage snapshots of the development database.
  • Selective Exclusion: Optionally exclude specific tables during snapshot creation.
  • Remote Operations: Push and pop snapshots to/from a remote server.
  • Database Recovery: Recover the database from previously created snapshots.
  • Environment Setup: Easy setup of environment variables for PostgreSQL connections.

Requirements

  • Python 3.12+
  • Docker Compose
  • PostgreSQL
  • EDWH environment variables configured (usually via edwh setup)

Installation

Development Installation

To install the plugin in development mode, run:

uv pip install -e .[dev]

Production Installation

For production use, you can install the plugin using:

uvenv install edwh[devdb]

Alternatively, you can add the plugin directly with:

edwh plugin.add devdb

Usage

Environment Variables

Ensure the following environment variables are set:

  • POSTGRES_USERNAME: Username for PostgreSQL (default: postgres)
  • POSTGRES_PASSWORD: Password for PostgreSQL (default: password)
  • PGPOOL_PORT: Port for pgpool (default: 5432)
  • POSTGRES_DATABASE: Name of the PostgreSQL database (default: backend)

Then you can run edwh setup and the other required variables can be infered.

Commands

Create a Snapshot

To create a snapshot of the development database:

ew devdb.snapshot

You can exclude specific tables using optional parameters:

ew devdb.snapshot --without_api_activity False --without_applog False

List Snapshots

To list all snapshots in reverse chronological order:

ew devdb.list

Rename a Snapshot

To rename the most recent snapshot:

ew devdb.rename <new_name>

Push a Snapshot

To push the local snapshot to a remote server:

ew devdb.push

Pop a Snapshot

To download and prepare a snapshot from a given URL:

ew devdb.pop <url>

Recover a Snapshot

To recover the database from a snapshot:

ew devdb.recover

This assumes an empty database. An easier alternative is:

Reset the Database

To reset your database to the latest state:

ew devdb.reset

Notes

  • Be cautious when using the reset command as it will clear your PostgreSQL database and remove all existing data.

Repository

The source code is available at GitHub.

License

This project is licensed under the MIT License.

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

edwh_devdb_plugin-0.6.0.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

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

edwh_devdb_plugin-0.6.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file edwh_devdb_plugin-0.6.0.tar.gz.

File metadata

  • Download URL: edwh_devdb_plugin-0.6.0.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for edwh_devdb_plugin-0.6.0.tar.gz
Algorithm Hash digest
SHA256 9b0a89939e322008fea4a1e2a7eb0189777f97999d8116e8de49ae96207ee778
MD5 8df78d88b4c8367442d3b201a6a98759
BLAKE2b-256 8b8ef369fddcc221a9b77d5037bba3538f9f04ea5b273dde4b5b50183e06743c

See more details on using hashes here.

File details

Details for the file edwh_devdb_plugin-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for edwh_devdb_plugin-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b3400de625d26157940ccb83b0ab5bc9a77fdd1b76205c63284287173f020ee
MD5 1aa6e724f74bf3dc1e7079a80d90b694
BLAKE2b-256 1abe4c1332611a1ff6efc5b563873b078ccc86ced4b91c81b8efa68fd40dd4b0

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