Thread: BUG #13642: no backup_label file in PG_DATA after pg_stop_backup();

BUG #13642: no backup_label file in PG_DATA after pg_stop_backup();

From
amir.rohan@mail.com
Date:
The following bug has been logged on the website:

Bug reference:      13642
Logged by:          Amir Rohan
Email address:      amir.rohan@mail.com
PostgreSQL version: 9.4.4
Operating system:   Linux
Description:

SELECT pg_start_backup('backup1');
SELECT pg_stop('backup1');

Doesn't create the `backup_label`  described in the docs (I'm assuming
"cluster directory" means data directory, e.g. $PGDATA):
http://www.postgresql.org/docs/current/static/continuous-archiving.html

They further state:
"The file is critical to the integrity of the backup, should you need to
restore from it."

Are my backups safe or not?

Re: BUG #13642: no backup_label file in PG_DATA after pg_stop_backup();

From
Jeff Janes
Date:
On Fri, Sep 25, 2015 at 8:16 PM, <amir.rohan@mail.com> wrote:

> The following bug has been logged on the website:
>
> Bug reference:      13642
> Logged by:          Amir Rohan
> Email address:      amir.rohan@mail.com
> PostgreSQL version: 9.4.4
> Operating system:   Linux
> Description:
>
> SELECT pg_start_backup('backup1');
> SELECT pg_stop('backup1');
>

The backup_label file should have been created by the first of those, and
removed by the second.  It should have existed in $PGDATA between those
events, but not afterward.  Because it should have been present in $PGDATA
while it was being copied to the backup, that means it should also be
present in your backup.


>
> Doesn't create the `backup_label`  described in the docs (I'm assuming
> "cluster directory" means data directory, e.g. $PGDATA):
> http://www.postgresql.org/docs/current/static/continuous-archiving.html
>
> They further state:
> "The file is critical to the integrity of the backup, should you need to
> restore from it."
>
> Are my backups safe or not?
>
>
Is backup_label present in your *backup*?  That is where it is needed.  It
is not needed in $PGDATA itself.  It is created in $PGDATA simply so that a
copy of it gets included in your backup.

Cheers,

Jeff

Re: BUG #13642: no backup_label file in PG_DATA after pg_stop_backup();

From
Amir Rohan
Date:
On 09/26/2015 06:30 AM, Jeff Janes wrote:
> On Fri, Sep 25, 2015 at 8:16 PM, <amir.rohan@mail.com
> <mailto:amir.rohan@mail.com>> wrote:
>

>     Doesn't create the `backup_label`  described in the docs (I'm assuming
>     "cluster directory" means data directory, e.g. $PGDATA):
>     http://www.postgresql.org/docs/current/static/continuous-archiving.html
>
>
>
> Is backup_label present in your *backup*?  That is where it is needed.
> It is not needed in $PGDATA itself.  It is created in $PGDATA simply so
> that a copy of it gets included in your backup.
>
> Cheers,
>
> Jeff

No. Well, there's a backup file in the archive directory that looks like
it might be /it/ but it's not named `backup_label` (it wouldn't, since
multiple backups need to coexist).

As mentioned earlier, in the backup procedure docs:

| 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. The file is critical to the
| integrity of the backup, should you need to restore from it.

About 8 paragraphs below (where only the brave have stamina to keep
reading):

| It's also worth noting that the pg_start_backup function makes a file
| named backup_label in the database cluster directory, which is
| removed by pg_stop_backup [Ok, I missed that]. This file will
| of course be archived as a part of your backup dump file  <...>

