Re: Consistent state for pg_dump and pg_dumpall

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Consistent state for pg_dump and pg_dumpall
Date: 2015-05-20 19:28:16
Message-ID: 555CE050.2020707@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 5/20/2015 10:44 AM, Michael Nolan wrote:
>
> When I moved to a new release of pg (9.3) last December, I stopped all
> transaction processing first so that pg_dumpall had no consistency
> issues.

the only possible consistency issue would be if you have applications
doing 2-phase commits to two different databases on the same server,
otherwise each database is dumped as a single transaction and all data
elements within that database are point-in-time consistent.

my preferred backup procedure for a whole server dump is to

A) pg_dumpall --globals-only | gzip > ...
B) for each database, do pg_dump -Fc -f $database.Fc.pgdump $database

I do this via the following crontab entry for hte postgres user...

$ crontab -l
30 1 * * * /var/lib/pgsql/cronbackup.sh

and this script...

#!/bin/bash
#
/usr/pgsql-9.3/bin/pg_dumpall --globals-only | gzip >
/home2/backups/pgsql/pgdumpall.globals.`date +\%a`.sql.gz
for i in $(psql -tc "select datname from pg_database where not
datistemplate"); do \
pg_dump -Fc -f /home2/backups/pgsql/pgdump.$i.$(date +\%a).dump $i
done

--
john r pierce, recycling bits in santa cruz

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stefan Stefanov 2015-05-20 20:16:35 About COPY command (and probably file fdw too)
Previous Message Peter Swartz 2015-05-20 19:23:09 Enum in foreign table: error and correct way to handle.