Home > Blockchain >  Postgres database export and import, problem with $$PATH$$
Postgres database export and import, problem with $$PATH$$

Time:02-15

I am in the process of doing export and import with postgres database.

I had used the following command to take the backup of postgres db

C:\dirs> pg_dump -U postgres -p 15432 -W -F t cgate-next-demo > .\dbexport_10th_February_2022.tar
Password:*****

I have unzipped dbexport_10th_February_2022.tar file and proceeded with database import. As a initial step, I had dropped the database.

#drop database if exists "cgate-next-demo";

And I had recreated the empty database.

#create database "cgate-next-demo";

In order to do this, I have logged in to psql once,

C:\dirs> psql -U postgres -p 15432
Password for user postgres:*****
postgres=#

For database import I have used the following command.

C:\dirs> psql -U postgres -p 15432 -d cgate-next-demo <restore.sql

While I do that I have got the following error. I took this excerpt from console logs.

ERROR: could not open file "$$PATH$$/6052.dat" for reading: No such file or directory HINT: COPY FROM instructs the PostgreSQL server process to read a file. You may want a client-side facility such as psql's \copy.

Can someone guide on what would've caused this issue.

CodePudding user response:

You are doing this in the wrong fashion. Rather than unpacking the archive, pass it as argument to pg_restore. That will do everything for you.

  • Related