pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chris Jewell <c.jewell@lancaster.ac.uk>
To: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: Re: Backup - filesystem snapshots
Date: Thu, 19 Jan 2006 00:04:10 +0000
Message-ID: <43CED77A.5080800@lancaster.ac.uk> (raw)
In-Reply-To: <43CEA0D8.8060901@lancaster.ac.uk>
References: <43CEA0D8.8060901@lancaster.ac.uk>

Hi,

Thanks for all the suggestions.  One thing I had done, before we got the
backup server, was to write a Perl script that parsed the log file
looking for SQL commands that altered data (eg CREATE, ALTER, UPDATE
etc).  I had, of course, set the client_min_messages = notice.  Since I
had confined my users to their own schemas, the script simply queries
the database for the user list, checks to see if they have altered data,
and does a pg_dump on their schema if they have.  This actually was
working reasonably well, but required a good deal of monitoring.  I will
go back to using this system if the WAL logging seems clunky.  However,
the disadvantage is that you need to confine users to their own schemas.
 Also, the script was written pre-roles.  I'd probably have to modify it
nowadays!

If anyone is interested, I can post the Perl script.

Chris

PS The backups are really only done to protect users from themselves
since we're running a RAID mirroring system - hence the PITR for a given
user (as opposed to for the whole database).

Chris Jewell wrote:
> Hi,
> 
> I'm trying to implement a backup strategy for a research database in
> order to prevent again users accidentally dropping their data.
> 
> My preferred method would be to create regular snapshots of the data
> directory, and then send this to the backup server using rsync, with
> hard-linking backup rotation.  The backup data directories could then be
> examined using a postmaster running on the backup server to extract any
> accidentally deleted tables.
> 
> My problem is how to do these snapshots: is it enough to create a hard
> link to the directory, or is there still a risk that a currently running
> transaction might introduce inconsistencies?  I guess I could use the
> pg_ctl -m 'Smart' command to stop the database after all clients have
> disconnected, but I sometimes have users leaving their clients connected
> all night.  Is there any other way to suspend the postmaster such that
> it finishes its current transaction and queues any other transactions
> while the snapshot is taking place?  Any other ideas of how I can create
> such snapshots?
> 
> Thanks,
> 
> Chris

-- 
Chris Jewell, BSc(Hons), BVSc, MRCVS
Dept of Maths and Statistics
Fylde College
Lancaster University
Lancaster
Lancs
LA1 4YF



view thread (4+ messages)

Message-ID: <43CED77A.5080800@lancaster.ac.uk>
Permalink:  ../43CED77A.5080800@lancaster.ac.uk/
Also on:    postgresql.org/message-id/43CED77A.5080800@lancaster.ac.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: c.jewell@lancaster.ac.uk
  Subject: Re: Backup - filesystem snapshots
  In-Reply-To: <43CED77A.5080800@lancaster.ac.uk>
  References: <43CEA0D8.8060901@lancaster.ac.uk> <43CED77A.5080800@lancaster.ac.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox