Skip to content

Commit 42a4dbc

Browse files
authored
Merge pull request #1 from postgrespro/master
sync upstream
2 parents c2f3968 + 4d51c7f commit 42a4dbc

38 files changed

+7079
-2736
lines changed

Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ OBJS += src/pg_crc.o src/datapagemap.o src/receivelog.o src/streamutil.o \
1515

1616
EXTRA_CLEAN = src/pg_crc.c src/datapagemap.c src/datapagemap.h \
1717
src/receivelog.c src/receivelog.h src/streamutil.c src/streamutil.h \
18-
src/xlogreader.c
18+
src/xlogreader.c src/instr_time.h
1919

20-
INCLUDES = src/datapagemap.h src/streamutil.h src/receivelog.h
20+
INCLUDES = src/datapagemap.h src/streamutil.h src/receivelog.h src/instr_time.h
2121

2222
ifdef USE_PGXS
2323
PG_CONFIG = pg_config
@@ -60,6 +60,8 @@ all: checksrcdir $(INCLUDES);
6060

6161
$(PROGRAM): $(OBJS)
6262

63+
src/instr_time.h: $(top_srcdir)/src/include/portability/instr_time.h
64+
rm -f $@ && $(LN_S) $(srchome)/src/include/portability/instr_time.h $@
6365
src/datapagemap.c: $(top_srcdir)/src/bin/pg_rewind/datapagemap.c
6466
rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_rewind/datapagemap.c $@
6567
src/datapagemap.h: $(top_srcdir)/src/bin/pg_rewind/datapagemap.h

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The utility is compatible with:
77

88
As compared to other backup solutions, `pg_probackup` offers the following benefits that can help you implement different backup strategies and deal with large amounts of data:
99
* Incremental backup: page-level incremental backup allows you to save disk space, speed up backup and restore. With three different incremental modes, you can plan the backup strategy in accordance with your data flow.
10+
* Merge: using this feature allows you to implement "incrementally updated backups" strategy, eliminating the need to to do periodical full backups.
1011
* Validation: automatic data consistency checks and on-demand backup validation without actual data recovery
1112
* Verification: on-demand verification of PostgreSQL instance with the `checkdb` command.
1213
* Retention: managing WAL archive and backups in accordance with retention policy. You can configure retention policy based on recovery time or the number of backups to keep, as well as specify `time to live` (TTL) for a particular backup. Expired backups can be merged or deleted.

doc/pgprobackup.xml

