473,395 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

pg_dump: what is advantage with schema and data dumps?

Hi,

I've seen in previous posts that recommended practice for database backup is
to run the dump utility twice. Once for schema only and a second time for
data only (I think). Up to know, I've only ever dumped both, and have never
had a problem restoring into older/newer versions of postgres, nor with
restoring into other commercial versions of postgres. This is a testament
of the robustness of pg_dump! Of course, there are always a series of error
messages at the start of each restore when duplicate/unknown template DB
functions are recreated, but these have never prevented the core data from
being properly copied into the database.

Am I setting myself up for disaster with only a single dump as a backup?

Much thanks,
Peter
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #1
2 2692
> I've seen in previous posts that recommended practice for database backup is
to run the dump utility twice. Once for schema only and a second time for
data only (I think). Up to know, I've only ever dumped both, and have never
had a problem restoring into older/newer versions of postgres, nor with
restoring into other commercial versions of postgres. This is a testament
of the robustness of pg_dump! Of course, there are always a series of error
messages at the start of each restore when duplicate/unknown template DB
functions are recreated, but these have never prevented the core data from
being properly copied into the database.
pg_dump is not always smart about ordering of objects when there are
custom items in play. For example, pg_dump does not restore correctly if
you use TSearch (although I believe there is a patch).

So, if you dump the schema separately you can fix any ordering problems,
or data type problems (from version to version) that you may encounter.
Which in turn will allow you to restore your data safely.

Also there are times when you only want to restore the structure and not
the constraints or indexes things like that. Dumping the database in two
parts allows you to edit the schema without having to open a 50gig file
in joe or vi ;)

Sincerely,

Joshua D. Drake

Am I setting myself up for disaster with only a single dump as a backup?

Much thanks,
Peter
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

--
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com
Mammoth PostgreSQL Replicator. Integrated Replication for PostgreSQL
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #2
"Anony Mous" <A.****@shaw.ca> writes:
I've seen in previous posts that recommended practice for database backup is
to run the dump utility twice. Once for schema only and a second time for
data only (I think).


I don't know who recommended that, but I sure wouldn't do it that way.

If you do do it that way then the restore will be slow, at least if you
have any indexes or foreign keys. It's better to load the data first
and then create indexes/verify foreign keys. pg_dump does do things in
that order if you use a single dump, but obviously it cannot if you dump
schema and data separately.

What I *would* recommend is a single dump in either -Fc or -Ft mode.
The reason for this is that if needed, you can use pg_restore's options
to alter the restore order, which can get you out of trouble if you run
into one of the various pg_dump bugs about dumping related objects in
the wrong order. (I think said bugs are finally all fixed for 8.0, but
they are a fact of life in released PG versions, so you should be
prepared to deal with 'em.)

If you use a text dump then you have to be willing to fix any ordering
problems by editing the dump file ... which can be a tad unwieldy if
it's a big dump.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Marcin Gil | last post by:
Hi! I dumped a DB using pg_dump from version 7.2.3 and tried to read it into DB with psql|pg_restore of version 7.3.3. I got an error 'pg_atoi: zero-length string' during the creation of...
0
by: Martin Hart | last post by:
Hi, postgresql 7.4beta4 on linux and postgresql 7.3.4 on linux We have a database that we routinely backup using "pg_dump -a" We have to do this (dump the data only) because of various...
2
by: Patrick Hatcher | last post by:
Pg: 7.4. I thought there was supposed to be switch to allow dumping of schema X from a database in version 7.4? But I don't see one. Is it still not possible? TIA Patrick Hatcher
4
by: jack turer | last post by:
I have a database in pgsql (7.3.2) on redhat 9. When I try a 'pg_dump mydb' to back up the database, I get: pg_dump: could not find namespace with OID 2200 Verbose version is: -bash-2.05b$...
6
by: Rory Campbell-Lange | last post by:
I think this is a suggestion/comment! pg_dump man page: --schema-only Dump only the schema (data definitions), no data I think this use of the word schema is confusing, meaning data...
6
by: Soeren Gerlach | last post by:
Hi, some weeks ago I started to develop an application using Postgresql the first time. I'm running 7.4.3 on a Linux box with a plain 2.6.7 kernel, the storage is handled by 5 SATA disks,...
1
by: Neil Zanella | last post by:
Hello, I have an SQL database which I create with: psql -f create.sql foodb I then access this database and perform several insertions, modifications, and deletions. Finally, I want to...
1
by: Ben Trewern | last post by:
All, There seems to be a bug in pg_dumpall: For one of my dbs I've done: ALTER DATABASE dbname SET search_path = mw, public; If I do a pg_dumpall I get a line like:
6
by: Ilia Chipitsine | last post by:
Dear Sirs, I want to dump all databases, but separately each database in its own file, not all databases in one single file as pg_dumpall does. How can I implement that ? Cheers, Ilia...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.