Thread: [GENERAL] pg_start/stop_backup naming conventions

[GENERAL] pg_start/stop_backup naming conventions

From
mj0nes
Date:
Hi,

I'm just starting out on a rolling backup strategy and the naming convention
has thrown me slightly for the WAL and "backup_label" files.

What I want to do is pair up the backup label files with the associated tar
ball of the data directory. When I first ran pg_start_backup('label'), I
naively thought a file would be created named label. Maybe not that naive
considering the documentation:

/pg_start_backup creates a backup label file, *called backup_label*, in the
cluster directory with information about your backup, including the start
time and label string./

I've since of course learnt that the file created is in some way related to
the WAL files referenced in the return from pg_start_backup - but it's not
really a transparent mapping from e.g. 1/F3000028 to
0000000100000001000000F3.00000028.backup. I appreciate the are telltale
similarities between the two, but to be sure of matching programmatically
I'd really rather know the naming convention. Why are there two fewer zeros
preceding the 28 in the value returned from pg_start_backup? What's the 28?
Why the "1/"? Can this pattern always be relied upon?

It might be easier if the backup file actually appeared locally, as the
documentation suggests, that way I could name the tar file accordingly. But
it doesn't, it gets shipped off to the remote server in the same way as WAL
files via the archive setup.

The documentation could be a bit more explicit around this.

Thanks for any pointers.



--
Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] pg_start/stop_backup naming conventions

From
"David G. Johnston"
Date:
On Mon, Oct 9, 2017 at 9:33 AM, mj0nes <matthew.jones@ramtech.co.uk> wrote:
Hi,

I'm just starting out on a rolling backup strategy and the naming convention
has thrown me slightly for the WAL and "backup_label" files.
 ​[...]​
Thanks for any pointers.

​I'll give out the standard advice - don't roll-your-own backup solution - investigate and choose one the many supported and maintained backup solutions (most are open source) that are already available.  This kind of detail, then, should become unimportant to you.

David J.

Re: [GENERAL] pg_start/stop_backup naming conventions

From
Stephen Frost
Date:
Greetings,

* mj0nes (matthew.jones@ramtech.co.uk) wrote:
> I'm just starting out on a rolling backup strategy and the naming convention
> has thrown me slightly for the WAL and "backup_label" files.
>
> What I want to do is pair up the backup label files with the associated tar
> ball of the data directory. When I first ran pg_start_backup('label'), I
> naively thought a file would be created named label. Maybe not that naive
> considering the documentation:
>
> /pg_start_backup creates a backup label file, *called backup_label*, in the
> cluster directory with information about your backup, including the start
> time and label string./

That's an interesting point, but not particularly relevent any more as
we've deprecated that approach to doing backups now because of issues
with the backup_label file and what happens if the system is restarted
during a backup.

> Thanks for any pointers.

Frankly, developing your own backup software for PG isn't trivial and
isn't something I'd recommend.  There's a number of good tools out there
which have been developed over years to work well to specifically
address PG backups and to do things correctly (such as making sure WAL
archiving is working and that WAL files are sync'd to disk before
telling PG that it's been copied).

Thanks!

Stephen