Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YJovO-000085-6y for pgsql-admin@arkaria.postgresql.org; Fri, 06 Feb 2015 19:50:46 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YJovN-0003mn-Ll for pgsql-admin@arkaria.postgresql.org; Fri, 06 Feb 2015 19:50:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YJovM-0003mb-Qj for pgsql-admin@postgresql.org; Fri, 06 Feb 2015 19:50:44 +0000 Received: from mail-yk0-x233.google.com ([2607:f8b0:4002:c07::233]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YJovH-0006gV-SH for pgsql-admin@postgresql.org; Fri, 06 Feb 2015 19:50:43 +0000 Received: by mail-yk0-f179.google.com with SMTP id 142so6808064ykq.10 for ; Fri, 06 Feb 2015 11:50:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; bh=uzbkvLAcJj7nE1IfRBg4GksxJ6Bacd2ifuxjdekqFiI=; b=bUw0Eaq0qabKv+8BeavUVMo2Z4Q0594Pi5Ng5NNF7+S5WkBY3mwute2Zb0s3rqqIrG IDMkypH6sYcEyljSU9sKBiagbSSyUEAj8ClgXC/fBuT1lyS0spSSTlyEYWvhYZubq0mH 8l2hwqlOBs7LzalsCy79J5f+OVPzLk+gEwRI7Jk7BA31Vks5FIAttEYc9DDUbESbyWP9 bIKnTFOtahauJTE+ZprfGFEXCPaIORU8AD5FD3KjvID27Wd75pUkOv8fhLC8vYp5WS9g DvnroqKNF24dYz7RyiSjDh2s/04BKVe+bXbktpfAwPtGo+o+XH8kWoEGdbAFO7HuzMGX 8Txg== X-Received: by 10.236.209.37 with SMTP id r25mr2011974yho.59.1423252237994; Fri, 06 Feb 2015 11:50:37 -0800 (PST) Received: from [192.168.254.3] (h77.89.102.166.static.ip.windstream.net. [166.102.89.77]) by mx.google.com with ESMTPSA id n22sm1726167yho.1.2015.02.06.11.50.37 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Feb 2015 11:50:37 -0800 (PST) Message-ID: <54D51B08.5050901@gmail.com> Date: Fri, 06 Feb 2015 14:50:32 -0500 From: John Scalia User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Matheus de Oliveira CC: "pgsql-admin@postgresql.org" Subject: Re: Hourly backup using pg_basebackup References: <54D50D9B.1090905@gmail.com> In-Reply-To: Content-Type: multipart/alternative; boundary="------------010409080106080402030909" X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org This is a multi-part message in MIME format. --------------010409080106080402030909 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 2/6/2015 2:25 PM, Matheus de Oliveira wrote: > > On Fri, Feb 6, 2015 at 4:53 PM, John Scalia > wrote: > > We have a python script called by cron on an hourly basis to back up our production database. Currently, the script invokes pg_dump and takes more than hour to complete. > Hence the script looks to see if it's already running and exits if so. I want to change the script so it uses pg_basebackup instead since that's so much faster. > > > Have you considered using incremental backup (continuous archiving) instead of a such small backup window? > > See [1] > > My problem is, however, that while I'd like to just have it build a tarball, maybe compressed, I can't use a "-X s" option for the wal segments. I think I understand why I > can't use the streaming option with a "-Ft" specified. I'm just concerned about the docs saying that the backup may have problems with fetch as a wal segment may have > expired. Manually testing is showing that the Db needs about 11 minutes to backup with pg_basebackup, and our wal_keep_segments setting is 6. This said, an hour's worth of > wal segments should be available, but the six that were there at the beginning of the backup are not the same six there at the end. I don't think this is really a problem, > but I'd like to get it confirmed. Wouldn't the backup actually have to take more than hour for this to be an issue? > > > If you use archiving [1], you don't need to worry about saving the segments withing the backup, just let it be done through archive_command. Isn't that an option for you? If > don't, why? > Oh, yes, I did fail to mention that the system where I'm trying this is the primary in a streaming replication cluster with (2) hot standby servers. I've mentioned without much traction, that we don't really even need a backup with 3 servers ready to do the work without delays. Like I said in the last post, it's all political. > > [1] http://www.postgresql.org/docs/current/static/continuous-archiving.html > > Best regards, > -- > Matheus de Oliveira > Analista de Banco de Dados > Dextra Sistemas - MPS.Br nível F! > www.dextra.com.br/postgres > --------------010409080106080402030909 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 2/6/2015 2:25 PM, Matheus de Oliveira wrote:

On Fri, Feb 6, 2015 at 4:53 PM, John Scalia <jayknowsunix@gmail.com> wrote:
We have a python script called by cron on an hourly basis to back up our production database. Currently, the script invokes pg_dump and takes more than hour to complete. Hence the script looks to see if it's already running and exits if so. I want to change the script so it uses pg_basebackup instead since that's so much faster.


Have you considered using incremental backup (continuous archiving) instead of a such small backup window?

See [1]

My problem is, however, that while I'd like to just have it build a tarball, maybe compressed,  I can't use a "-X s" option for the wal segments. I think I understand why I can't use the streaming option with a "-Ft" specified. I'm just concerned about the docs saying that the backup may have problems with fetch as a wal segment may have expired. Manually testing is showing that the Db needs about 11 minutes to backup with pg_basebackup, and our wal_keep_segments setting is 6.  This said, an hour's worth of wal segments should be available, but the six that were there at the beginning of the backup are not the same six there at the end. I don't think this is really a problem, but I'd like to get it confirmed. Wouldn't the backup actually have to take more than hour for this to be an issue?

If you use archiving [1], you don't need to worry about saving the segments withing the backup, just let it be done through archive_command. Isn't that an option for you? If don't, why?

Oh, yes, I did fail to mention that the system where I'm trying this is the primary in a streaming replication cluster with (2) hot standby servers. I've mentioned without much traction, that we don't really even need a backup with 3 servers ready to do the work without delays. Like I said in the last post, it's all political.

[1] http://www.postgresql.org/docs/current/static/continuous-archiving.html

Best regards,
--
Matheus de Oliveira
Analista de Banco de Dados
Dextra Sistemas - MPS.Br nível F!
www.dextra.com.br/postgres


--------------010409080106080402030909--