Git Product home page Git Product logo

br-pgbr's Introduction

pgbr

PostgreSQL simple backup & restore helper tool created for usage with Backup Repository, but can be used also standalone.

Features:

  • Opinionated backup & restore commands basing on PostgreSQL built-in commands

Requirements:

  • Linux (x86_64/amd64 architecture)
  • PostgreSQL in desired version

Conception

Sensible defaults

Backup & Restore should be simple and fault-tolerant, that's why this tool is automating basic things like disconnecting clients, or connecting to database using an empty database schema during restore - we cannot restore database we connect to, also we cannot recreate from backup something that is in use.

Both pgbr db backup and pgbr db restore should work out-of-the-box with sensible defaults.

Backup

Selected database or all databases are dumped into a custom formatted file, readable by pg_restore.

# for single database "pbr"
pgbr db backup --password riotkit --user riotkit --db-name pbr > dump.gz

# for all databases
pgbr db backup --password riotkit --user riotkit > dump.gz

Restore

Procedure:

  1. Existing connections to selected one database, or to all databases are terminated
  2. Selected database, or all databases are closed for incoming connections
  3. Selected database, or all databases are recreated from backup using pg_restore, which uses --clean and --create by default
cat dump.gz | ./.build/pgbr db restore --password riotkit --user riotkit --connection-database=postgres

Passing extra arguments

Both pgbr db backup and pgbr db restore are supporting UNIX-like parameters passing to subprocess, which is pg_dump/pg_dumpall for Backup and pg_restore for Restore.

Example

pgbr db backup --password riotkit --user riotkit -- --role=my-role > dump.gz

Using tooling from docker image

pgbr can rely on your host OS or use docker run to trigger psql, pg_dump, pg_dumpall or pg_restore.

In order to use a docker image that will provide client tools you can set those environment variables:

export PGBR_USE_CONTAINER=true
export POSTGRES_VERSION=15

# optional: image name
export PGBR_CONTAINER_IMAGE=my-registry/image-name 

br-pgbr's People

Contributors

blackandred avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

dystudio

br-pgbr's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.