Skip to content

Commit

Permalink
Add notes to take a backup at standby-site (#223)
Browse files Browse the repository at this point in the history
* Add notes to take a backup at standby-site

* Unify 'standby site' to 'standby-site'

Co-authored-by: Masahiro Ikeda <[email protected]>
  • Loading branch information
2 people authored and huangfumingyue committed Sep 2, 2022
1 parent 1071b19 commit 6684b4e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
24 changes: 19 additions & 5 deletions docs/index-ja.html
Original file line number Diff line number Diff line change
Expand Up @@ -390,19 +390,33 @@ <h3>削除済みバックアップの消去</h3>

<h3>スタンバイサイトでのバックアップ</h3>

<p>PostgreSQL 9.0 以降のレプリケーションを利用している場合、スタンバイサイトでバックアップを取得することができます。</p>
<p>PostgreSQL 9.0 以降のレプリケーションを利用している場合、スタンバイサイトでもバックアップを取得することができます。
基本的な使用方法は、単体の PostgreSQL で利用する場合と同様なので、注意が必要な点のみ記述します。</p>

<p>スタンバイサイトでのバックアップを行うためには、通常の pg_rman の利用方法と異なるオプションを指定する必要があります。
<p>スタンバイサイトでバックアップを取得する場合もアーカイブWALをバックアップ対象にする必要があります。
共有ディスクなどを用意し、マスタのアーカイブ領域をスタンバイからも参照できるような構成か、
archive_modeを 'always' として、スタンバイサイトでもアーカイブを出力するような構成にしてください。
</p>

<p>スタンバイサイトで pg_rman を用いたバックアップを行う使用例を示します。 基本的な使用方法は、単体の PostgreSQL で利用する場合と同様なので、注意が必要な点のみ記述します。</p>
<p>後者の構成の場合は、スタンバイ構築時にプライマリに存在するアーカイブWAL(historyファイルを含む)を同期して、
リストアに必要なファイルを漏れなく、バックアップ出来るようにしてください。また、--keep-arclog-files / --keep-arclog-daysを
利用することでバックアップ時に古いアーカイブを削除することが可能ですが、バックアップ取得対象ではないアーカイブ領域は、
削除対象にならない点に注意してください。そのため、スタンバイサイトでバックアップを取得する場合は、本オプションを利用しても、
マスタの古いアーカイブを削除することはできません。
</p>

<p>まず、バックアップカタログの初期化についてです。 <code>-D</code>/<code>--pgdata</code> で指定するものは、スタンバイのデータベースクラスタへのパスとなります。</p>
<p>バックアップカタログの初期化時には、<code>-D</code>/<code>--pgdata</code> で、
スタンバイのデータベースクラスタへのパスを指定してください。</p>

<pre><code>$ pg_rman init -B &lt;バックアップカタログパス&gt; -D &lt;(スタンバイの)PostgreSQLのデータベースクラスタパス&gt;
</code></pre>

<p>スタンバイサイトでバックアップを取得するには、<code>-D</code>/<code>--pgdata</code> オプションでスタンバイサイトのデータベースクラスタを指定し、その他の接続オプション(<code>-d</code>/<code>--dbname</code><code>-h</code>/<code>--host</code><code>-p</code>/<code>--port</code> など)でマスタサイトの設定情報を指定します。 スタンバイ接続オプション (<code>--standby-host</code><code>--standby-port</code>) でスタンバイサイトの設定情報を指定します。<code>--standby-host</code><code>--standby-port</code> は両方とも指定する必要があります。</p>
<p>スタンバイサイトでのバックアップを行うためには、通常の pg_rman の利用方法と異なるオプションを指定する必要があります。
スタンバイサイトでバックアップを取得するには、<code>-D</code>/<code>--pgdata</code> オプションでスタンバイサイトの
データベースクラスタを指定し、その他の接続オプション(<code>-d</code>/<code>--dbname</code><code>-h</code>/<code>--host</code>
<code>-p</code>/<code>--port</code> など)でマスタサイトの設定情報を指定します。 スタンバイ接続オプション
(<code>--standby-host</code><code>--standby-port</code>) でスタンバイサイトの設定情報を指定します。<code>--standby-host</code>
<code>--standby-port</code> は両方とも指定する必要があります。</p>

<p>以下の環境において、スタンバイサイトからバックアップを取得する際のコマンド例を示します。</p>

Expand Down
27 changes: 23 additions & 4 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,28 @@ <h2>Remove deleted backups</h2>

<h2 id="Standby-site.Backup">Standby-site Backup</h2>

<p>If you use replication feature on PostgreSQL 9.0 later, you can get backup from standby-site.</p>
<p>If you use replication feature on PostgreSQL 9.0 later, you can get backup from standby-site.
The basic usage is the same as when using it with a single master server, so only the points that
need attention are described.
</p>

<p>Archive WALs must also be taken when you take a backup of the standby-site.
So, you need to prepare a shared disk and so on so that the archive area of the master can be
accessed from the standby, or set archive_mode to 'always' at the standby-site.
</p>

<p>In the latter case, copy the primary's archive WALs (including history file)
when the standby-site is created to make sure that you can take back up all the files required for restoring.
You can delete old archive WALs at the time of backup using --keep-arclog-files / --keep-arclog-days.
But, since the deletion target is only the one which it take a backup, the master's archived WALs
are not deleted if you take a backup at standby-site.
</p>

<p>You should specify different options from usual use for getting backup from standby-site. In detail, you should specify the database cluster on standby-site by <code>-D</code>/<code>--pgdata</code> option. And you should specify information on master-site by connection options (<code>-d</code>/<code>--dbname</code>, <code>-h</code>/<code>--host</code>, <code>-p</code>/<code>--port</code>). In addition, you should specify information to connect standby-site by standby connection options (<code>--standby-host</code>, <code>--standby-port</code>).</p>
<p>You should specify different options from usual use for getting backup from standby-site.
In detail, you should specify the database cluster on standby-site by <code>-D</code>/<code>--pgdata</code> option.
And you should specify information on master-site by connection options (<code>-d</code>/<code>--dbname</code>,
<code>-h</code>/<code>--host</code>, <code>-p</code>/<code>--port</code>). In addition, you should specify information
to connect standby-site by standby connection options (<code>--standby-host</code>, <code>--standby-port</code>).</p>

<pre><code>$ pg_rman init -B &lt;a backup catalog path&gt; -D &lt;(the database cluster path(on standby-site)&gt;
</code></pre>
Expand All @@ -396,7 +415,7 @@ <h2 id="Standby-site.Backup">Standby-site Backup</h2>
<li>the database cluster path of standby-site: /home/postgres/pgdata_sby</li>
</ul>

<p>Then, the backup from standby site can be done with the below command:</p>
<p>Then, the backup from standby-site can be done with the below command:</p>

<pre><code>$ pg_rman backup --pgdata=/home/postgres/pgdata_sby --backup-mode=full --host=master --standby-host=localhost --standby-port=5432
</code></pre>
Expand Down Expand Up @@ -744,7 +763,7 @@ <h2>Connection options</h2>

<h2>Standby connection options</h2>

<p>Parameters to connect standby server. They are used only when you get backup from the standby site.</p>
<p>Parameters to connect standby server. They are used only when you get backup from the standby-site.</p>

<ul>
<li><strong><code>--standby-host</code></strong>
Expand Down

0 comments on commit 6684b4e

Please sign in to comment.