+147-30
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ doc/src/sgml/pgprobackup.sgml
131131
<arg choice="plain"><option>archive-push</option></arg>
132132
<arg choice="plain"><option>-B</option> <replaceable>backup_dir</replaceable></arg>
133133
<arg choice="plain"><option>--instance</option> <replaceable>instance_name</replaceable></arg>
134-
<arg choice="plain"><option>--wal-file-path</option> <replaceable>wal_file_path</replaceable></arg>
135134
<arg choice="plain"><option>--wal-file-name</option> <replaceable>wal_file_name</replaceable></arg>
136135
<arg rep="repeat"><replaceable>option</replaceable></arg>
137136
</cmdsynopsis>
@@ -427,14 +426,6 @@ doc/src/sgml/pgprobackup.sgml
427426
or <application>libc</application>/<application>libicu</application> versions.
428427
</para>
429428
</listitem>
430-
<listitem>
431-
<para>
432-
All backups in the incremental chain must belong to the same
433-
timeline. For example, if you have taken incremental backups on a
434-
standby server that gets promoted, you have to take another FULL
435-
backup.
436-
</para>
437-
</listitem>
438429
</itemizedlist>
439430
</para>
440431
</refsect2>
@@ -754,9 +745,10 @@ ALTER ROLE backup WITH REPLICATION;
754745
<title>Setting up Continuous WAL Archiving</title>
755746
<para>
756747
Making backups in PAGE backup mode, performing
757-
<link linkend="pbk-performing-point-in-time-pitr-recovery">PITR</link>
758-
and making backups with
759-
<link linkend="pbk-archive-mode">ARCHIVE</link> WAL delivery mode
748+
<link linkend="pbk-performing-point-in-time-pitr-recovery">PITR</link>,
749+
making backups with
750+
<link linkend="pbk-archive-mode">ARCHIVE</link> WAL delivery mode and
751+
running incremental backup after timeline switch
760752
require
761753
<ulink url="https://postgrespro.com/docs/postgresql/current/continuous-archiving.html">continuous
762754
WAL archiving</ulink> to be enabled. To set up continuous
@@ -786,7 +778,7 @@ ALTER ROLE backup WITH REPLICATION;
786778
parameter, as follows:
787779
</para>
788780
<programlisting>
789-
archive_command = '<replaceable>install_dir</replaceable>/pg_probackup archive-push -B <replaceable>backup_dir</replaceable> --instance <replaceable>instance_name</replaceable> --wal-file-path=%p --wal-file-name=%f [<replaceable>remote_options</replaceable>]'
781+
archive_command = '<replaceable>install_dir</replaceable>/pg_probackup archive-push -B <replaceable>backup_dir</replaceable> --instance <replaceable>instance_name</replaceable> --wal-file-name=%f [<replaceable>remote_options</replaceable>]'
790782
</programlisting>
791783
</listitem>
792784
</itemizedlist>
@@ -1634,13 +1626,14 @@ pg_probackup restore -B <replaceable>backup_dir</replaceable> --instance <replac
16341626
<para>
16351627
If you restore <link linkend="pbk-archive-mode">ARCHIVE</link> backups,
16361628
perform <link linkend="pbk-performing-point-in-time-pitr-recovery">PITR</link>,
1637-
or specify the <literal>--restore-as-replica</literal> option with the
1629+
or specify the <literal>--restore-as-replica</literal> flag with the
16381630
<literal>restore</literal> command to set up a standby server,
16391631
<application>pg_probackup</application> creates a recovery configuration
16401632
file once all data files are copied into the target directory. This file
16411633
includes the minimal settings required for recovery, except for the password in the
16421634
<ulink url="https://postgrespro.com/docs/postgresql/current/runtime-config-replication.html#GUC-PRIMARY-CONNINFO">primary_conninfo</ulink>
1643-
parameter; you have to add the password manually, if required.
1635+
parameter; you have to add the password manually or use
1636+
the <literal>--primary-conninfo</literal> option, if required.
16441637
For <productname>PostgreSQL</productname> 11 or lower,
16451638
recovery settings are written into the <filename>recovery.conf</filename>
16461639
file. Starting from <productname>PostgreSQL</productname> 12,
@@ -2242,6 +2235,13 @@ BACKUP INSTANCE 'node'
22422235
<literal>MERGING</literal> — the backup is being merged.
22432236
</para>
22442237
</listitem>
2238+
<listitem>
2239+
<para>
2240+
<literal>MERGED</literal> — the backup data files were
2241+
successfully merged, but its metadata is in the process
2242+
of been updated. Only full backup can have this status.
2243+
</para>
2244+
</listitem>
22452245
<listitem>
22462246
<para>
22472247
<literal>DELETING</literal> — the backup files are being deleted.
@@ -3146,7 +3146,9 @@ pg_probackup merge -B <replaceable>backup_dir</replaceable> --instance <replacea
31463146
<para>
31473147
This command merges the specified incremental backup to its
31483148
parent full backup, together with all incremental backups
3149-
between them. Once the merge is complete, the incremental
3149+
between them. If the specified backup ID belong to the full backup,
3150+
then it will be merged with the closest incremental backup.
3151+
Once the merge is complete, the incremental
31503152
backups are removed as redundant. Thus, the merge operation is
31513153
virtually equivalent to retaking a full backup and removing all
31523154
the outdated backups, but it allows to save much time,
@@ -3165,7 +3167,8 @@ pg_probackup show -B <replaceable>backup_dir</replaceable> --instance <replaceab
31653167
</programlisting>
31663168
<para>
31673169
If the merge is still in progress, the backup status is
3168-
displayed as <literal>MERGING</literal>. The merge is idempotent, so you can
3170+
displayed as <literal>MERGING</literal> or, at the final stage,
3171+
<literal>MERGED</literal>. The merge is idempotent, so you can
31693172
restart the merge if it was interrupted.
31703173
</para>
31713174
</refsect2>
@@ -3404,6 +3407,7 @@ pg_probackup backup -B <replaceable>backup_dir</replaceable> -b <replaceable>bac
34043407
[--no-validate] [--skip-block-validation]
34053408
[-w --no-password] [-W --password]
34063409
[--archive-timeout=<replaceable>timeout</replaceable>] [--external-dirs=<replaceable>external_directory_path</replaceable>]
3410+
[--no-sync]
34073411
[<replaceable>connection_options</replaceable>] [<replaceable>compression_options</replaceable>] [<replaceable>remote_options</replaceable>]
34083412
[<replaceable>retention_options</replaceable>] [<replaceable>pinning_options</replaceable>] [<replaceable>logging_options</replaceable>]
34093413
</programlisting>
@@ -3556,6 +3560,18 @@ pg_probackup backup -B <replaceable>backup_dir</replaceable> -b <replaceable>bac
35563560
</para>
35573561
</listitem>
35583562
</varlistentry>
3563+
3564+
<varlistentry>
3565+
<term><option>--no-sync</option></term>
3566+
<listitem>
3567+
<para>
3568+
Do not sync backed up files to disk. You can use this flag to speed
3569+
up backup process. Using this flag can result in data
3570+
corruption in case of operating system or hardware crash.
3571+
Corruption can be detected by backup validation.
3572+
</para>
3573+
</listitem>
3574+
</varlistentry>
35593575
</variablelist>
35603576
</para>
35613577

