Coder Social home page Coder Social logo

gcloud-psql-cron's Introduction

gcloud-psql-cron

Docker container uses cron and psql to do a database backup and then write the backup to object storage using the gcloud cli.

usage

  • create a service account that has a Storage -> Storage Object Creator role
  • download the .json key file and save it

You can now either:

  • add the key to a custom image FROM binocarlos/gcloud-psql-cron
  • mount the key as a Docker volume
  • use k8s secrets

You end up with a file that contains the key.

To configure the container:

$ docker run
  -e SERVICE_ACCOUNT_EMAIL=... \
  -e SERVICE_ACCOUNT_KEY_FILE=/service-account-key.json \
  -v ./mykey.json:/service-account-key.json \
  binocarlos/gcloud-psql-cron

vars:

  • SERVICE_ACCOUNT_EMAIL - email associated with the service account
  • SERVICE_ACCOUNT_KEY_FILE - path to the file containing the private key for the service account
  • SERVICE_ACCOUNT_PROJECT - gcloud project
  • SERVICE_ACCOUNT_STORAGE_BUCKET - the storage bucket to save the backups
  • POSTGRES_SERVICE_HOST - hostname for the postgres database
  • POSTGRES_SERVICE_USER - postgres user
  • POSTGRES_SERVICE_PASSWORD - postgres password
  • POSTGRES_SERVICE_DATABASE - postgres database

crontab

You can control when the backup happens by adding a custom cronfile to /cron/crontab that points to the /app/backup.sh script.

Here is the default crontab that runs every hour:

0 * * * * /app/backup.sh

license

MIT

gcloud-psql-cron's People

Contributors

binocarlos avatar

Watchers

 avatar  avatar

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.