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 1hXnfh-0000jj-6z for pgsql-general@arkaria.postgresql.org; Mon, 03 Jun 2019 14:10:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hXnfe-00063A-VS for pgsql-general@arkaria.postgresql.org; Mon, 03 Jun 2019 14:10:42 +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 1hXnfe-00062m-G1 for pgsql-general@lists.postgresql.org; Mon, 03 Jun 2019 14:10:42 +0000 Received: from mail-qk1-x744.google.com ([2607:f8b0:4864:20::744]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hXnfZ-0001qU-Sd for pgsql-general@postgresql.org; Mon, 03 Jun 2019 14:10:40 +0000 Received: by mail-qk1-x744.google.com with SMTP id a132so446013qkb.13 for ; Mon, 03 Jun 2019 07:10:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brunol-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=5KgSKL9iqKEnwf/itn2LWAXrX/B7RPj3DXxuhrfts14=; b=gsQTmlquy8AcOAcvKWxuFKVF37vxnx6WSb8sWfxbcyZHqnBXYGKUdEbDGOxEbJ01zK doviT+Zk6gY8U3gQZTlnJdiWJh69spsFpjBszBAo7fsJonBN3EWWVbTxXmXAvwl7vhzQ vnVjZlJoBYTZO5gbYHLef+bMHnM/WL50pM2Mw/4l+J+QOvQiiRCS3r6E70MJAFyGOWas rDDTAEs7SuPqYXs97Hvz4r9dzgyHFvd7+0+v/VpRv4Mh6zEVSAG/6mgHhiyvvcp6ekPQ U4/AM9z9UnMPqCQRWu1M/kZjn5CQteLIAu/13mGcr+/8YlpxC5D5tzi3De9VoAmAdnh9 6TTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=5KgSKL9iqKEnwf/itn2LWAXrX/B7RPj3DXxuhrfts14=; b=KRBeUpNC5Q8s7Z1Ncy+Ne5gKCFaLqaJPhcZUzE9MHKYUpOajL4rTP2+P3sSk0LmxIs hizYHQCky1kbZsqee0eQhqy2y3MbzesAXow0SPR25XxOWDsRMZZ9WvHa80a7XYkMR9NM L4UWtvxxBJGG8nR1LcfBb7xgJhsqB2LhNq0Kp2Dbj1EoTw7aHuuYueZvNdqxRwbeJsuK 0pDHitNpfVx0smGuLtZfdSyzBtlZbH2qZIaIyHbRH+mwoP7DmvMzLRpP2eKV0AU5rCuE Z/2oZqQsAYHHJ1msizB3BEpiL/6wpiKh8/DNYcT8Um0FHYTHrq5vLWn+2DibRtc0tTPF 5Q5A== X-Gm-Message-State: APjAAAXVQ082c7NYY9KewDmySfCZNnUOW+8rIAeZr0EJ/Z0LIUm4y+ze PA9OcnpnjgKze/gA67rP7+IE/UXJDe8= X-Google-Smtp-Source: APXvYqyv7J+a4U+5tcukdgrFDS1OV1XpxqmOItWN0ywUJIuECmgUHNk5yI+USM/4JG4ekrcUfgCXuw== X-Received: by 2002:a37:9a4d:: with SMTP id c74mr22118140qke.123.1559571035117; Mon, 03 Jun 2019 07:10:35 -0700 (PDT) Received: from axiom.brunol.com ([132.203.168.5]) by smtp.gmail.com with ESMTPSA id i17sm7703315qkl.71.2019.06.03.07.10.34 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jun 2019 07:10:34 -0700 (PDT) Subject: Re: Postgresql backup via LVM snapshot? To: "Lu, Dan" , "pgsql-general@postgresql.org" References: <5d75bcc3e64f4b7b9a0e0cf2d66f0397@msx.bala.susq.com> From: Bruno Lavoie Message-ID: <234b2de0-e579-b01f-7d41-7414f5bb3408@brunol.com> Date: Mon, 3 Jun 2019 10:10:33 -0400 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: multipart/alternative; boundary="------------9F3809C925E8D93DAC6D4DC0" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------9F3809C925E8D93DAC6D4DC0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Hi, I suggest you to take a serious look at ZFS: https://zfsonlinux.org/ With simply a few commands, mainly zpool and zfs, you can manage everything in one stack: * encryption: new in 0.8.0 * compression: with lz4, it's very lightweitgh with practically no impact on cpu * snapshots: it uses copy on write, no messing with complicated lvm snapshot management. Instantaneous snapshots. And as a bonus you can easily copy snapshots between hosts. * arc, l2arc: better cache management than page cache on linux, not simply an LRU * it handles mount point for you I don't see any problems to you procedure, just keep your generated WALs during the backup procedure (pg-start-backup to pg-stop-backup). Generally, you'll want to separate WAL directory from the data one. Because I can't cover more in a simple email (tuning, parameters, disable pg full page writes, disable pg page checksuming, etc.), here are good resources: * https://www.2ndquadrant.com/en/blog/pg-phriday-postgres-zfs/ * https://www.slideshare.net/SeanChittenden/postgresql-zfs-best-practices * https://www.slideshare.net/SeanChittenden/postgres-on-zfs-lightning-talk * From Oracle for Oracle, but it can helps: o https://docs.oracle.com/cd/E36784_01/html/E36845/chapterzfs-db2.html o https://docs.oracle.com/cd/E53394_01/html/E54818/chapterzfs-1.html#scrolltoc o https://www.oracle.com/technetwork/server-storage/solaris10/config-solaris-zfs-wp-167894.pdf Maybe someone else can share experience with PG + ZFS ? Hope that helps Bruno Lavoie On 2019-05-30 3:38 p.m., Lu, Dan wrote: > > Hello, > > Would you be able to confirm for me that a host level LVM snapshot of > the PGDATA directory along with PG_WAL directly via LVM backup is > supported way of backup and restore? > > I read about this here: > https://dba.stackexchange.com/questions/145361/backup-standby-database-using-lvm-snapshot > > > Is it as simple as: > > èSELECT pg_start_backup('Begin LVM Backup At xyz'); > > èDo LVM backup from o/s end to backup PGDATA/PG_WAL > > èSELECT pg_stop_backup(); > > Thanks. > > Dan > > > ------------------------------------------------------------------------ > > IMPORTANT: The information contained in this email and/or its > attachments is confidential. If you are not the intended recipient, > please notify the sender immediately by reply and immediately delete > this message and all its attachments. Any review, use, reproduction, > disclosure or dissemination of this message or any attachment by an > unintended recipient is strictly prohibited. Neither this message nor > any attachment is intended as or should be construed as an offer, > solicitation or recommendation to buy or sell any security or other > financial instrument. Neither the sender, his or her employer nor any > of their respective affiliates makes any warranties as to the > completeness or accuracy of any of the information contained herein or > that this message or any of its attachments is free of viruses. --------------9F3809C925E8D93DAC6D4DC0 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: 8bit

Hi,

I suggest you to take a serious look at ZFS: https://zfsonlinux.org/

With simply a few commands, mainly zpool and zfs, you can manage everything in one stack:

  • encryption: new in 0.8.0
  • compression: with lz4, it's very lightweitgh with practically no impact on cpu
  • snapshots: it uses copy on write, no messing with complicated lvm snapshot management. Instantaneous snapshots. And as a bonus you can easily copy snapshots between hosts.
  • arc, l2arc: better cache management than page cache on linux, not simply an LRU
  • it handles mount point for you

I don't see any problems to you procedure, just keep your generated WALs during the backup procedure (pg-start-backup to pg-stop-backup).

Generally, you'll want to separate WAL directory from the data one.

Because I can't cover more in a simple email (tuning, parameters, disable pg full page writes, disable pg page checksuming, etc.), here are good resources:

Maybe someone else can share experience with PG + ZFS ?

Hope that helps
Bruno Lavoie


On 2019-05-30 3:38 p.m., Lu, Dan wrote:

Hello,

 

Would you be able to confirm for me that a host level LVM snapshot of the PGDATA directory along with PG_WAL directly via LVM backup is supported way of backup and restore?

 

I read about this here: https://dba.stackexchange.com/questions/145361/backup-standby-database-using-lvm-snapshot


Is it as simple as:

 

è SELECT pg_start_backup('Begin LVM Backup At xyz');

è Do LVM backup from o/s end to backup PGDATA/PG_WAL

è SELECT pg_stop_backup();

 

Thanks.

 

Dan

 

 




IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.
--------------9F3809C925E8D93DAC6D4DC0--