PostgreSQL external database dump

  • 22 September 2022

Userlevel 1
  • Not a newbie anymore


I am using a managed PostgreSQL database. I would like to dump / restore it using Kasten.

Is it possible to do it? Kind of pg_dump / pg_restore in a pod.

I have not found any example of such blueprint.

Many thanks for your help.


Userlevel 7
Badge +22

Hi Lejav,


Have you tried using this blueprint, if I remember correctly it is simply sending the db dump to S3:





Userlevel 1

Thanks for your answer.

But if I understand well, this blueprint is run as a sidecar of a postgres server and the annotation on the postgres deployment allows to backup the database.

How to do for my use case?

Userlevel 6
Badge +2

@lejav Thanks for posting this question.

As Geoff mentioned, You could re-purpose the blueprint in such a way that it points to your external postgres server.

#this points to local kubernetes service as of now. But if you have the connectivity, you could point that to an external server as well.

export PGHOST='{{ index .Object.metadata.labels "" }}-postgresql.{{ .StatefulSet.Namespace }}.svc.cluster.local’

All you should do is run a dummy statefulset, annotated with the blueprint(include that in the backup policy with a location profile set for kanisterActions).

The blueprint runs a `KubeTask` function which doesn't expect a sidecar. It will spin up a new pod with the image specified in the blueprint and performs all the phases under action.

Downside is that the dummy statefulSet will also be a part of your backup. But it does’t cause any issues wrt to your db dump or restore as such.




Userlevel 1

Hi Jaiganesh,

Many thanks for your suggestion. I came to this conclusion but was not sure if it could work.

You confirm that this is the solution! Great!

I will do like that.


Userlevel 6
Badge +2

Thanks @lejav . Let us know if you face any issues in doing that.