@@ -3582,8 +3598,11 @@ pg_probackup restore -B <replaceable>backup_dir</replaceable> --instance <replac
35823598
[--help] [-D <replaceable>data_dir</replaceable>] [-i <replaceable>backup_id</replaceable>]
35833599
[-j <replaceable>num_threads</replaceable>] [--progress]
35843600
[-T <replaceable>OLDDIR</replaceable>=<replaceable>NEWDIR</replaceable>] [--external-mapping=<replaceable>OLDDIR</replaceable>=<replaceable>NEWDIR</replaceable>] [--skip-external-dirs]
3585-
[-R | --restore-as-replica] [--no-validate] [--skip-block-validation] [--force]
3601+
[-R | --restore-as-replica] [--no-validate] [--skip-block-validation]
3602+
[--force] [--no-sync]
35863603
[--restore-command=<replaceable>cmdline</replaceable>]
3604+
[--primary-conninfo=<replaceable>primary_conninfo</replaceable>]
3605+
[-S | --primary-slot-name=<replaceable>slotname</replaceable>]
35873606
[<replaceable>recovery_target_options</replaceable>] [<replaceable>logging_options</replaceable>] [<replaceable>remote_options</replaceable>]
35883607
[<replaceable>partial_restore_options</replaceable>] [<replaceable>remote_wal_archive_options</replaceable>]
35893608
</programlisting>
@@ -3621,6 +3640,34 @@ pg_probackup restore -B <replaceable>backup_dir</replaceable> --instance <replac
36213640
</listitem>
36223641
</varlistentry>
36233642

