X-Original-To: pgsql-admin@postgresql.org Received: from biscay.ymogen.com (biscay.ymogen.net [194.164.6.62]) by postgresql.org (Postfix) with SMTP id C8D1B474E44 for ; Fri, 14 Mar 2003 11:48:42 -0500 (EST) Received: (qmail 7406 invoked from network); 14 Mar 2003 16:28:46 -0000 Received: from unknown (HELO solent) (mailuser@213.165.136.12) by 0 with SMTP; 14 Mar 2003 16:28:46 -0000 From: "Matt Clark" To: Subject: Re: LVM snapshots Date: Fri, 14 Mar 2003 16:28:26 -0000 Message-ID: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_04BA_01C2EA46.BD3A4C80" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: <996802F75C3CD411B424001083FA445B534D51@CET_PONXX_FP001> X-Archive-Number: 200303/226 X-Sequence-Number: 7866 This is a multi-part message in MIME format. ------=_NextPart_000_04BA_01C2EA46.BD3A4C80 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit RE: [ADMIN] LVM snapshotsThat's what I thought. The docs are a bit coy on this point. Section 9.2 says "The database server must be shut down in order to get a usable backup. Half-way measures such as disallowing all connections will not work as there is always some buffering going on. For this reason it is also not advisable to trust file systems that claim to support "consistent snapshots". But LVM calls fsync_dev_lockfs() before the snapshot is taken, and unlockfs() afterwards, so there are guaranteed to be no dirty buffers lying around - the tradeoff is that calls to write() will block until all the buffers are written to disk and the snapshot set up, but that shouldn't take long. BTW I see I was wrong in my original question about tar &c being unsuitable, I don't know where I got that idea from, so taking a snapshot every 10 mins and doing an rsync should be pretty cheap in terms of write IO, though it will increase the CPU demands above those for a simple copy, and doesn't save anything on read IO. Is there some other interpretation of Section 9.2 of the docs that means the reasoning on fsync_dev_lockfs above is wrong or inadequate? -----Original Message----- From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Trewern, Ben Sent: 14 March 2003 16:03 To: 'David F. Skoll'; pgsql-admin@postgresql.org Subject: Re: [ADMIN] LVM snapshots I don't see why not. What happens if your server crashes? Hopefully what's on the disk is consistent (one of the good reasons to use Postgresql). BTW I've heard of someone else doing something like this and using rsync. He was running it just before the snapshot and then again against the snapshot. This should then reduce the amount of time the actual snapshot needs to be kept. Regards, Ben -----Original Message----- From: David F. Skoll [mailto:dfs@roaringpenguin.com] Sent: 14 March 2003 15:52 To: pgsql-admin@postgresql.org Subject: Re: [ADMIN] LVM snapshots On Fri, 14 Mar 2003, Matt Clark wrote: > Has anyone tried taking an LVM snapshot of a running DB? I don't think there's a guarantee that a snapshot of the file system corresponds to a consistent database, even if the snapshot corresponds to a single point-in-time. -- David. ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org **************************************************************************** * This email and any attachments transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender and do not store, copy or disclose the content to any other person. It is the responsibility of the recipient to ensure that opening this message and/or any of its attachments will not adversely affect its systems. No responsibility is accepted by the Company. **************************************************************************** * ------=_NextPart_000_04BA_01C2EA46.BD3A4C80 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: [ADMIN] LVM snapshots
That's what I thought.  The docs are a bit coy on this point.=  =20 Section 9.2 says "The database server must be shut down in order to get a usable back= up.=20 Half-way measures such as disallowing all connections will not work as ther= e is=20 always some buffering going on. For this reason it is also not advisable to= =20 trust file systems that claim to support "consistent=20 snapshots".
 
But=20 LVM calls fsync_dev_lockfs() before the snapshot is taken, and unlockfs()= =20 afterwards, so there are guaranteed to be no dirty buffers lying around - t= he=20 tradeoff is that calls to write() will block until all the buffers are writ= ten=20 to disk and the snapshot set up, but that shouldn't take=20 long.
 
BTW I=20 see I was wrong in my original question about tar &c being unsuitable, = I=20 don't know where I got that idea from, so taking a snapshot every 10 mins a= nd=20 doing an rsync should be pretty cheap in terms of write IO, though it will= =20 increase the CPU demands above those for a simple copy, and doesn't save=20 anything on read IO.
 
Is=20 there some other interpretation of Section 9.2 of the docs that means the= =20 reasoning on fsync_dev_lockfs above is wrong or inadequate?
 
 
-----Original Message-----
From:=20 pgsql-admin-owner@postgresql.org=20 [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Trewern,=20 Ben
Sent: 14 March 2003 16:03
To: 'David F. Skoll';= =20 pgsql-admin@postgresql.org
Subject: Re: [ADMIN] LVM=20 snapshots

I don't see why not.  What happens if your server= =20 crashes?  Hopefully what's on the disk is consistent (one of the goo= d=20 reasons to use Postgresql).

BTW I've heard of someone else doing something like thi= s and=20 using rsync.  He was running it just before the snapshot and then ag= ain=20 against the snapshot.  This should then reduce the amount of time th= e=20 actual snapshot needs to be kept.

Regards,

Ben

-----Original Message-----
Fr= om: David=20 F. Skoll [mailto:dfs@roaringpenguin.com]= =20
Sent: 14 March 2003 15:52
To:=20 pgsql-admin@postgresql.org
Subject: Re: [ADMIN]= LVM=20 snapshots

On Fri, 14 Mar 2003, Matt Clark wrote:

> Has anyone tried taking an LVM snapshot of a runni= ng=20 DB?

I don't think there's a guarantee that a snapshot of th= e file=20 system
corresponds to a consistent database, ev= en if=20 the snapshot corresponds
to a single=20 point-in-time.

--
David.

---------------------------(end of=20 broadcast)---------------------------
TIP 1: su= bscribe=20 and unsubscribe commands go to majordomo@postgresql.org

=

********************************************************= *********************
This=20 email and any attachments transmitted with it are confidential
and int= ended=20 solely for the use of the individual or entity to whom
they are addres= sed.=20 If you have received this email in error please
notify the sender and = do=20 not store, copy or disclose the content
to any other person.

It= is=20 the responsibility of the recipient to ensure that opening this
messag= e=20 and/or any of its attachments will not adversely affect
its systems. N= o=20 responsibility is accepted by the=20 Company.
*************************************************************= ****************
------=_NextPart_000_04BA_01C2EA46.BD3A4C80--