Re: Transaction logs gone, how to restart?

From: "Anjan Dave" <adave(at)vantage(dot)com>
To: "Jeff Boes" <jboes(at)nexcerpt(dot)com>
Cc: <pgsql-admin(at)postgresql(dot)org>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Transaction logs gone, how to restart?
Date: 2004-03-09 16:08:55
Message-ID: 4BAFBB6B9CC46F41B2AD7D9F4BBAF78508C950@vt-pe2550-001.vantage.vantage.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

If it helps in future, I use this script (don't remember where I had
found it..) to backup the databases on disk, and then the backup
directory can be backed up to the tape --

#!/bin/sh

# Backup PostgreSQL

TMPDIR=/var/lib/pgsql/backups
export TMPDIR

echo $TMPDIR

# dump each database schema/data separately
su -l postgres -c "psql -At -F ' ' -U postgres -d template1 <<__END__
SELECT datname FROM pg_database WHERE datallowconn;
__END__
" | while read DB; do
echo "PostgreSQL db $DB"
mkdir -p $TMPDIR/$DB

# schema
su -l postgres -c "pg_dump -Cs -F c -Z 9 -S postgresql $DB" \
> $TMPDIR/$DB/schema.pg
rm -rf $TMPDIR/$DB/schema.pg.gz
gzip $TMPDIR/$DB/schema.pg

# data
su -l postgres -c "pg_dump -bd -F c -Z 9 -S postgresql $DB" \
> $TMPDIR/$DB/data.pg
rm -rf $TMPDIR/$DB/data.pg.gz
gzip $TMPDIR/$DB/data.pg

# simple
su -l postgres -c "pg_dump $DB" \
> $TMPDIR/$DB/simple.sql
rm -rf $TMPDIR/$DB/simple.sql.gz
gzip $TMPDIR/$DB/simple.sql
done

# dump all globals (users/groups)
su -l postgres -c "pg_dumpall -g" \
> $TMPDIR/globals.sql

-----Original Message-----
From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
Sent: Tuesday, March 09, 2004 10:51 AM
To: Jeff Boes
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: [ADMIN] Transaction logs gone, how to restart?

Jeff Boes <jboes(at)nexcerpt(dot)com> writes:
> We backed up our test server yesterday (Pg 7.4.1) as the first step in

> switching from Red Hat 7 to Whitebox. However, we failed to back up
> the transaction and commit logs. Now that the OS and database are back

> to where they were, we get this message on attempting to restart:

> LOG: could not open file
> "/usr/local/pgsql/data/pg_xlog/00000041000000EE" (log file 65, segment

> 238): No such file or directory

Urgh. If you shut down the postmaster cleanly before backing up, then
you don't really need pg_xlog --- running pg_resetxlog will get you out
of the above problem. However, if you did not save pg_clog then I fear
you are well and truly screwed.

How long ago was your last complete (database-wide) VACUUM? If it was
just before shutdown then you may be able to achieve some semblance of a
consistent database, but if it was awhile ago then you do not have a
database but just a pile of bits :-(

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Browse pgsql-admin by date

  From Date Subject
Next Message Louie Kwan 2004-03-09 16:14:39 Colors in vim
Previous Message Tom Lane 2004-03-09 15:51:06 Re: Transaction logs gone, how to restart?