Skip to content
This repository has been archived by the owner on Oct 11, 2020. It is now read-only.

Backup Postgres database in a Kubernetes cluster to GCS bucket

License

Notifications You must be signed in to change notification settings

osakunta/kubernetes-gcs-backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kubernetes GCS Backup

This utility is used to backup data from a Postgres database in Kubernetes cluster to a Google Cloud Storage bucket.

Setup

A service account is used to access the Kubernetes cluster and GCS. A service account private key must be available in the container through GOOGLE_APPLICATION_CREDENTIALS environment variable. The default location is /app/key.json. Other environment variables to configure the container are:

  • NAMESPACE: Cluster namespace (default: production)
  • POSTGRES_DB: Database name (default: postgres)
  • POSTGRES_USER: Database user (default: postgres)
  • BACKUP_BUCKET: GCS bucket name (default: satakuntatalo-services-versioned-backup)

There are also environment variables that must be set as they don't have default values:

  • DB_POD: Name of the pod that contains the database. It can also be the name of the deployment/statefulset and kubectl will choose the first pod it finds.
  • APP_POD: Name of the pod that contains the app using the database. It can also be the name of the deployment and kubectl will choose the first pod it finds. This is used to scale down the app before database restoration and scale it back up again afterwards (TODO: make this optional and take the scale-up as an argument).

About

Backup Postgres database in a Kubernetes cluster to GCS bucket

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published