You've already forked pg_probackup
mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-09-16 09:26:30 +02:00
Rewrite How-To into a Quick Start
This commit is contained in:
@@ -171,6 +171,9 @@ doc/src/sgml/pgprobackup.sgml
|
||||
<listitem>
|
||||
<para><link linkend="pbk-overview">Overview</link></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><link linkend="pbk-quickstart">Quick Start</link></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><link linkend="pbk-install">Installation</link></para>
|
||||
</listitem>
|
||||
@@ -453,7 +456,267 @@ doc/src/sgml/pgprobackup.sgml
|
||||
</para>
|
||||
</refsect2>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id="pbk-quickstart">
|
||||
<title>Quick Start</title>
|
||||
<para>
|
||||
To quickly get started with <application>pg_probackup</application>, complete the steps below. This will set up FULL and DELTA backups in the remote mode and demonstrate some
|
||||
basic <application>pg_probackup</application> operations. In the following, these terms are used:
|
||||
</para>
|
||||
<itemizedlist spacing="compact">
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>backup</literal> — <productname>PostgreSQL</productname>
|
||||
role used to connect to the <productname>PostgreSQL</productname>
|
||||
cluster.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>backupdb</literal> — database used used to connect to the
|
||||
<productname>PostgreSQL</productname> cluster.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>backup_host</literal> — host with the backup catalog.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>backup</literal> — user on
|
||||
<literal>backup_host</literal> running all <application>pg_probackup</application>
|
||||
operations.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<filename>/mnt/backups</filename> — directory on
|
||||
<literal>backup_host</literal> where the backup catalog is stored.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>postgres_host</literal> — host with the
|
||||
<productname>PostgreSQL</productname> cluster.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>postgres</literal> — user on
|
||||
<literal>postgres_host</literal> under which
|
||||
<productname>PostgreSQL</productname> cluster processes are running.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<filename>/var/lib/postgresql/16/main</filename> —
|
||||
<productname>PostgreSQL</productname> data directory on
|
||||
<literal>postgres_host</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<refsect2 id="pbk-minimal-setup">
|
||||
<title>Steps to perform:</title>
|
||||
<procedure>
|
||||
<step>
|
||||
<title>Install <application>pg_probackup</application> on both <literal>backup_host</literal> and <literal>postgres_host</literal>.</title>
|
||||
</step>
|
||||
<step id="pbk-quickstart-setup-ssh">
|
||||
<title><link linkend="pbk-setup-ssh">Set up an SSH connection</link> from <literal>backup_host</literal> to <literal>postgres_host</literal>.</title>
|
||||
</step>
|
||||
<step id="pbk-setup-postgresql-cluster">
|
||||
<title><link linkend="pbk-configuring-the-database-cluster">Configure</link> your database cluster for <link linkend="pbk-setting-up-stream-backups">STREAM backups</link>.</title>
|
||||
</step>
|
||||
<step id="pbk-init-the-backup-catalog">
|
||||
<title>Initialize the backup catalog:</title>
|
||||
<programlisting>
|
||||
backup_user@backup_host:~$ pg_probackup-16 init -B /mnt/backups
|
||||
INFO: Backup catalog '/mnt/backups' successfully initialized
|
||||
</programlisting>
|
||||
</step>
|
||||
<step id="pbk-add-instance-to-backup-catalog">
|
||||
<title>Add a backup instance called <literal>mydb</literal> to the backup catalog:</title>
|
||||
<programlisting>
|
||||
backup_user@backup_host:~$ pg_probackup-16 add-instance \
|
||||
-B /mnt/backups \
|
||||
-D /var/lib/postgresql/16/main \
|
||||
--instance=mydb \
|
||||
--remote-host=postgres_host \
|
||||
--remote-user=postgres
|
||||
INFO: Instance 'mydb' successfully initialized
|
||||
</programlisting>
|
||||
</step>
|
||||
<step id="pbk-make-full-backup">
|
||||
<title>Make a FULL backup:</title>
|
||||
<programlisting>
|
||||
backup_user@backup_host:~$ pg_probackup-16 backup \
|
||||
-B /mnt/backups \
|
||||
-b FULL \
|
||||
--instance=mydb \
|
||||
--stream \
|
||||
--remote-host=postgres_host \
|
||||
--remote-user=postgres \
|
||||
-U backup \
|
||||
-d backupdb
|
||||
INFO: Backup start, pg_probackup version: 2.5.13, instance: mydb, backup ID: S6OBFN, backup mode: FULL, wal mode: STREAM, remote: true, compress-algorithm: none, compress-level: 1
|
||||
INFO: Database backup start
|
||||
INFO: wait for pg_backup_start()
|
||||
INFO: Wait for WAL segment /mnt/backups/backups/mydb/S6OBFN/database/pg_wal/000000010000000000000002 to be streamed
|
||||
INFO: PGDATA size: 29MB
|
||||
INFO: Current Start LSN: 0/2000060, TLI: 1
|
||||
INFO: Start transferring data files
|
||||
INFO: Data files are transferred, time elapsed: 1s
|
||||
INFO: wait for pg_stop_backup()
|
||||
INFO: pg_stop backup() successfully executed
|
||||
INFO: stop_lsn: 0/2003CB0
|
||||
INFO: Getting the Recovery Time from WAL
|
||||
INFO: Syncing backup files to disk
|
||||
INFO: Backup files are synced, time elapsed: 0
|
||||
INFO: Validating backup S6OBFN
|
||||
INFO: Backup S6OBFN data files are valid
|
||||
INFO: Backup S6OBFN resident size: 45MB
|
||||
INFO: Backup S6OBFN completed
|
||||
</programlisting>
|
||||
</step>
|
||||
<step id="pbk-list-backups">
|
||||
<title>List the backups of the instance:</title>
|
||||
<programlisting>
|
||||
backup_user@backup_host:~$ pg_probackup-16 show -B /mnt/backups --instance=mydb
|
||||
================================================================================================================================
|
||||
Instance Version ID Recovery Time Mode WAL Mode TLI Time Data WAL Zratio Start LSN Stop LSN Status
|
||||
================================================================================================================================
|
||||
mydb 16 S6OBFN 2024-01-03 06:59:49+00 FULL STREAM 1/0 10s 29MB 16MB 1.00 0/2000060 0/2003CB0 OK
|
||||
</programlisting>
|
||||
</step>
|
||||
<step id="pbk-make-incremental-backup-in-delta-mode">
|
||||
<title>Make an incremental backup in the DELTA mode:</title>
|
||||
<programlisting>
|
||||
backup_user@backup_host:~$ pg_probackup-16 backup \
|
||||
-B /mnt/backups \
|
||||
-b delta \
|
||||
--instance=mydb \
|
||||
--stream \
|
||||
--remote-host=postgres_host \
|
||||
--remote-user=postgres \
|
||||
-U backup \
|
||||
-d backupdb
|
||||
INFO: Backup start, pg_probackup version: 2.5.13, instance: mydb, backup ID: S6OBLG, backup mode: DELTA, wal mode: STREAM, remote: true, compress-algorithm: none, compress-level: 1
|
||||
INFO: Database backup start
|
||||
INFO: wait for pg_backup_start()
|
||||
INFO: Parent backup: S6OBFN
|
||||
INFO: Wait for WAL segment /mnt/backups/backups/mydb/S6OBLG/database/pg_wal/000000010000000000000004 to be streamed
|
||||
INFO: PGDATA size: 29MB
|
||||
INFO: Current Start LSN: 0/4000028, TLI: 1
|
||||
INFO: Parent Start LSN: 0/2000060, TLI: 1
|
||||
INFO: Start transferring data files
|
||||
INFO: Data files are transferred, time elapsed: 1s
|
||||
INFO: wait for pg_stop_backup()
|
||||
INFO: pg_stop backup() successfully executed
|
||||
INFO: stop_lsn: 0/4000168
|
||||
INFO: Getting the Recovery Time from WAL
|
||||
INFO: Syncing backup files to disk
|
||||
INFO: Backup files are synced, time elapsed: 0
|
||||
INFO: Validating backup S6OBLG
|
||||
INFO: Backup S6OBLG data files are valid
|
||||
INFO: Backup S6OBLG resident size: 32MB
|
||||
INFO: Backup S6OBLG completed
|
||||
</programlisting>
|
||||
</step>
|
||||
<step id="pbk-save-config-parameters">
|
||||
<title>Add or modify some parameters in the <application>pg_probackup</application>
|
||||
configuration file, so that you do not have to specify them each time on the command line:</title>
|
||||
<programlisting>
|
||||
backup_user@backup_host:~$ pg_probackup-16 set-config \
|
||||
-B /mnt/backups \
|
||||
--instance=mydb \
|
||||
--remote-host=postgres_host \
|
||||
--remote-user=postgres \
|
||||
-U backup \
|
||||
-d backupdb
|
||||
</programlisting>
|
||||
</step>
|
||||
<step id="pbk-print-instance-config">
|
||||
<title>Check the configuration of the instance:</title>
|
||||
<programlisting>
|
||||
backup_user@backup_host:~$ pg_probackup-16 show-config -B /mnt/backups --instance=mydb
|
||||
# Backup instance information
|
||||
pgdata = /var/lib/postgresql/16/main
|
||||
system-identifier = 7319761899046784808
|
||||
xlog-seg-size = 16777216
|
||||
# Connection parameters
|
||||
pgdatabase = backupdb
|
||||
pghost = postgres_host
|
||||
pguser = backup
|
||||
# Replica parameters
|
||||
replica-timeout = 5min
|
||||
# Archive parameters
|
||||
archive-timeout = 5min
|
||||
# Logging parameters
|
||||
log-level-console = INFO
|
||||
log-level-file = OFF
|
||||
log-format-console = PLAIN
|
||||
log-format-file = PLAIN
|
||||
log-filename = pg_probackup.log
|
||||
log-rotation-size = 0TB
|
||||
log-rotation-age = 0d
|
||||
# Retention parameters
|
||||
retention-redundancy = 0
|
||||
retention-window = 0
|
||||
wal-depth = 0
|
||||
# Compression parameters
|
||||
compress-algorithm = none
|
||||
compress-level = 1
|
||||
# Remote access parameters
|
||||
remote-proto = ssh
|
||||
remote-host = postgres_host
|
||||
remote-user = postgres
|
||||
</programlisting>
|
||||
<para>
|
||||
Note that the parameters not modified via <command>set-config</command> retain their default values.
|
||||
</para>
|
||||
</step>
|
||||
<step id="pbk-make-another-incremental-backup-in-delta-mode-using-saved-parameters">
|
||||
<title>Make another incremental backup in the DELTA mode, omitting
|
||||
the parameters stored in the configuration file earlier:</title>
|
||||
<programlisting>
|
||||
backup_user@backup_host:~$ pg_probackup-16 backup -B /mnt/backups --instance=mydb -b delta --stream
|
||||
INFO: Backup start, pg_probackup version: 2.5.13, instance: mydb, backup ID: S6OBQO, backup mode: DELTA, wal mode: STREAM, remote: true, compress-algorithm: none, compress-level: 1
|
||||
INFO: Database backup start
|
||||
INFO: wait for pg_backup_start()
|
||||
INFO: Parent backup: S6OBLG
|
||||
INFO: Wait for WAL segment /mnt/backups/backups/mydb/S6OBQO/database/pg_wal/000000010000000000000006 to be streamed
|
||||
INFO: PGDATA size: 29MB
|
||||
INFO: Current Start LSN: 0/6000028, TLI: 1
|
||||
INFO: Parent Start LSN: 0/4000028, TLI: 1
|
||||
INFO: Start transferring data files
|
||||
INFO: Data files are transferred, time elapsed: 1s
|
||||
INFO: wait for pg_stop_backup()
|
||||
INFO: pg_stop backup() successfully executed
|
||||
INFO: stop_lsn: 0/6000168
|
||||
INFO: Getting the Recovery Time from WAL
|
||||
INFO: Syncing backup files to disk
|
||||
INFO: Backup files are synced, time elapsed: 0
|
||||
INFO: Validating backup S6OBQO
|
||||
INFO: Backup S6OBQO data files are valid
|
||||
INFO: Backup S6OBQO resident size: 32MB
|
||||
INFO: Backup S6OBQO completed
|
||||
</programlisting>
|
||||
</step>
|
||||
<step id="pbk-list-backups-again">
|
||||
<title>List the backups of the instance again:</title>
|
||||
<programlisting>
|
||||
backup_user@backup_host:~$ pg_probackup-16 show -B /mnt/backups --instance=mydb
|
||||
==================================================================================================================================
|
||||
Instance Version ID Recovery Time Mode WAL Mode TLI Time Data WAL Zratio Start LSN Stop LSN Status
|
||||
==================================================================================================================================
|
||||
mydb 16 S6OBQO 2024-01-03 07:06:26+00 DELTA STREAM 1/1 6s 111kB 32MB 1.00 0/6000028 0/6000168 OK
|
||||
mydb 16 S6OBLG 2024-01-03 07:03:18+00 DELTA STREAM 1/1 10s 127kB 32MB 1.00 0/4000028 0/4000168 OK
|
||||
mydb 16 S6OBFN 2024-01-03 06:59:49+00 FULL STREAM 1/0 10s 29MB 16MB 1.00 0/2000060 0/2003CB0 OK
|
||||
</programlisting>
|
||||
</step>
|
||||
</procedure>
|
||||
</refsect2>
|
||||
</refsect1>
|
||||
<refsect1 id="pbk-install">
|
||||
<title>Installation</title>
|
||||
<refsect2 id="pbk-install-deb">
|
||||
@@ -744,7 +1007,7 @@ pg_probackup init -B <replaceable>backup_dir</replaceable>
|
||||
pg_probackup add-instance -B <replaceable>backup_dir</replaceable> -D <replaceable>data_dir</replaceable> --instance <replaceable>instance_name</replaceable> [<replaceable>remote_options</replaceable>]
|
||||
</programlisting>
|
||||
<para>
|
||||
where:
|
||||
Where:
|
||||
</para>
|
||||
<itemizedlist spacing="compact">
|
||||
<listitem>
|
||||
@@ -812,11 +1075,19 @@ pg_probackup add-instance -B <replaceable>backup_dir</replaceable> -D <replaceab
|
||||
configuration instructions, the <literal>backup</literal> role
|
||||
is used as an example.
|
||||
</para>
|
||||
<para>
|
||||
For security reasons, it is recommended to run the configuration SQL queries below
|
||||
in a separate database.
|
||||
</para>
|
||||
<programlisting>
|
||||
postgres=# CREATE DATABASE backupdb;
|
||||
postgres=# \c backupdb
|
||||
</programlisting>
|
||||
<para>
|
||||
To perform a <xref linkend="pbk-backup"/>, the following
|
||||
permissions for role <literal>backup</literal> are required
|
||||
only in the database <emphasis role="strong">used for
|
||||
connection</emphasis> to the <productname>PostgreSQL</productname> server:
|
||||
connection</emphasis> to the <productname>PostgreSQL</productname> server.
|
||||
</para>
|
||||
<para>
|
||||
For <productname>PostgreSQL</productname> versions 11 — 14:
|
||||
@@ -908,7 +1179,18 @@ COMMIT;
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
Grant the <literal>REPLICATION</literal> privilege to the <literal>backup</literal> role:
|
||||
If the <literal>backup</literal> role does not exist, create it with
|
||||
the <literal>REPLICATION</literal> privilege when
|
||||
<link linkend="pbk-configuring-the-database-cluster">Configuring the
|
||||
Database Cluster</link>:
|
||||
</para>
|
||||
<programlisting>
|
||||
CREATE ROLE backup WITH LOGIN REPLICATION;
|
||||
</programlisting>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
If the <literal>backup</literal> role already exists, grant it with the <literal>REPLICATION</literal> privilege:
|
||||
</para>
|
||||
<programlisting>
|
||||
ALTER ROLE backup WITH REPLICATION;
|
||||
@@ -1203,7 +1485,7 @@ GRANT SELECT ON TABLE pg_catalog.pg_database TO backup;
|
||||
If you are going to use <application>pg_probackup</application> in remote mode via SSH,
|
||||
complete the following steps:
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
Install <application>pg_probackup</application> on both systems:
|
||||
@@ -1213,7 +1495,7 @@ GRANT SELECT ON TABLE pg_catalog.pg_database TO backup;
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
For communication between the hosts set up the passwordless
|
||||
For communication between the hosts set up a passwordless
|
||||
SSH connection between <literal>backup</literal> user on
|
||||
<literal>backup_host</literal> and
|
||||
<literal>postgres</literal> user on
|
||||
@@ -1222,54 +1504,64 @@ GRANT SELECT ON TABLE pg_catalog.pg_database TO backup;
|
||||
<programlisting>
|
||||
[backup@backup_host] ssh-copy-id postgres@db_host
|
||||
</programlisting>
|
||||
<para>
|
||||
Where:
|
||||
</para>
|
||||
<itemizedlist spacing="compact">
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>backup_host</literal> is the system with
|
||||
<emphasis>backup catalog</emphasis>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>db_host</literal> is the system with <productname>PostgreSQL</productname>
|
||||
cluster.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>backup</literal> is the OS user on
|
||||
<literal>backup_host</literal> used to run <application>pg_probackup</application>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>postgres</literal> is the user on
|
||||
<literal>postgres_host</literal> under which
|
||||
<productname>PostgreSQL</productname> cluster processes are running.
|
||||
For <productname>PostgreSQL</productname> 11 or higher a
|
||||
more secure approach can be used thanks to
|
||||
<ulink url="https://postgrespro.com/docs/postgresql/current/app-initdb.html#APP-INITDB-ALLOW-GROUP-ACCESS">allow-group-access</ulink> feature.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
If you are going to rely on
|
||||
<link linkend="pbk-setting-up-continuous-wal-archiving">continuous
|
||||
WAL archiving</link>, set up passwordless SSH
|
||||
connection between <literal>postgres</literal> user on
|
||||
<literal>db_host</literal> and <literal>backup</literal>
|
||||
WAL archiving</link>, set up a passwordless SSH
|
||||
connection between the <literal>postgres</literal> user on
|
||||
<literal>db_host</literal> and the <literal>backup</literal>
|
||||
user on <literal>backup_host</literal>:
|
||||
</para>
|
||||
<programlisting>
|
||||
[postgres@db_host] ssh-copy-id backup@backup_host
|
||||
</programlisting>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<para>
|
||||
where:
|
||||
</para>
|
||||
<itemizedlist spacing="compact">
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>backup_host</literal> is the system with
|
||||
<emphasis>backup catalog</emphasis>.
|
||||
Make sure <application>pg_probackup</application> on <literal>postgres_host</literal>
|
||||
can be located when a connection via SSH is made. For example, for <application>Bash</application>, you can
|
||||
modify <literal>PATH</literal> in <filename>~/.bashrc</filename> of the <literal>backup</literal> user.
|
||||
Alternatively, for <application>pg_probackup</application> commands, specify the path to the directory
|
||||
containing the <application>pg_probackup</application> binary on <literal>postgres_host</literal> via
|
||||
the <link linkend="pbk-remote-server-opts">--remote-path</link> option.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>db_host</literal> is the system with <productname>PostgreSQL</productname>
|
||||
cluster.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>backup</literal> is the OS user on
|
||||
<literal>backup_host</literal> used to run <application>pg_probackup</application>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>postgres</literal> is the OS user on
|
||||
<literal>db_host</literal> used to start the <productname>PostgreSQL</productname>
|
||||
cluster. For <productname>PostgreSQL</productname> 11 or higher a
|
||||
more secure approach can be used thanks to
|
||||
<ulink url="https://postgrespro.com/docs/postgresql/current/app-initdb.html#APP-INITDB-ALLOW-GROUP-ACCESS">allow-group-access</ulink>
|
||||
feature.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</orderedlist>
|
||||
<para>
|
||||
<application>pg_probackup</application> in the remote mode via SSH works
|
||||
as follows:
|
||||
@@ -1763,7 +2055,7 @@ pg_probackup validate -B <replaceable>backup_dir</replaceable> --instance <repla
|
||||
pg_probackup restore -B <replaceable>backup_dir</replaceable> --instance <replaceable>instance_name</replaceable> -i <replaceable>backup_id</replaceable>
|
||||
</programlisting>
|
||||
<para>
|
||||
where:
|
||||
Where:
|
||||
</para>
|
||||
<itemizedlist spacing="compact">
|
||||
<listitem>
|
||||
@@ -5935,257 +6227,6 @@ pg_probackup catchup -b <replaceable>catchup_mode</replaceable>
|
||||
</refsect2>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id="pbk-howto">
|
||||
<title>How-To</title>
|
||||
<para>
|
||||
All examples below assume the remote mode of operations via
|
||||
SSH. If you are planning to run backup and
|
||||
restore operation locally, skip the
|
||||
<quote>Setup passwordless SSH connection</quote> step
|
||||
and omit all <option>--remote-*</option> options.
|
||||
</para>
|
||||
<para>
|
||||
Examples are based on <productname>Ubuntu</productname> 18.04,
|
||||
<productname>PostgreSQL</productname> 11, and <application>pg_probackup</application>
|
||||
2.2.0.
|
||||
</para>
|
||||
<itemizedlist spacing="compact">
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>backup</literal> — <productname>PostgreSQL</productname>
|
||||
role used for connection to <productname>PostgreSQL</productname>
|
||||
cluster.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>backupdb</literal> — database used for connection
|
||||
to <productname>PostgreSQL</productname> cluster.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>backup_host</literal> — host with backup catalog.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>backupman</literal> — user on
|
||||
<literal>backup_host</literal> running all <application>pg_probackup</application>
|
||||
operations.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<filename>/mnt/backups</filename> — directory on
|
||||
<literal>backup_host</literal> where backup catalog is stored.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>postgres_host</literal> — host with <productname>PostgreSQL</productname>
|
||||
cluster.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal>postgres</literal> — user on
|
||||
<literal>postgres_host</literal> that has started the <productname>PostgreSQL</productname> cluster.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<filename>/var/lib/postgresql/11/main</filename> — <productname>PostgreSQL</productname>
|
||||
data directory on <literal>postgres_host</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<refsect2 id="pbk-minimal-setup">
|
||||
<title>Minimal Setup</title>
|
||||
<para>
|
||||
This scenario illustrates setting up standalone FULL and DELTA backups.
|
||||
</para>
|
||||
<procedure>
|
||||
<step id="pbk-setup-passwordless-ssh-connection-from-backup-host-to-postgres-host">
|
||||
<title>Set up passwordless SSH connection from
|
||||
<literal>backup_host</literal> to
|
||||
<literal>postgres_host</literal>:</title>
|
||||
<programlisting>
|
||||
[backupman@backup_host] ssh-copy-id postgres@postgres_host
|
||||
</programlisting>
|
||||
</step>
|
||||
<step id="pbk-setup-postgresql-cluster">
|
||||
<title>Configure your <productname>PostgreSQL</productname> cluster.</title>
|
||||
<para>
|
||||
For security purposes, it is recommended to use a separate
|
||||
database for backup operations.
|
||||
</para>
|
||||
<programlisting>
|
||||
postgres=#
|
||||
CREATE DATABASE backupdb;
|
||||
</programlisting>
|
||||
<para>
|
||||
Connect to the <literal>backupdb</literal> database, create the
|
||||
<literal>probackup</literal> role, and grant the following
|
||||
permissions to this role:
|
||||
</para>
|
||||
<programlisting>
|
||||
backupdb=#
|
||||
BEGIN;
|
||||
CREATE ROLE backup WITH LOGIN REPLICATION;
|
||||
GRANT USAGE ON SCHEMA pg_catalog TO backup;
|
||||
GRANT EXECUTE ON FUNCTION pg_catalog.current_setting(text) TO backup;
|
||||
GRANT EXECUTE ON FUNCTION pg_catalog.set_config(text, text, boolean) TO backup;
|
||||
GRANT EXECUTE ON FUNCTION pg_catalog.pg_is_in_recovery() TO backup;
|
||||
GRANT EXECUTE ON FUNCTION pg_catalog.pg_start_backup(text, boolean, boolean) TO backup;
|
||||
GRANT EXECUTE ON FUNCTION pg_catalog.pg_stop_backup(boolean, boolean) TO backup;
|
||||
GRANT EXECUTE ON FUNCTION pg_catalog.pg_create_restore_point(text) TO backup;
|
||||
GRANT EXECUTE ON FUNCTION pg_catalog.pg_switch_wal() TO backup;
|
||||
GRANT EXECUTE ON FUNCTION pg_catalog.pg_last_wal_replay_lsn() TO backup;
|
||||
GRANT EXECUTE ON FUNCTION pg_catalog.txid_current() TO backup;
|
||||
GRANT EXECUTE ON FUNCTION pg_catalog.txid_current_snapshot() TO backup;
|
||||
GRANT EXECUTE ON FUNCTION pg_catalog.txid_snapshot_xmax(txid_snapshot) TO backup;
|
||||
GRANT EXECUTE ON FUNCTION pg_catalog.pg_control_checkpoint() TO backup;
|
||||
COMMIT;
|
||||
</programlisting>
|
||||
</step>
|
||||
<step id="pbk-init-the-backup-catalog">
|
||||
<title>Initialize the backup catalog:</title>
|
||||
<programlisting>
|
||||
[backupman@backup_host]$ pg_probackup-11 init -B /mnt/backups
|
||||
INFO: Backup catalog '/mnt/backups' successfully inited
|
||||
</programlisting>
|
||||
</step>
|
||||
<step id="pbk-add-instance-pg-11-to-backup-catalog">
|
||||
<title>Add instance <literal>pg-11</literal> to the backup catalog:</title>
|
||||
<programlisting>
|
||||
[backupman@backup_host]$ pg_probackup-11 add-instance -B /mnt/backups --instance pg-11 --remote-host=postgres_host --remote-user=postgres -D /var/lib/postgresql/11/main
|
||||
INFO: Instance 'node' successfully inited
|
||||
</programlisting>
|
||||
</step>
|
||||
<step id="pbk-take-full-backup">
|
||||
<title>Take a FULL backup:</title>
|
||||
<programlisting>
|
||||
[backupman@backup_host] pg_probackup-11 backup -B /mnt/backups --instance pg-11 -b FULL --stream --remote-host=postgres_host --remote-user=postgres -U backup -d backupdb
|
||||
INFO: Backup start, pg_probackup version: 2.2.0, instance: node, backup ID: PZ7YK2, backup mode: FULL, wal mode: STREAM, remote: true, compress-algorithm: none, compress-level: 1
|
||||
INFO: Start transferring data files
|
||||
INFO: Data files are transferred
|
||||
INFO: wait for pg_stop_backup()
|
||||
INFO: pg_stop backup() successfully executed
|
||||
INFO: Validating backup PZ7YK2
|
||||
INFO: Backup PZ7YK2 data files are valid
|
||||
INFO: Backup PZ7YK2 resident size: 196MB
|
||||
INFO: Backup PZ7YK2 completed
|
||||
</programlisting>
|
||||
</step>
|
||||
<step id="pbk-lets-take-a-look-at-the-backup-catalog">
|
||||
<title>Let's take a look at the backup catalog:</title>
|
||||
<programlisting>
|
||||
[backupman@backup_host] pg_probackup-11 show -B /mnt/backups --instance pg-11
|
||||
|
||||
BACKUP INSTANCE 'pg-11'
|
||||
==================================================================================================================================
|
||||
Instance Version ID Recovery Time Mode WAL Mode TLI Time Data WAL Zratio Start LSN Stop LSN Status
|
||||
==================================================================================================================================
|
||||
node 11 PZ7YK2 2019-10-11 19:45:45+03 FULL STREAM 1/0 11s 180MB 16MB 1.00 0/3C000028 0/3C000198 OK
|
||||
</programlisting>
|
||||
</step>
|
||||
<step id="pbk-take-incremental-backup-in-delta-mode">
|
||||
<title>Take an incremental backup in the DELTA mode:</title>
|
||||
<programlisting>
|
||||
[backupman@backup_host] pg_probackup-11 backup -B /mnt/backups --instance pg-11 -b delta --stream --remote-host=postgres_host --remote-user=postgres -U backup -d backupdb
|
||||
INFO: Backup start, pg_probackup version: 2.2.0, instance: node, backup ID: PZ7YMP, backup mode: DELTA, wal mode: STREAM, remote: true, compress-algorithm: none, compress-level: 1
|
||||
INFO: Parent backup: PZ7YK2
|
||||
INFO: Start transferring data files
|
||||
INFO: Data files are transferred
|
||||
INFO: wait for pg_stop_backup()
|
||||
INFO: pg_stop backup() successfully executed
|
||||
INFO: Validating backup PZ7YMP
|
||||
INFO: Backup PZ7YMP data files are valid
|
||||
INFO: Backup PZ7YMP resident size: 32MB
|
||||
INFO: Backup PZ7YMP completed
|
||||
</programlisting>
|
||||
</step>
|
||||
<step id="pbk-lets-hide-some-parameters-into-config-so-cmdline-can-be-less-crowdy">
|
||||
<title>Let's add some parameters to <application>pg_probackup</application>
|
||||
configuration file, so that you can omit them from the command line:</title>
|
||||
<programlisting>
|
||||
[backupman@backup_host] pg_probackup-11 set-config -B /mnt/backups --instance pg-11 --remote-host=postgres_host --remote-user=postgres -U backup -d backupdb
|
||||
</programlisting>
|
||||
</step>
|
||||
<step id="pbk-take-another-incremental-backup-in-delta-mode-omitting-some-of-the-previous-parameters">
|
||||
<title>Take another incremental backup in the DELTA mode, omitting
|
||||
some of the previous parameters:</title>
|
||||
<programlisting>
|
||||
[backupman@backup_host] pg_probackup-11 backup -B /mnt/backups --instance pg-11 -b delta --stream
|
||||
INFO: Backup start, pg_probackup version: 2.2.0, instance: node, backup ID: PZ7YR5, backup mode: DELTA, wal mode: STREAM, remote: true, compress-algorithm: none, compress-level: 1
|
||||
INFO: Parent backup: PZ7YMP
|
||||
INFO: Start transferring data files
|
||||
INFO: Data files are transferred
|
||||
INFO: wait for pg_stop_backup()
|
||||
INFO: pg_stop backup() successfully executed
|
||||
INFO: Validating backup PZ7YR5
|
||||
INFO: Backup PZ7YR5 data files are valid
|
||||
INFO: Backup PZ7YR5 resident size: 32MB
|
||||
INFO: Backup PZ7YR5 completed
|
||||
</programlisting>
|
||||
</step>
|
||||
<step id="pbk-lets-take-a-look-at-instance-config">
|
||||
<title>Let's take a look at the instance configuration:</title>
|
||||
<programlisting>
|
||||
[backupman@backup_host] pg_probackup-11 show-config -B /mnt/backups --instance pg-11
|
||||
|
||||
# Backup instance information
|
||||
pgdata = /var/lib/postgresql/11/main
|
||||
system-identifier = 6746586934060931492
|
||||
xlog-seg-size = 16777216
|
||||
# Connection parameters
|
||||
pgdatabase = backupdb
|
||||
pghost = postgres_host
|
||||
pguser = backup
|
||||
# Archive parameters
|
||||
archive-timeout = 5min
|
||||
# Logging parameters
|
||||
log-level-console = INFO
|
||||
log-level-file = OFF
|
||||
log-format-console = PLAIN
|
||||
log-format-file = PLAIN
|
||||
log-filename = pg_probackup.log
|
||||
log-rotation-size = 0
|
||||
log-rotation-age = 0
|
||||
# Retention parameters
|
||||
retention-redundancy = 0
|
||||
retention-window = 0
|
||||
wal-depth = 0
|
||||
# Compression parameters
|
||||
compress-algorithm = none
|
||||
compress-level = 1
|
||||
# Remote access parameters
|
||||
remote-proto = ssh
|
||||
remote-host = postgres_host
|
||||
</programlisting>
|
||||
<para>
|
||||
Note that we are getting the default values for other options
|
||||
that were not overwritten by the <command>set-config</command> command.
|
||||
</para>
|
||||
</step>
|
||||
<step id="pbk-lets-take-a-look-at-the-backup-catalog-1">
|
||||
<title>Let's take a look at the backup catalog:</title>
|
||||
<programlisting>
|
||||
[backupman@backup_host] pg_probackup-11 show -B /mnt/backups --instance pg-11
|
||||
|
||||
====================================================================================================================================
|
||||
Instance Version ID Recovery Time Mode WAL Mode TLI Time Data WAL Zratio Start LSN Stop LSN Status
|
||||
====================================================================================================================================
|
||||
node 11 PZ7YR5 2019-10-11 19:49:56+03 DELTA STREAM 1/1 10s 112kB 32MB 1.00 0/41000028 0/41000160 OK
|
||||
node 11 PZ7YMP 2019-10-11 19:47:16+03 DELTA STREAM 1/1 10s 376kB 32MB 1.00 0/3E000028 0/3F0000B8 OK
|
||||
node 11 PZ7YK2 2019-10-11 19:45:45+03 FULL STREAM 1/0 11s 180MB 16MB 1.00 0/3C000028 0/3C000198 OK
|
||||
</programlisting>
|
||||
</step>
|
||||
</procedure>
|
||||
</refsect2>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id="pbk-versioning">
|
||||
<title>Versioning</title>
|
||||
<para>
|
||||
|
Reference in New Issue
Block a user