Re: Restoring a database from a file system snapshot

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: William Garrison <postgres(at)mobydisk(dot)com>
Cc: Postgres General List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Restoring a database from a file system snapshot
Date: 2008-08-27 20:54:09
Message-ID: 20080827205409.GG4071@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

William Garrison wrote:

> 1) I have a file system backup that *IS* consistent. So I should not
> need any WAL files at all right?

It is consistent only if it was taken when the postmaster was down.

> **update**
> I got it working. Here's how
> 1) I have a file system snapshot. No WAL files were required.
> 2) Using my example from my first post, here is how I manually
> rearranged the files so that postgres saw the new database.
> - Create a new tablesspace on the new server
> - Create a new database on the new server, using that tablespace. I
> placed it into X:\NewDatabase\
> - PostgreSQL will create a folder X:\NewDatabase\98765. Notice that the
> number postgres created is NOT the same as your old one.
> - Stop PostgreSQL
> - Move your files from Z:\MyDatabase\1234567 into the X:\NewDatabase folder
> - Delete the 98765 directory.
> - Start PostgreSql

This does not really work, because you're missing the necessay pg_clog
files. You can make it sort-of-work by doing a VACUUM FREEZE and a
CHECKPOINT on the database before taking the snapshot. However, you'd
still be missing the entries in shared catalogs. The only one you've
recreated is the one on pg_database, but there are more.

> --- The referenced article is lacking an explanation for how postgres
> arranges the files and how the symlinks for the tablespaces are made.
> Without that knowledge, attaching to another database is guesswork.

Attaching to another database is not supported at all.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2008-08-27 22:04:50 Re: Do I have a corrupted database?
Previous Message Tino Wildenhain 2008-08-27 20:42:18 Re: Dumping/Restoring with constraints?