Re: pgbackrest creating new directories (messing up cron jobs).

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: mimble9(at)danwin1210(dot)me
Cc: pgsql-novice(at)lists(dot)postgresql(dot)org
Subject: Re: pgbackrest creating new directories (messing up cron jobs).
Date: 2020-03-11 00:37:27
Message-ID: 20200311003726.GR3195@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Greetings,

* mimble9(at)danwin1210(dot)me (mimble9(at)danwin1210(dot)me) wrote:
> I think I need to take a step backwards and ask something else before
> moving forward.

Good idea.

> > Isn't that going to mail you the same WAL over and over again if you set
> > it up as a cronjob..? Is that really what you want?
>
> I took a full backup when I started. Then I used type=diff. This creates
> two archives every x hours (depending on the time period set in cron).

WAL files are not "archives" in the sense that they are a complete
database backup- they're just the write-ahead-logs from the ongoing
running of PG. You need the actual data files as well as the WAL to
perform a restore.

> For example:
>
> -rw-r----- 1 postgres postgres 27145 Mar 11 00:00
> 0000000100000001000000B9-6f3902fe5c3bdebc3c1c124ec6821c7206e350da.gz
>
> -rw-r----- 1 postgres postgres 27126 Mar 11 00:00
> 0000000100000001000000BA-214e7142c6eda0a350577f6bd624c3db203e184f.gz
>
> Only one of these relates to the database I setup in PostgreSQL. I don't
> know what the other one is but it might be related to the "default"
> database 'postgres'. (This is just a guess).

No, that's not how WAL works. Those are two WAL files and they're both
generated as part of running the PG system- they are not specific to one
database or another in PG.

> Irrespective, I would only want a new archive file if something has
> changed in the database. Yet I seem to always receive two new files every
> x hours even if nothing has changed.

These individuals files are not archives of the entire PG system or
anything you can use to reconstruct a running PG system with just one
file.

> So I tried type-incr but that seems to produce the same results as type=diff.

The difference between incremental and differential backups is
documented at https://pgbackrest.org

> I wonder what I am doing wrong?

I'm afraid there are some pretty fundamental misunderstandings that you
have about the PG WAL, PG backups, and what you can do with a PG cluster
andf file-level backup/restore.

Documentation about the WAL can be found here:

https://www.postgresql.org/docs/current/wal-intro.html

If what you're actually looking for is a single file that has a backup
of your entire database, you can get that by running:

pgbackrest backup --archive-copy

and then do:

pgbackrest restore --pg-path=/path/to/somewhere
tar -czf pgdata.tar.gz /path/to/somewhere

or so. Check the pgbackrest docs for the specific command syntax and
such.

Thanks,

Stephen

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Keith 2020-03-11 02:06:43 Re: Major upgrade from 9.6.15 to 12.2
Previous Message mimble9 2020-03-11 00:08:05 Re: pgbackrest creating new directories (messing up cron jobs).