Re: Best pg_dump practices

From: <btober(at)seaworthysys(dot)com>
To: <dbichko(at)genpathpharma(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Best pg_dump practices
Date: 2003-06-13 03:19:05
Message-ID: 64953.66.212.203.144.1055474345.squirrel@$HOSTNAME
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


>> 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.
>
> The -s (--schema-only) flag dumps only the schema, not the data... At
> least according to pg_dump --help
>

It does in fact work as the manual describes. I've used it. What I usualy
do for back-ups though, although you wouldn't want to do this for a huge
database or with sensitive data, is

#!/bin/bash
NAIL=/usr/local/bin/nail
OUTPUT_FILE=dbname_`date +%Y%m%d`
OUTPUT_PATH=/tmp/

# Dump schema and data for backup
pg_dump -U dbname username > ${OUTPUT_PATH}${OUTPUT_FILE}.sql

# Compress for mailing
gzip ${OUTPUT_PATH}${OUTPUT_FILE}.sql

# Send it off-site
echo | ${NAIL} -a ${OUTPUT_PATH}${OUTPUT_FILE}.sql.gz -s ${OUTPUT_FILE}
btober_at_computer_dot_org

OUTPUT_FILE=globals_`date +%Y%m%d`
OUTPUT_PATH=/tmp/

# Dump user and group names for backup
pg_dumpall -g -U postgres > ${OUTPUT_PATH}${OUTPUT_FILE}.sql

# Send it off-site
echo | ${NAIL} -a ${OUTPUT_PATH}${OUTPUT_FILE}.sql -s ${OUTPUT_FILE}
btober_at_computer_dot_org

~Berend Tober

In response to

Browse pgsql-general by date

  From Date Subject
Next Message The Hermit Hacker 2003-06-13 04:13:42 Re: [HACKERS] SAP and MySQL ... [and Benchmark]
Previous Message Lamar Owen 2003-06-13 02:53:36 Re: [HACKERS] SAP and MySQL ... [and Benchmark]