Re: Updated backup APIs for non-exclusive backups

From: David Steele <david(at)pgmasters(dot)net>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Marco Nenciarini <marco(dot)nenciarini(at)2ndquadrant(dot)it>, Noah Misch <noah(at)leadboat(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: Updated backup APIs for non-exclusive backups
Date: 2018-12-12 13:01:18
Message-ID: c989ff62-95fb-e7d8-1c95-054fe0d32d03@pgmasters.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12/12/18 12:58 AM, Laurenz Albe wrote:
> On Tue, 2018-12-11 at 23:43 -0500, David Steele wrote:
>>>>> [about managing backups from pre- and post-file-system-backup scrips]
>>> I have come up with some sample code here:
>>> https://github.com/cybertec-postgresql/safe-backup
>>>
>>> This just uses bash and psql.
>>> Does that look reasonably safe?
>>>
>>> It's probably too big to be introduced into the documentation, but maybe
>>> we could add it to the Wiki.
>>
>> My bash-fu is not all that great, but it seems to me you could do this
>> all in one script and forgo the table entirely. Just do the file copy
>> at about line 60 in pgpre.sh.
>>
>> It does look workable to me, just wonder if it could be simpler.
>
> Thanks for having a look. Yes, it looks appallingly complicated.
>
> Sure, if I knew there was a file to write, and I knew where to write
> it, I could do it in the "pre" script.

Good point!

> But since I have no idea how the
> actual backup is performed and how the "backup_label" file is going to
> be saved, I thought it best to return the information to the caller and
> persist it somewhere, and only the "post" script can actually return the
> information.

Perhaps it could be done in a bash file that is included into the user's
script, rather than doing pre/post.

So, they would have start and stop backup methods they could call that
would manage the psql process in the background. In that case it should
be possible to eliminate the table.

I do see the table as a weak spot. It appears to work, but does add a
lot of complexity. Limiting to one backup at a time can be a feature,
though. In pgBackRest we use advisory locks to enforce this.

--
-David
david(at)pgmasters(dot)net

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey Borodin 2018-12-12 13:08:04 Re: Connections hang indefinitely while taking a gin index's LWLock buffer_content lock
Previous Message David Steele 2018-12-12 12:54:05 Re: Add timeline to partial WAL segments