pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedSetting up a server with previous day data
7+ messages / 6 participants
[nested] [flat]
* Setting up a server with previous day data
@ 2022-07-19 07:22 Srinivasa T N <seenutn@gmail.com>
0 siblings, 4 replies; 7+ messages in thread
From: Srinivasa T N @ 2022-07-19 07:22 UTC (permalink / raw)
To: PostgreSQL General <pgsql-general@lists.postgresql.org>
Hi All,
I have a primary postgresql 12 server which is being continuously used
for transaction processing. For reporting purposes, I want to set up a
secondary server which has got previous day data. Everyday night, I want
the data from primary to be shifted to secondary. I can achieve this
manually using pg_basebackup on primary and pg_restore on secondary. Is
there any other automated efficient way to achieve the same? Any relevant
docs would be helpful.
Regards,
Seenu.
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Setting up a server with previous day data
@ 2022-07-19 10:07 Abdul Qoyyuum <aqoyyuum@cardaccess.com.au>
parent: Srinivasa T N <seenutn@gmail.com>
3 siblings, 0 replies; 7+ messages in thread
From: Abdul Qoyyuum @ 2022-07-19 10:07 UTC (permalink / raw)
To: Srinivasa T N <seenutn@gmail.com>; +Cc: PostgreSQL General <pgsql-general@lists.postgresql.org>
You could instead set up High Availability and use your secondary as actual
streamed and backed up database.
https://www.postgresql.org/docs/current/high-availability.html
This way, you get up-to-date data that you can query/generate reports with.
On Tue, Jul 19, 2022 at 3:22 PM Srinivasa T N <seenutn@gmail.com> wrote:
> Hi All,
> I have a primary postgresql 12 server which is being continuously used
> for transaction processing. For reporting purposes, I want to set up a
> secondary server which has got previous day data. Everyday night, I want
> the data from primary to be shifted to secondary. I can achieve this
> manually using pg_basebackup on primary and pg_restore on secondary. Is
> there any other automated efficient way to achieve the same? Any relevant
> docs would be helpful.
>
> Regards,
> Seenu.
>
--
Abdul Qoyyuum Bin Haji Abdul Kadir
HP No: +673 720 8043
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Setting up a server with previous day data
@ 2022-07-19 15:02 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Srinivasa T N <seenutn@gmail.com>
3 siblings, 0 replies; 7+ messages in thread
From: Adrian Klaver @ 2022-07-19 15:02 UTC (permalink / raw)
To: Srinivasa T N <seenutn@gmail.com>; PostgreSQL General <pgsql-general@lists.postgresql.org>
On 7/19/22 00:22, Srinivasa T N wrote:
> Hi All,
> I have a primary postgresql 12 server which is
> being continuously used for transaction processing. For reporting
> purposes, I want to set up a secondary server which has got previous day
> data. Everyday night, I want the data from primary to be shifted to
> secondary. I can achieve this manually using pg_basebackup on primary
> and pg_restore on secondary. Is there any other automated efficient way
> to achieve the same? Any relevant docs would be helpful.
Use Postgres FDW:
https://www.postgresql.org/docs/current/postgres-fdw.html
to set up a link between the two?
>
> Regards,
> Seenu.
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Setting up a server with previous day data
@ 2022-08-23 19:43 Stephen Frost <sfrost@snowman.net>
parent: Srinivasa T N <seenutn@gmail.com>
3 siblings, 0 replies; 7+ messages in thread
From: Stephen Frost @ 2022-08-23 19:43 UTC (permalink / raw)
To: Srinivasa T N <seenutn@gmail.com>; +Cc: PostgreSQL General <pgsql-general@lists.postgresql.org>
Greetings,
* Srinivasa T N (seenutn@gmail.com) wrote:
> I have a primary postgresql 12 server which is being continuously used
> for transaction processing. For reporting purposes, I want to set up a
> secondary server which has got previous day data. Everyday night, I want
> the data from primary to be shifted to secondary. I can achieve this
> manually using pg_basebackup on primary and pg_restore on secondary. Is
> there any other automated efficient way to achieve the same? Any relevant
> docs would be helpful.
You might consider checking out pgbackrest and the incremental backup
and delta restore options that it has. Incremental backups will only
copy files from the PG server that have changed since the last backup,
and the delta restore option will only update the files that are
different between the backup and the files that are in place.
pgbackrest is also able to parallelize these operations.
(this use-case, more-or-less, was part of the original reason pgbackrest
was developed, btw)
Thanks,
Stephen
Attachments:
signature.asc (application/pgp-signature, 818B) download
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Setting up a server with previous day data
@ 2022-08-24 00:15 Ron <ronljohnsonjr@gmail.com>
parent: Srinivasa T N <seenutn@gmail.com>
3 siblings, 1 reply; 7+ messages in thread
From: Ron @ 2022-08-24 00:15 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 7/19/22 02:22, Srinivasa T N wrote:
> Hi All,
> I have a primary postgresql 12 server which is being continuously used
> for transaction processing. For reporting purposes, I want to set up a
> secondary server which has got previous day data. Everyday night, I want
> the data from primary to be shifted to secondary. I can achieve this
> manually using pg_basebackup on primary and pg_restore on secondary. Is
> there any other automated efficient way to achieve the same? Any relevant
> docs would be helpful.
We populated a "reporting" database from the OLTP database (not PostgreSQL)
by creating "/X/_log1" and "/X/_log2" tables which had the same columns as
relevant "main" tables, plus an ACTION_CODE with values 'I", "U" or "D", and
a datetime field which defaults to CURRENT_TIMESTAMP.
ON INSERT, ON UPDATE and ON DELETE triggers were added to the "main" tables
which inserted into X_log2 on even days, and into X_log1 on odd days.
Soon after midnight, a cron job dumped "yesterday's" _log table, loaded it
into the reporting table, and then truncated the _log table.
That was before someone developed a utility to convert the roll-forward logs
into INSERT, UPDATE and DELETE statements.
Such a utility for PostgreSQL that would convert yesterday's WAL files into
SQL would /really/ solve your problem.
--
Angular momentum makes the world go 'round.
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Setting up a server with previous day data
@ 2022-08-24 06:42 Peter J. Holzer <hjp-pgsql@hjp.at>
parent: Ron <ronljohnsonjr@gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Peter J. Holzer @ 2022-08-24 06:42 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 2022-08-23 19:15:58 -0500, Ron wrote:
> That was before someone developed a utility to convert the roll-forward logs
> into INSERT, UPDATE and DELETE statements.
>
> Such a utility for PostgreSQL that would convert yesterday's WAL files into SQL
> would really solve your problem.
Isn't that what logical replication basically does?
I also think I've seen other tools parsing the WAL stream and doing
something useful with the results.
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Setting up a server with previous day data
@ 2022-08-24 13:51 Ron <ronljohnsonjr@gmail.com>
parent: Peter J. Holzer <hjp-pgsql@hjp.at>
0 siblings, 0 replies; 7+ messages in thread
From: Ron @ 2022-08-24 13:51 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 8/24/22 01:42, Peter J. Holzer wrote:
> On 2022-08-23 19:15:58 -0500, Ron wrote:
>> That was before someone developed a utility to convert the roll-forward logs
>> into INSERT, UPDATE and DELETE statements.
>>
>> Such a utility for PostgreSQL that would convert yesterday's WAL files into SQL
>> would really solve your problem.
> Isn't that what logical replication basically does?
In a more asynchronous manner. :D
--
Angular momentum makes the world go 'round.
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2022-08-24 13:51 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-07-19 07:22 Setting up a server with previous day data Srinivasa T N <seenutn@gmail.com>
2022-07-19 10:07 ` Abdul Qoyyuum <aqoyyuum@cardaccess.com.au>
2022-07-19 15:02 ` Adrian Klaver <adrian.klaver@aklaver.com>
2022-08-23 19:43 ` Stephen Frost <sfrost@snowman.net>
2022-08-24 00:15 ` Ron <ronljohnsonjr@gmail.com>
2022-08-24 06:42 ` Peter J. Holzer <hjp-pgsql@hjp.at>
2022-08-24 13:51 ` Ron <ronljohnsonjr@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox