pg-dump

Use pg_restore to restore from a newer version of PostgreSQL

爷,独闯天下 提交于 2020-01-20 03:28:11
问题 I have a (production) DB server running PostgreSQL v9.0 and a development machine running PostgreSQL v8.4. I would like to take a dump of the production DB and use it on the development machine. I cannot upgrade the postgres on the dev machine. On the production machine, I run: pg_dump -f nvdls.db -F p -U nvdladmin nvdlstats On the development machine, I run: pg_restore -d nvdlstats -U nvdladmin nvdls.db And I got this error: pg_restore: [archiver] unsupported version (1.12) in file header

Use pg_restore to restore from a newer version of PostgreSQL

眉间皱痕 提交于 2020-01-20 03:28:04
问题 I have a (production) DB server running PostgreSQL v9.0 and a development machine running PostgreSQL v8.4. I would like to take a dump of the production DB and use it on the development machine. I cannot upgrade the postgres on the dev machine. On the production machine, I run: pg_dump -f nvdls.db -F p -U nvdladmin nvdlstats On the development machine, I run: pg_restore -d nvdlstats -U nvdladmin nvdls.db And I got this error: pg_restore: [archiver] unsupported version (1.12) in file header

PostgreSQL dump and restore in different timezone

只谈情不闲聊 提交于 2020-01-14 09:20:29
问题 I have two databases running on different servers in different timezones. There is a couple of tables which contains timestamp with timezone . I need to dump data from one database and to import it to another with correct timestamp and correct timezone. I use following command to dump data: pg_dump -a DB_NAME > dump.sql I see data are in old timestamp and timezone format: 2013-11-29 14:30:00+02 Then I use command to another server to restore dump: psql -d DB_NAME -f dump.sql And I see that

How to create a backup of a single table in a postgres database?

依然范特西╮ 提交于 2020-01-11 14:49:23
问题 Is there a way to create a backup of a single table within a database using postgres? And how? Does this also work with the pg_dump command? 回答1: Use --table to tell pg_dump what table it has to backup: pg_dump --host localhost --port 5432 --username postgres --format plain --ignore-version --verbose --file "<abstract_file_path>" --table public.tablename dbname 回答2: If you are on Ubuntu, Login to your postgres user sudo su postgres pg_dump -d <database_name> -t <table_name> > file.sql Make

How to create a backup of a single table in a postgres database?

天大地大妈咪最大 提交于 2020-01-11 14:49:07
问题 Is there a way to create a backup of a single table within a database using postgres? And how? Does this also work with the pg_dump command? 回答1: Use --table to tell pg_dump what table it has to backup: pg_dump --host localhost --port 5432 --username postgres --format plain --ignore-version --verbose --file "<abstract_file_path>" --table public.tablename dbname 回答2: If you are on Ubuntu, Login to your postgres user sudo su postgres pg_dump -d <database_name> -t <table_name> > file.sql Make

Comparing two postgres dump files

馋奶兔 提交于 2020-01-02 01:15:27
问题 How to compare postgres dump files? I have two dump files, dump1 and dump2 . And I want to compare these two dump files. Any help will be appreciated.. Thank you 回答1: PostgreSql's dump files are like normal data files.. you can use any utility/tool to see the difference between them.. Most of the OS has build in utilities for this For example: linux: vimdiff dump1 dump2 (http://alvinalexander.com/linux-unix/vimdiff-see-multiple-file-differences-visually) On Windows: fc dump1 dump2 (http://www

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

流过昼夜 提交于 2019-12-31 08:44:22
问题 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? 回答1: 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; 回答2: Backup schema and restore it on system for postgresql as below: Dump schema for database pg_dump -s database_name

Why is pg_restore returning successfully but not actually restoring my database?

馋奶兔 提交于 2019-12-29 10:53:14
问题 I have a Postgres 8.4 database on a linux server that I have dumped using the following command: pg_dump --format=c --exclude-table=log --file=/path/to/output my_db I then ftp the created file to my local Windows 7 machine and attempt to restore the file to my local Postgres 8.4 instance using the following command: pg_restore --create --exit-on-error --verbose c:\path\to\file The restore command generates plenty of output claiming it created my database, connected to it, and then created all

pg upgrade saving database definition taking time

假装没事ソ 提交于 2019-12-24 14:27:08
问题 I am in process of a pg_upgrade from 8.4 to 9.3. I am using this technique: http://momjian.us/main/writings/pgsql/pg_upgrade.pdf The upgrade has been running since 250 hours, and it has been on the step saving database definition since 160 hours. This is the current output of strace last few lines: poll([{fd=5, events=POLLIN|. POLLERR}], 1, -1) = 1 ([{fd=5, revents=POLLIN}]) recvfrom(5, "T\0\0\0F \0\2reltoastrelid\0\0\0\4\353\0\n \0\0\0\32\0"..., 16384, 0, NULL, NULL) = 122 (5, "Q\0\0\0

pg_dump on Database throwing error 'out of shared memory'

别来无恙 提交于 2019-12-22 05:29:13
问题 Getting problem when taking backup on database contains around 50 schema with each schema having around 100 tables. pg_dump throwing below error suggesting that to increase max_locks_per_transaction . pg_dump: WARNING: out of shared memory pg_dump: SQL command failed pg_dump: Error message from server: ERROR: out of shared memory HINT: You might need to increase max_locks_per_transaction. pg_dump: The command was: SELECT tableoid, oid, prsname, prsnamespace, prsstart::oid, prstoken::oid,