Best pg_dump practices

Started by MTalmost 23 years ago2 messagesgeneral
Jump to latest
#1MT
mt@open2web.com

Hi,

Now that I've painstakinly entered my data into the db, I'd like to perform regular backups using pg_dump as such

pg_dump -c -f dumpfile.sql dbname

This will give me the data in its original, pristine form. Note that using pg_dump this way means that the data gets dumped as copy too. Is there a way to dump only the db objects (ie. tables, sequences, etc) and exclude the data.

Then, as the db is used, I would perform daily backups, automated with cron.

pg_dump -a -f daily_dumpfile.sql dbname

I would then tar and gzip the daily_dumpfile.sql and upload it to a backup server.

Now, if the database should suddenly crash, I would do retrieve the dumpfiles, untar them and

psql dbname
\i dumpfile.sql
This would create the db in its original form.

\i daily_dumpfile.sql
This would bring the reconstituted db up to date.

Then again, �I'm not sure if this works. Furthermore, maybe someone could recommend a better way to perform this task.

--
Thanks,

Mark

#2Roderick A. Anderson
raanders@acm.org
In reply to: MT (#1)
Re: Best pg_dump practices

On Thu, 12 Jun 2003, MT wrote:

Hi,

This will give me the data in its original, pristine form. Note that
using pg_dump this way means that the data gets dumped as copy too. Is
there a way to dump only the db objects (ie. tables, sequences, etc)
and exclude the data.

man pg_dump gives me (on an older version - 7.2.1 :-)

pg_dump -s

Rod
--
"Open Source Software - Sometimes you get more than you paid for..."