peterlamar / postgres-gce

Restore db automation for Postgres in Google Cloud

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

postgres-gce

Automation for Postgres in Google Cloud. This script will restore a postgress database from a backup file stored in google storage. It also has a docker option for extensibility. It is meant to enable automated restoration of a database.

Build

docker build . -t pgrestore

Credentials are grabbed from a local credentials.json file in the root of the project.

Example usage

List and description of environment variables need to set:

PGPASSWORD - password for access a database

PGUSER - PostgreSQL user

PGHOST - PostgreSQL server address

PGPORT - PostgreSQL server port

BUCKET - Google Storage bucket for store backups

PGDATABASE - database for backup

DUMP - filename of dump in bucket

DROP - Drop schema 'public' and everything in it in database. Set to "yes" to use it.

docker run  \
-e "PGPASSWORD=mysecretpassword" -e "PGUSER=postgres" \
-e "PGHOST=localhost" -e "BUCKET=myawesomebucket" -e "PGDATABASE=postgres" \
-e "PGPORT=5432" -e "DUMP=mybackup." "DROP=yes" -i pgrestore restore

About

Restore db automation for Postgres in Google Cloud

License:MIT License


Languages

Language:Shell 82.6%Language:Dockerfile 17.4%