3643+
<varlistentry>
3644+
<term><option>--primary-conninfo=<replaceable>primary_conninfo</replaceable></option></term>
3645+
<listitem>
3646+
<para>
3647+
Sets the
3648+
<ulink url="https://postgrespro.com/docs/postgresql/current/runtime-config-replication.html#GUC-PRIMARY-CONNINFO">primary_conninfo</ulink>
3649+
parameter to the specified value.
3650+
This option will be ignored unless the <option>-R</option> flag if specified.
3651+
</para>
3652+
<para>
3653+
Example: <literal>--primary-conninfo='host=192.168.1.50 port=5432 user=foo password=foopass'</literal>
3654+
</para>
3655+
</listitem>
3656+
</varlistentry>
3657+
3658+
<varlistentry>
3659+
<term><option>-S</option></term>
3660+
<term><option>--primary-slot-name=<replaceable>slot_name</replaceable></option></term>
3661+
<listitem>
3662+
<para>
3663+
Sets the
3664+
<ulink url="https://postgrespro.com/docs/postgresql/current/runtime-config-replication#GUC-PRIMARY-SLOT-NAME">primary_slot_name</ulink>
3665+
parameter to the specified value.
3666+
This option will be ignored unless the <option>-R</option> flag if specified.
3667+
</para>
3668+
</listitem>
3669+
</varlistentry>
3670+
36243671
<varlistentry>
36253672
<term><option>-T <replaceable>OLDDIR</replaceable>=<replaceable>NEWDIR</replaceable></option></term>
36263673
<term><option>--tablespace-mapping=<replaceable>OLDDIR</replaceable>=<replaceable>NEWDIR</replaceable></option></term>
@@ -3705,6 +3752,17 @@ pg_probackup restore -B <replaceable>backup_dir</replaceable> --instance <replac
37053752
</para>
37063753
</listitem>
37073754
</varlistentry>
3755+
3756+
<varlistentry>
3757+
<term><option>--no-sync</option></term>
3758+
<listitem>
3759+
<para>
3760+
Do not sync restored files to disk. You can use this flag to speed
3761+
up restore process. Using this flag can result in data
3762+
corruption in case of operating system or hardware crash.
3763+
</para>
3764+
</listitem>
3765+
</varlistentry>
37083766
</variablelist>
37093767
</para>
37103768
<para>
@@ -3831,7 +3889,9 @@ pg_probackup merge -B <replaceable>backup_dir</replaceable> --instance <replacea
38313889
<para>
38323890
Merges the specified incremental backup to its parent full
38333891
backup, together with all incremental backups between them, if
3834-
any. As a result, the full backup takes in all the merged
3892+
any. If the specified backup ID belong to the full backup,
3893+
then it will be merged with the closest incremental backup.
3894+
As a result, the full backup takes in all the merged
38353895
data, and the incremental backups are removed as redundant.
38363896
</para>
38373897
<para>
@@ -3866,9 +3926,12 @@ pg_probackup delete -B <replaceable>backup_dir</replaceable> --instance <replace
38663926
<title>archive-push</title>
38673927
<programlisting>
38683928
pg_probackup archive-push -B <replaceable>backup_dir</replaceable> --instance <replaceable>instance_name</replaceable>
3869-
--wal-file-path=<replaceable>wal_file_path</replaceable> --wal-file-name=<replaceable>wal_file_name</replaceable>
3870-
[--help] [--compress] [--compress-algorithm=<replaceable>compression_algorithm</replaceable>]
3871-
[--compress-level=<replaceable>compression_level</replaceable>] [--overwrite]
3929+
--wal-file-name=<replaceable>wal_file_name</replaceable>
3930+
[--help] [--no-sync] [--compress] [--no-ready-rename] [--overwrite]
3931+
[-j <replaceable>num_threads</replaceable>] [--batch-size=<replaceable>batch_size</replaceable>]
3932+
[--archive-timeout=<replaceable>timeout</replaceable>]
3933+
[--compress-algorithm=<replaceable>compression_algorithm</replaceable>]
3934+
[--compress-level=<replaceable>compression_level</replaceable>]
38723935
[<replaceable>remote_options</replaceable>] [<replaceable>logging_options</replaceable>]
38733936
</programlisting>
38743937
<para>
@@ -3893,13 +3956,24 @@ pg_probackup archive-push -B <replaceable>backup_dir</replaceable> --instance <r
38933956
with the <option>--overwrite</option> flag.
38943957
</para>
38953958
<para>
3896-
The files are copied to a temporary file with the
3897-
<literal>.part</literal> suffix. After the copy is
3898-
done, atomic rename is performed. This algorithm ensures that a
3899-
failed <command>archive-push</command> will not stall continuous archiving and
3900-
that concurrent archiving from multiple sources into a single
3901-
WAL archive have no risk of archive corruption. WAL segments copied to
3902-
the archive are synced to disk.
3959+
Every file is copied to a temporary file with the
3960+
<literal>.part</literal> suffix. If the temporary file already
3961+
exists, <application>pg_probackup</application> will wait
3962+
<option>archive_timeout</option> seconds before discarding it.
3963+
After the copy is done, atomic rename is performed.
3964+
This algorithm ensures that a failed <command>archive-push</command>
3965+
will not stall continuous archiving and that concurrent archiving from
3966+
multiple sources into a single WAL archive have no risk of archive
3967+
corruption.
3968+
</para>
3969+
<para>
3970+
To speed up archiving, especially in remote mode, <command>archive-push</command>
3971+
can be run on multiple threads using <option>-j num_threads</option> option.
3972+
Files can also be copied in batches using option <option>--batch-size</option>.
3973+
</para>
3974+
<para>
3975+
WAL segments copied to the archive are synced to disk unless
3976+
<option>--no-sync</option> flag is used.
39033977
</para>
39043978
<para>
39053979
You can use <command>archive-push</command> in the
@@ -4005,7 +4079,8 @@ pg_probackup archive-get -B <replaceable>backup_dir</replaceable> --instance <re
40054079
<para>
40064080
Sets the number of parallel threads for <command>backup</command>,
40074081
<command>restore</command>, <command>merge</command>,
4008-
<command>validate</command>, and <command>checkdb</command> processes.
4082+
<command>validate</command>, <command>checkdb</command> and
4083+
<command>archive-push</command> processes.
40094084
</para>
40104085
</listitem>
40114086
</varlistentry>
@@ -4664,6 +4739,48 @@ pg_probackup archive-get -B <replaceable>backup_dir</replaceable> --instance <re
46644739
</para>
46654740
</listitem>
46664741
</varlistentry>
4742+
4743+
<varlistentry>
4744+
<term><option>--batch-size=batch_size</option></term>
4745+
<listitem>
4746+
<para>
4747+
Sets the maximum number of files to be copied into archive by signle
4748+
<command>archive-push</command> process.
4749+
</para>
4750+
</listitem>
4751+
</varlistentry>
4752+
4753+
<varlistentry>
4754+
<term><option>--archive-timeout=<replaceable>wait_time</replaceable></option></term>
4755+
<listitem>
4756+
<para>
4757+
Sets the timeout for considering existing <literal>.part</literal> file to be stale. By default <application>pg_probackup</application> waits 300 seconds.
4758+
</para>
4759+
</listitem>
4760+
</varlistentry>
4761+
4762+
<varlistentry>
4763+
<term><option>--no-ready-rename</option></term>
4764+
<listitem>
4765+
<para>
4766+
Do not rename status files in <literal>archive_status</literal> directory.
4767+
This option should be used only if <parameter>archive_command</parameter>
4768+
contain multiple commands.
4769+
</para>
4770+
</listitem>
4771+
</varlistentry>
4772+
4773+
<varlistentry>
4774+
<term><option>--no-sync</option></term>
4775+
<listitem>
4776+
<para>
4777+
Do not sync copied WAL files to disk. You can use this flag to speed
4778+
up archiving process. Using this flag can result in WAL archive
4779+
corruption in case of operating system or hardware crash.
4780+
</para>
4781+
</listitem>
4782+
</varlistentry>
4783+
46674784
</variablelist>
46684785
</para>
46694786
</refsect3>

0 commit comments

Comments
 (0)