Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hXooP-0007s7-U8 for pgsql-general@arkaria.postgresql.org; Mon, 03 Jun 2019 15:23:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hXooO-0005Nx-0m for pgsql-general@arkaria.postgresql.org; Mon, 03 Jun 2019 15:23:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hXooN-0005JS-KR for pgsql-general@lists.postgresql.org; Mon, 03 Jun 2019 15:23:47 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hXooK-0003UF-Ga for pgsql-general@postgresql.org; Mon, 03 Jun 2019 15:23:46 +0000 Received: by mail-wm1-x333.google.com with SMTP id g135so8455478wme.4 for ; Mon, 03 Jun 2019 08:23:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ocado.com; s=google; h=reply-to:subject:to:references:from:organization:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=2plDz+YWeEoSqLX4uP3ks994evFifa6O5rANv/NexiA=; b=aMgjH4kODJ2SvHH64ta6L6APzrmNZfut5tugorj2MyKMvoVomBsM4g3l6vLTARHNY0 hNRUgt7U3eKFGMspcoVycyDruekykHBynuQn92nR5T5E90wgCdy2+QIj9qNC9fiEvxS1 RiQ11jLWD0x5c2zZABsgA5+7bSL3XZcxwW02/aescxzL6IbcAW05WPIvwp+64Yak1Ds+ fppdcZ3NIqsPrvfNIqWY3KQkPfSmUuXwEshJSf3ll3XG6WUs6Zkxt9eyVtYMLgYPfPGp oU13yTykGCOVQY6R4RDqGh7tzLkuL5v8UjE2KpPvrjOVgNZEu8OqtiJnU9sNV6nzAii+ CiJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=2plDz+YWeEoSqLX4uP3ks994evFifa6O5rANv/NexiA=; b=htEz6tftsnoD7mrPf4DwnOtdLb3T6UPhysXA/oSMiyDUMFxjQsQDXILoqXMIYQIQj7 VTyPTsVdQBWfyJtAYYLfRpT6u3pigu+ltwxeiI8/c4ZXsYuddMBnyeS7BKO8m0CHKAgU grxHf59WlCHHKbGi5p+ezXNEYKjvZqDTUe13O6ps5yYkEuZPjlIpUWZJuZ3i5HIrepwm n2T0N7TarpR0GPHZ0Xz2ukQv3jv7KVo9C6McSEeIMS1KV/mguIppv3dOooTZqBb8ZxJB 1/V8OU9wiof8liaHrfYsbrhcnF4TOJ+9VOzvR9L1aBM5N9eBxO0QfxJDVajCOzOOf3Dv h9kA== X-Gm-Message-State: APjAAAWiFNwxBLxuLuU9DEJIkDUmFiyG9VqGfQjN8RltnjurYixMgIeE 6CiWtUBuoHdCCIwvSrKlDycc6uNtKXDqQ2GBIC79Kxl26t6v1BHfrpo+bIGf6/mjUQ5goL+2sAo +LYwO6yofaN8t98nDZ0QCKw== X-Google-Smtp-Source: APXvYqzm+hl92GSeQjmE9narHetY+ZGlH7Cid9/2QPCrfztdkQJcak5Emmvx95UuIjQz2W4pHl3wuw== X-Received: by 2002:a1c:c70f:: with SMTP id x15mr6864312wmf.59.1559575422532; Mon, 03 Jun 2019 08:23:42 -0700 (PDT) Received: from [10.62.14.33] ([91.206.0.63]) by smtp.gmail.com with ESMTPSA id c18sm15421442wrm.7.2019.06.03.08.23.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jun 2019 08:23:41 -0700 (PDT) Reply-To: f.venchiarutti@ocado.com Subject: Re: Postgresql backup via LVM snapshot? To: "Lu, Dan" , "pgsql-general@postgresql.org" References: <5d75bcc3e64f4b7b9a0e0cf2d66f0397@msx.bala.susq.com> From: Fabio Ugo Venchiarutti Organization: Ocado Technology Message-ID: Date: Mon, 3 Jun 2019 16:23:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <5d75bcc3e64f4b7b9a0e0cf2d66f0397@msx.bala.susq.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Are you trying to fit the postgres backups in some overarching LVM-based=20 backup scheme you're already running or is this from scratch? With the possible exception of rsync's deltas & hardlink trickeries=20 between full backups, I personally don't see a point in using a=20 block/file-level copy for physical backups of Postgres clusters (unless=20 you're keeping the snapshot around as the "thin backup" but that would=20 put the backup in the same volume group as the live data; meh). pg_basebackup (or more specifically the underlying replication protocol=20 command BASE_BACKUP), precisely wraps up all that you're trying to=20 accomplish here; it is perfectly aware of the internal state of=20 operations and guarantees operations=20 synchronisation/correctness/completeness. It roughly boils down to (with minor variations between types of=20 physical backups): - dropping a checkpoint and wait for it to complete, or wait for the=20 next one to roll around (that will be the starting point of WAL recovery=20 when you restore) - remember the WAL location of that checkpoint - copy the data files "as is" without worrying about torn/corrupt pages=20 due to changes. They will be overwritten with the amended version during=20 WAL recovery - optionally put away a copy of all the transaction logs that were=20 generated between the checkpoint and the end of the copy if you're not=20 already performing WAL archival (or if you simply want your backup to be=20 self-contained and recoverable without accessing the WAL archive). The database will look to have crashed when you initially restore it=20 (same as with an any form of snapshotting including LVM) and will have=20 to go through WAL recovery anyway: the earliest version of the DB to=20 which you can safely restore is the one at the moment the copy ended, so=20 the benefits of the atomic low-level snapshot are negated. By using the old exclusive start/stop_backup() & action synchronisation=20 yourself you're just making it more manual and error prone. Regards F On 30/05/2019 20:38, Lu, Dan wrote: > Hello, >=20 > Would you be able to confirm for me that a host level LVM snapshot of=20 > the PGDATA directory along with PG_WAL directly via LVM backup is=20 > supported way of backup and restore? >=20 > I read about this here:=20 > https://dba.stackexchange.com/questions/145361/backup-standby-database-us= ing-lvm-snapshot >=20 >=20 > Is it as simple as: >=20 > =E8SELECT pg_start_backup('Begin LVM Backup At xyz'); >=20 > =E8Do LVM backup from o/s end to backup PGDATA/PG_WAL >=20 > =E8SELECT pg_stop_backup(); >=20 > Thanks. >=20 > Dan >=20 >=20 > ------------------------------------------------------------------------ >=20 > IMPORTANT: The information contained in this email and/or its=20 > attachments is confidential. If you are not the intended recipient,=20 > please notify the sender immediately by reply and immediately delete=20 > this message and all its attachments. Any review, use, reproduction,=20 > disclosure or dissemination of this message or any attachment by an=20 > unintended recipient is strictly prohibited. Neither this message nor=20 > any attachment is intended as or should be construed as an offer,=20 > solicitation or recommendation to buy or sell any security or other=20 > financial instrument. Neither the sender, his or her employer nor any of= =20 > their respective affiliates makes any warranties as to the completeness= =20 > or accuracy of any of the information contained herein or that this=20 > message or any of its attachments is free of viruses. --=20 Regards Fabio Ugo Venchiarutti OSPCFC Network Engineering Dpt. Ocado Technology --=20 Notice: =A0This email is confidential and may contain copyright material of= =20 members of the Ocado Group. Opinions and views expressed in this message=20 may not necessarily reflect the opinions and views of the members of the=20 Ocado Group.=A0 =A0 If you are not the intended recipient, please notify us=20 immediately and delete all copies of this message. Please note that it is= =20 your responsibility to scan this message for viruses.=A0 =A0 Fetch and Sizzle=20 are trading names of Speciality Stores Limited and Fabled is a trading name= =20 of Marie Claire Beauty Limited, both members of the Ocado Group. =A0 References to the =93Ocado Group=94 are to Ocado Group plc (registered in= =20 England and Wales with number 7098618) and its subsidiary undertakings (as= =20 that expression is defined in the Companies Act 2006) from time to time. = =A0 The registered office of Ocado Group plc is=A0Buildings One & Two, Trident= =20 Place, Mosquito Way, Hatfield, Hertfordshire, AL10 9UL.