file doesn't have access to pg_dump or psql

I’m trying to copy some data around as part of my script on preview apps. However / line 31: pg_dump: command not found is what I get when I try and run pg_dump. Is there something I can do to make these commands available?

Hi @Brandyn_Bennett! Good question. At the moment psql and pg_dump are available to running services and in the web shell, but not at build time. We’ll go ahead and add these to the build environment for you.

Depending on your use case, you may be able to define an initialDeployHook that does the data copying instead of making this part of your build process. The initialDeployHook is a command that runs only once, after your preview environment is deployed for the first time. It should already have access to psql and pg_dump.

See Preview Environments | Render · Cloud Hosting for Developers for more on the initialDeployHook.

Thank you! Looks like initialDeployHook was what I needed.

1 Like

My pleasure! I’m glad the initialDeployHook will work for your use case. For future reference and for others who might be wondering, you can now use psql and pg_dump as part of your build process.