pg-dump

Postgres: Best way to move data from public schema of one DB to new schema of another DB

徘徊边缘 提交于 2019-12-04 03:05:16
I am new to Postgres and just discovered that I cannot access data of different databases in one SQL query. And also learned the concept of schema in Postgres. Now, I have two databases db1 and db2 Both have tables with same name in their public schema. Now, I want to create a new schema in db1 with name : new_schema And move data from db2.public to db1.new_schema What is the easiest way to do this ? The simplest way to do that is to rename schemas. However you must be sure you are a sole user of db1 database. First, hide your schema public in db1: alter schema public rename to original_public

How to merge dump into database from PostgreSQL?

雨燕双飞 提交于 2019-12-03 16:56:20
问题 I'm working on the same databse schema on different machines (PostgreSQL). I would like to know, how to merge data from one machine to another. Schema has many tables (around 10). What I want to achieve? Dump data from machine A to file A.dmp Restore data from file A.dmp to machine B When a record already exists in machine B, I would like to don't insert it into machine B. I was trying dump data from machine A to simple SQL inserts commands, but when I'm trying to restore it, I am getting

“permission denied” for pg_dump output file

帅比萌擦擦* 提交于 2019-12-03 12:05:45
i used below command to backup my database sudo -u user_name pg_dump dbName -f /home ..../someWhere/db.sql but it gives me this : pg_dump: [archiver] could not open output file "/home ..../someWhere/db.sql": Permission denied after googling this issue i find that i must backup my data under the /tmp path , but doesn't work how can i resolve this issue ? thanks in advance, i am using Ubuntu 12.04 lts try pg_dump from psql command-line as below: postgres=# \! pg_dump dbName -f /home ..../someWhere/db.sql It looks like your pg_dump is working fine, but it is having problems opening the output

Is there a way to get pg_dump to exclude a specific sequence?

人盡茶涼 提交于 2019-12-03 11:23:50
问题 I want to exclude a sequence from my pg_dump command which is putting the output into a plain file. Command: /Library/PostgreSQL/8.4/bin/pg_dump --host localhost --port 5433 --username xxx --format plain --clean --inserts --verbose --file /Users/xxx/documents/output/SYSTEM_admin_20131126015325.sql --exclude-table public.table1 --exclude-table public.table2 mydatabase I know there are switches for tables which i am using above and that you can enable/disable database objects in the tar format

How to merge dump into database from PostgreSQL?

十年热恋 提交于 2019-12-03 06:47:55
I'm working on the same databse schema on different machines (PostgreSQL). I would like to know, how to merge data from one machine to another. Schema has many tables (around 10). What I want to achieve? Dump data from machine A to file A.dmp Restore data from file A.dmp to machine B When a record already exists in machine B, I would like to don't insert it into machine B. I was trying dump data from machine A to simple SQL inserts commands, but when I'm trying to restore it, I am getting duplicate key errors. What is more, I would like to restore data from command line (I have to import 250

Is there a way to get pg_dump to exclude a specific sequence?

孤街醉人 提交于 2019-12-03 01:44:45
I want to exclude a sequence from my pg_dump command which is putting the output into a plain file. Command: /Library/PostgreSQL/8.4/bin/pg_dump --host localhost --port 5433 --username xxx --format plain --clean --inserts --verbose --file /Users/xxx/documents/output/SYSTEM_admin_20131126015325.sql --exclude-table public.table1 --exclude-table public.table2 mydatabase I know there are switches for tables which i am using above and that you can enable/disable database objects in the tar format in combination with pg_restore as stated in the pg_dump documentation but I will not be using pg

pg_dump postgres database from remote server when port 5432 is blocked

心已入冬 提交于 2019-12-03 01:28:35
问题 I'm trying to pg_dump a SQL database on a remote server in our DMZ. There are 2 problems. 1) there is n't a lot of space left on the remote server so the normal command run to locally backup the database pg_dump -C database > sqldatabase.sql.bak won't work due to space issues. 2) I also can't run the other version of pg_dump command to dump database from remote server to local server using: pg_dump -C -h remotehost -U remoteuser db_name | psql localhost -U localuser db_name as the server is

How do I convert a binary pgdump (compressed) to a plain SQL file?

馋奶兔 提交于 2019-12-02 21:44:44
I do want to search for some data inside a database dump but these dumps are using the binary-compressed format ( PGDMP header). How can I convert these to SQL without restoring them? Craig Ringer pg_restore , when run without a database name, outputs a text dump to stdout; you can send that elsewhere with -f or with I/O redirection. pg_restore -f mydatabase.sql mydatabase.dump The fastest method that I've used was: pg_restore mybinaryfile.backup > mysqlfile.sql No special flags, since pg_restore just spits it out to stdout. Note that if you run multiple clusters, the restore command may not

How do I do a schema only backup and restore in PostgreSQL?

时光毁灭记忆、已成空白 提交于 2019-12-02 17:30:51
How do I take a schema level backup in PostgreSQL database and restore on the another database? Is there any single command available for this? For example, can I pg_dump and restore in single line? pg_dump --schema=masters oldDB > masters1.sql cat masters1.sql | psql newDB or in single command you can do by this pg_dump oldDB --schema masters | psql -h localhost newDB; Backup schema and restore it on system for postgresql as below: Dump schema for database pg_dump -s database_name > db.sql Dump schema for specific table pg_dump -s database_name -t table_name > db.sql Restore backed up schema

pg_dump postgres database from remote server when port 5432 is blocked

一个人想着一个人 提交于 2019-12-02 16:42:49
I'm trying to pg_dump a SQL database on a remote server in our DMZ. There are 2 problems. 1) there is n't a lot of space left on the remote server so the normal command run to locally backup the database pg_dump -C database > sqldatabase.sql.bak won't work due to space issues. 2) I also can't run the other version of pg_dump command to dump database from remote server to local server using: pg_dump -C -h remotehost -U remoteuser db_name | psql localhost -U localuser db_name as the server is in our DMZ and port 5432 is blocked. What I'm looking to see is if it is possible to pg_dump the