I am trying to clone a schema in my remotely hosted Postgres 15 database, without affecting the original schema. I decided to do this in the method outlined here in the most-upvoted answer, i.e. using pg_dump to get a plain text file backup, "hacking" the dump to find and replace all references to old_schema with new_schema (because I cannot afford to take the master schema off the grid and I have hard-coded schema-qualified names in functions), and then restoring using psql.
The issue is that when I try to restore, I get this:
ERROR: syntax error at or near "psql".
I'm restoring using the PSQL shell on a Mac and after logging into my database, attempted to run these commands. All resulted in the same error, pointing to the start of the command as incorrect. What is the incorrect syntax in my commands? I also tried using a backslash at the start and omitting the psql part, neither of those worked either.
psql my_db -f '/path/to/file.pgsql';
psql my_db -f /path/to/file.pgsql;
psql -U username -d dbname < /path/to/file.sql;
psql -U username -d dbname < '/path/to/file.sql';
psqlis not apsqlmeta-command; you should run what you've tried to run from the OS shell command line. – mustaccio May 23 '23 at 20:23