GithubHelp home page GithubHelp logo

isabella232 / postgresql-backup-restore-fs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from silinternational/postgresql-backup-restore-fs

0.0 0.0 0.0 125 KB

Backup and/or restore a PostgreSQL database to/from a local filesystem directory

License: MIT License

Shell 93.35% Makefile 3.44% Dockerfile 3.21%

postgresql-backup-restore-fs's Introduction

postgresql-backup-restore-fs

Service to backup and/or restore a PostgreSQL database to/from a local filesystem directory

How to use it

  1. Create a directory on the filesystem to hold your backups
  2. Supply all appropriate environment variables
  3. Run a backup and check your directory for that backup

Environment variables

MODE Valid values: backup, restore

DB_HOST hostname of the database server

DB_NAME name of the database

DB_OPTIONS optional arguments to supply to the backup or restore commands

DB_ROOTPASSWORD password for the DB_ROOTUSER

DB_ROOTUSER database administrative user, typically "postgres" for PostgreSQL databases

DB_USERPASSWORD password for the DB_USER

DB_USER user that accesses the database (PostgreSQL "role")

BACKUP_DIR e.g., /path/to/database-backups NOTE: no trailing slash

Versioning of the backup file is left as an exercise for the user. This script will overwrite an existing backup file.

Docker Hub

This image is built automatically on Docker Hub as silintl/postgresql-backup-restore-fs

Playing with it locally

You'll need Docker, Docker Compose, and Make.

  1. cd .../postgres-backup-restore-fs
  2. mkdir ./mybackups
  3. cp -p test/world.sql.gz ./mybackups
  4. make db # creates the Postgres DB server
  5. make restore # restores the DB dump file
  6. docker ps -a # get the Container ID of the exited restore container
  7. docker logs <containerID> # review the restoration log messages
  8. make backup # create a new DB dump file
  9. docker ps -a # get the Container ID of the exited backup container
  10. docker logs <containerID> # review the backup log messages
  11. make restore # restore the DB dump file from the new backup
  12. docker ps -a # get the Container ID of the exited restore container
  13. docker logs <containerID> # review the restoration log messages
  14. make clean # remove containers and network
  15. docker volume ls # find the volume ID of the Postgres data container
  16. docker volume rm <volumeID> # remove the data volume
  17. docker images # list existing images
  18. docker image rm <imageID ...> # remove images no longer needed

postgresql-backup-restore-fs's People

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.