I do try to create a dump of a table, that is stored inside of my database. The table is called
In order to create the dump, I do use following commands:
docker-compose exec db1 pg_dump -F tar -d db -U user -t webapp_product > /home/backup.tar
Then, on the other machine:
sudo mv backup.tar ../pgdata docker-compose exec db1 sh pg_restore -Ft -C -U user -d db /var/lib/postgresql/data/pgdata/backup.tar
Unfortunately, it always ends up with the same scenario. I do receive following error log:
pg_restore: error: could not read from input file: end of file
I have also tried the other way. After moving the backup file, I have been trying to use:
cat /var/lib/postgresql/data/pgdata/backup.sql | psql -d db -U user
After invoking that command, I have been receiving an error saying that I am unable to create duplicates (IDs of the records were the same.) In order to go further, I have tried to turn off all of the constrains, but without any expected effects.
The backup.tar file consists of a following lines:
-- NOTE: -- -- File paths need to be edited. Search for $$PATH$$ and -- replace it with the path to the directory containing -- the extracted data files. -- -- -- PostgreSQL database dump -- -- Dumped from database version 12.1 (Debian 12.1-1.pgdg100+1) -- Dumped by pg_dump version 12.1 (Debian 12.1-1.pgdg100+1)
Can it affect the process of restoring the data?
and has a following ending:
-- -- PostgreSQL database dump complete --