0

I have a database which contains 50 tables (5 schemas, 5 tablespaces). And tried to take a backup of few tables (each table in different tablespace) using following command.

$psql -U my_db_user my_db_name -t my_table_1 -t my_table_2 -t my_table_3 > ttables.sql

Above command is working fine to take the *sql backup. But the table column value is having null values. While restoring the the dump using the following command getting some error due to null (\N) values which is in backup file (ttables.sql).

$cat ttables.sql | psql -d new_db -U new_db_user

Is there any way to avoid \N characters in backup dump file? or Any wrong with backup / restore command which I have used?

(Postgres version 9.1)

Spike
  • 734
  • 1
  • 12
  • 22
  • 1
    possible duplicate of [psql invalid command \N while restore sql](http://stackoverflow.com/questions/20427689/psql-invalid-command-n-while-restore-sql) – Kristján Jul 24 '15 at 15:12
  • have verified that too, didn't work. – Spike Jul 24 '15 at 16:22
  • 1
    The first command will not take a backup. Did you mean to write `pg_dump` instead of `psql`? –  Jul 26 '15 at 20:11
  • yes, I need to take pg_dump of few tables and i have used pg_dump --host host_name --port port_id --username "user_name" --format custom --verbose --file "/home/user/tbl_bkp.backup" --table "s1.tbl1" --table "s2.tbl2" --table "s2.tbl1" "db_name". seems command executed successfully. But while doing pg_restore with the following command, pg_restore --host host_name--port port_id --username "user_name" --dbname "new_db_name" --role "role_name" --schema public --verbose "/home/user/tbl_bkp.backup" not getting the expected output. showing constraint related error. so that, I have tried psql. – Spike Jul 27 '15 at 09:15

0 Answers0