I am looking for a solution to backup my Cloud SQL schemas (and Cloud Storage files).

At first I tried using Cloud Scheduler to call the googleapis (https://cloud.google.com/sql/docs/postgres/import-export/exporting) in order to make an export of the database. The problem is that I need specific backup arguments, and I need to export specific schemas in the PostgreSQL database. Each of my clients has a schema, and i would like to be able to restore a schema without restoring the entire database. Googleapis don't seem to support exporting specific schemas (yet), which is why I would like to call pg_dump directly.

The same problem is with using automatic backups in Cloud SQL. I cannot restore a specific schema in a database, and I need to keep the backups around for atleast a month.

However, I have yet to find a way to call pg_dump using e.g. Cloud Functions. So currently I am thinking about using my own Windows 10 laptop to call pg_dump and to setup a daily task in Windows. I would much rather use Google Cloud, instead of my own laptop.

If anybody has any ideas of how to I should build my backup infrastructure, it would be greatly appreciated.


As you mentioned, the docs say that the backups only work on instances and databases, not on specific schemas. Nothing new here.

I know this might not the best thing to do but due to this restrictions, have you considered an update/change on your design? One database per client so the backups won't become a pain in the back. At least until they release something to backup or export single schemas.

Your bills wouldn't be affected because they charge for storage, not for database or schema. This, however, might take even more time than your expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.