Обсуждение: Transaction logs gone, how to restart?

Поиск
Список
Период
Сортировка

Transaction logs gone, how to restart?

От
Jeff Boes
Дата:
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

(There are other problems that we are still working to correct, but this is the
one that I don't understand.)

--
~~~~~~~~~~~~~~~~| Genius may have its limitations, but stupidity is not
Jeff Boes       | thus handicapped.
jboes@qtm.net   |        --Elbert Hubbard (1856-1915), American author



Re: Transaction logs gone, how to restart?

От
Tom Lane
Дата:
Jeff Boes <jboes@nexcerpt.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

Re: Transaction logs gone, how to restart?

От
"Anjan Dave"
Дата:
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@sss.pgh.pa.us]
Sent: Tuesday, March 09, 2004 10:51 AM
To: Jeff Boes
Cc: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Transaction logs gone, how to restart?


Jeff Boes <jboes@nexcerpt.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