But:
- There's no single "backup dump file" that the file is "part of"
(creating a .tgz isn't part of the workflow described). It's
just a sequence of one or more WAL files.
- It doesn't mentioned that the file gets renamed.

The section previous (on using pg_basebackup not sql commands) talks
about something different called a "backup history file", I guess
a "backup_label" becomes one, one PG knows what xlog the backup ends at.

This isn't great documentation. I'll send a patch to pgsql-docs with
suggested improvements.

Thanks for the help,
Amir

Re: BUG #13642: no backup_label file in PG_DATA after pg_stop_backup();

From
Jeff Janes
Date:
On Fri, Sep 25, 2015 at 11:27 PM, Amir Rohan <amir.rohan@mail.com> wrote:

> On 09/26/2015 06:30 AM, Jeff Janes wrote:
> > On Fri, Sep 25, 2015 at 8:16 PM, <amir.rohan@mail.com
> > <mailto:amir.rohan@mail.com>> wrote:
> >
>
> >     Doesn't create the `backup_label`  described in the docs (I'm
> assuming
> >     "cluster directory" means data directory, e.g. $PGDATA):
> >
> http://www.postgresql.org/docs/current/static/continuous-archiving.html
> >
> >
> >
> > Is backup_label present in your *backup*?  That is where it is needed.
> > It is not needed in $PGDATA itself.  It is created in $PGDATA simply so
> > that a copy of it gets included in your backup.
> >
>
> No. Well, there's a backup file in the archive directory that looks like
> it might be /it/ but it's not named `backup_label` (it wouldn't, since
> multiple backups need to coexist).
>
> As mentioned earlier, in the backup procedure docs:
>
> | 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. The file is critical to the
> | integrity of the backup, should you need to restore from it.
>

The very next item says:

3.  Perform the backup, using any convenient file-system-backup tool such
as tar or cpio (not pg_dump or pg_dumpall).

>
> About 8 paragraphs below (where only the brave have stamina to keep
> reading):
>
> | It's also worth noting that the pg_start_backup function makes a file
> | named backup_label in the database cluster directory, which is
> | removed by pg_stop_backup [Ok, I missed that]. This file will
> | of course be archived as a part of your backup dump file  <...>
>
> But:
> - There's no single "backup dump file" that the file is "part of"
> (creating a .tgz isn't part of the workflow described).


You have to "perform the backup", as quoted above.  You don't have to do it
with tar, and you don't need to name the resulting file ".tgz".  But using
some method or another, you do need to actually take a backup, if your
desire is to have a backup.

Did you create a backup?  If you did not, then no, your backup is not
usable.  If you did, does it include the backup_label file?

Cheers,

Jeff

Re: BUG #13642: no backup_label file in PG_DATA after pg_stop_backup();

From
Amir Rohan
Date:
On 09/27/2015 03:58 AM, Jeff Janes wrote:
> On Fri, Sep 25, 2015 at 11:27 PM, Amir Rohan <amir.rohan@mail.com
> <mailto:amir.rohan@mail.com>> wrote:
>

>     No. Well, there's a backup file in the archive directory that looks like
>     it might be /it/ but it's not named `backup_label` (it wouldn't, since
>     multiple backups need to coexist).
>

> The very next item says:
>
> 3.  Perform the backup, using any convenient file-system-backup tool
> such as tar or cpio (not pg_dump or pg_dumpall).
>

I understand, but "backup" is so overloaded that "perform the backup"
isn't really descriptive. What is meant is "Make a copy of your server's
entire tree, including configuration files, subdirectories, as well as
the backup_labeland tablespace_map files created when you
initiate pg_start_backup()".

It may seem ovious to veteransm but trust me, to someone new the
various steps can be very confusing, and the documentation for it
isn't great.

>
> You have to "perform the backup", as quoted above.  You don't have to do
> it with tar, and you don't need to name the resulting file ".tgz".  But
> using some method or another, you do need to actually take a backup, if
> your desire is to have a backup.
>
> Did you create a backup?  If you did not, then no, your backup is not
> usable.  If you did, does it include the backup_label file?
>
> Cheers,
>
> Jeff

Thanks Jeff. I've spent enough time on this so that I feel I have
a reasonable grasp of the steps involved. My WALs are archived,
The file system backup is stowed away, with backup_label safely
tucked in it.

I posted a documentation to -docs, which hopefully would qualify
as an improvement. Obviously, it would help if someone more
experienced reviewed it and gave it up a thumbs up. If you have
the spare cycles...


Kind Regards,
Amir