バージョンごとのドキュメント一覧

pg_dumpall

pg_dumpall <refpurpose>extract a <productname>PostgreSQL</productname> database cluster into a script file</refpurpose> PostgreSQLのデータベースクラスタをスクリプトファイルへ抽出する

概要

pg_dumpall [connection-option...] [option...]

説明

<title>Description</title>

<application>pg_dumpall</application> is a utility for writing out (<quote>dumping</quote>) all <productname>PostgreSQL</productname> databases of a cluster into one script file. The script file contains <acronym>SQL</acronym> commands that can be used as input to <xref linkend="app-psql"/> to restore the databases. It does this by calling <xref linkend="app-pgdump"/> for each database in the cluster. <application>pg_dumpall</application> also dumps global objects that are common to all databases, namely database roles, tablespaces, and privilege grants for configuration parameters. (<application>pg_dump</application> does not save these objects.) pg_dumpallはクラスタの全てのPostgreSQLデータベースを、1つのスクリプトファイルに書き出す(ダンプする)ためのユーティリティです。 スクリプトファイルには、データベースのリストアのためにpsqlへの入力として使うことのできるSQLコマンドが含まれています。 これはクラスタ内の各データベースに対してpg_dumpを呼び出すことで行われます。 さらに、pg_dumpallは、全てのデータベースに共通するグローバルオブジェクト、すなわちデータベースロール、テーブル空間、および権限パラメータに対する設定許可をダンプします。 (pg_dumpはこれらのオブジェクトを保存しません)。

Since <application>pg_dumpall</application> reads tables from all databases you will most likely have to connect as a database superuser in order to produce a complete dump. Also you will need superuser privileges to execute the saved script in order to be allowed to add roles and create databases. pg_dumpallは全てのデータベースからテーブルを読み込むため、完全なダンプを作成するには、おそらくデータベーススーパーユーザとして接続する必要がある可能性が高いでしょう。 さらに、保存されたスクリプトを実行する時には、ロールを追加したり、データベースを作成したりするので、スーパーユーザ権限が必要になるでしょう。

The SQL script will be written to the standard output. Use the <option>-f</option>/<option>&#45;-file</option> option or shell operators to redirect it into a file. SQLスクリプトは標準出力に書き込まれます。 それをファイルにリダイレクトするためには、-f/--fileオプションまたはシェルの演算子を使用して下さい。

<application>pg_dumpall</application> needs to connect several times to the <productname>PostgreSQL</productname> server (once per database). If you use password authentication it will ask for a password each time. It is convenient to have a <filename>~/.pgpass</filename> file in such cases. See <xref linkend="libpq-pgpass"/> for more information. pg_dumpallは、PostgreSQLサーバに何度か接続しなければなりません(データベースごとに接続することになります)。 パスワード認証を使用している場合、その度にパスワード入力が促されます。 そのような場合は~/.pgpassファイルを用意しておくと便利です。 詳細は34.16を参照してください。

オプション

<title>Options</title>

The following command-line options control the content and format of the output. 以下のコマンドラインオプションは出力内容や形式を制御します。

-a
--data-only

Dump only the data, not the schema (data definitions). データのみをダンプし、スキーマ(データ定義)をダンプしません。

-c
--clean

Include SQL commands to clean (drop) databases before recreating them. <command>DROP</command> commands for roles and tablespaces are added as well. データベースを再作成するコマンドの前に、データベースのクリーンアップ(削除)するコマンドを書き出します。 ロールおよびテーブル空間用のDROPコマンドも同様に追加されます。

-E encoding
--encoding=encoding

Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the <envar>PGCLIENTENCODING</envar> environment variable to the desired dump encoding.) 指定された文字エンコーディングでダンプを作ります。 デフォルトでは、ダンプはデータベースエンコーディングで作られます。 (同じ結果を得る他の方法はPGCLIENTENCODING環境変数を望みのダンプエンコーディングに設定することです。)

-f filename
--file=filename

Send output to the specified file. If this is omitted, the standard output is used. 出力を指定したファイルに送ります。 これが省略されると標準出力が使用されます。

-g
--globals-only

Dump only global objects (roles and tablespaces), no databases. グローバルオブジェクト(ロールとテーブル空間)のみをダンプし、データベースのダンプを行いません。

-O
--no-owner

Do not output commands to set ownership of objects to match the original database. By default, <application>pg_dumpall</application> issues <command>ALTER OWNER</command> or <command>SET SESSION AUTHORIZATION</command> statements to set ownership of created schema elements. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify <option>-O</option>. オブジェクトの所有権を元のデータベースに一致させるためのコマンドを出力しません。 デフォルトでは、pg_dumpallALTER OWNER文またはSET SESSION AUTHORIZATION文を発行して作成したスキーマ要素の所有権を設定します。 スーパーユーザ(もしくは、スクリプト内の全てのオブジェクトを所有するユーザ)以外のユーザがスクリプトを実行した場合、これらの文は失敗します。 任意のユーザがリストアできるスクリプトを作成するには、-Oを指定してください。ただし、この場合は、全てのオブジェクトの所有者がリストアしたユーザとなってしまいます。

-r
--roles-only

Dump only roles, no databases or tablespaces. ロールのみをダンプし、データベースやテーブル空間のダンプを行いません。

-s
--schema-only

Dump only the object definitions (schema), not data. オブジェクト定義(スキーマ)のみをダンプし、データをダンプしません。

-S username
--superuser=username

Specify the superuser user name to use when disabling triggers. This is relevant only if <option>&#45;-disable-triggers</option> is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.) トリガを無効にする際に使用するスーパーユーザのユーザ名を指定します。 これは--disable-triggersを使用する場合にのみ使用されます (通常はこのオプションを使うよりも、出力されたスクリプトをスーパーユーザ権限で実行する方が良いでしょう)。

-t
--tablespaces-only

Dump only tablespaces, no databases or roles. テーブル空間のみをダンプし、データベースやロールのダンプを行いません。

-v
--verbose

Specifies verbose mode. This will cause <application>pg_dumpall</application> to output start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error. The option is also passed down to <application>pg_dump</application>. 冗長モードを指定します。 これを指定すると、pg_dumpallは開始時刻と終了時刻をダンプファイルに、進行メッセージを標準エラーに出力するようになります。 オプションを繰り返すと、追加のデバッグレベルメッセージが標準エラーに現れます。 このオプションはpg_dumpにも渡されます。

-V
--version

Print the <application>pg_dumpall</application> version and exit. pg_dumpallのバージョンを表示し、終了します。

-x
--no-privileges
--no-acl

Prevent dumping of access privileges (grant/revoke commands). アクセス権限のダンプ(grant/revokeコマンド)を行いません。

--binary-upgrade

This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice. このオプションは現位置でのアップグレード用のユーティリティにより使用されるものです。 他の目的での使用は推奨されませんし、サポートもされません。 このオプションの動作は、将来通知することなく変更される可能性があります。

--column-inserts
--attribute-inserts

Dump data as <command>INSERT</command> commands with explicit column names (<literal>INSERT INTO <replaceable>table</replaceable> (<replaceable>column</replaceable>, ...) VALUES ...</literal>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<productname>PostgreSQL</productname> databases. 明示的に列名を付けたINSERTコマンド(INSERT INTO table (column, ...) VALUES...)としてダンプします。 これによりリストアは非常に遅くなります。 主に、PostgreSQL以外のデータベースにロード可能なダンプを作成する時に有用です。

--disable-dollar-quoting

This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax. このオプションは、関数本体用のドル引用符の使用を無効にし、強制的に標準SQLの文字列構文を使用した引用符付けを行います。

--disable-triggers

This option is relevant only when creating a data-only dump. It instructs <application>pg_dumpall</application> to include commands to temporarily disable triggers on the target tables while the data is restored. Use this if you have referential integrity checks or other triggers on the tables that you do not want to invoke during data restore. このオプションは、データのみのダンプを作成する場合だけに使用します。 データのリストア中に、対象とするテーブル上のトリガを一時的に使用不可にするためのコマンドを出力するようpg_dumpallに指示します。 このオプションは、データのリストア中には呼び出したくない参照整合性検査やその他のトリガがテーブル上にある場合に使用します。

Presently, the commands emitted for <option>&#45;-disable-triggers</option> must be done as superuser. So, you should also specify a superuser name with <option>-S</option>, or preferably be careful to start the resulting script as a superuser. 現在のところ、--disable-triggersを指定してコマンドを実行するのは、スーパーユーザでなければなりません。 そのため、-Sでスーパーユーザの名前を指定するか、あるいは、可能であれば、スーパーユーザ権限でスクリプトを開始するよう注意する必要があります。

--exclude-database=pattern

Do not dump databases whose name matches <replaceable class="parameter">pattern</replaceable>. Multiple patterns can be excluded by writing multiple <option>&#45;-exclude-database</option> switches. The <replaceable class="parameter">pattern</replaceable> parameter is interpreted as a pattern according to the same rules used by <application>psql</application>'s <literal>\d</literal> commands (see <xref linkend="app-psql-patterns"/>), so multiple databases can also be excluded by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent shell wildcard expansion. 名前がpatternにマッチするデータベースをダンプしません。 複数の--exclude-databaseオプションを記述することで複数のパターンを除外できます。 patternパラメータはpsql\dコマンドで使用される規則(パターン参照)と同じ規則に従うパターンとして解釈されます。ですので、ワイルドカード文字をパターン内に記述することで、複数のデータベースを除外することもできます。 ワイルドカードを使用する時は、シェルによりそのワイルドカードを展開させないように、パターンを引用符で括ってください。

--extra-float-digits=ndigits

Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option. 浮動小数点データをダンプする時に、利用できる最大の精度の代わりに、extra_float_digitsで指定された値を使います。 バックアップ目的で作られたダンプルーチンは、このオプションを使うべきではありません。

--if-exists

Use conditional commands (i.e., add an <literal>IF EXISTS</literal> clause) to drop databases and other objects. This option is not valid unless <option>&#45;-clean</option> is also specified. データベースおよび他のオブジェクトを初期化するときに、条件コマンドを使います(つまりIF EXISTS句を追加します)。 このオプションは、--cleanも指定されているのでなければ、有効にはなりません。

--inserts

Dump data as <command>INSERT</command> commands (rather than <command>COPY</command>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<productname>PostgreSQL</productname> databases. Note that the restore might fail altogether if you have rearranged column order. The <option>&#45;-column-inserts</option> option is safer, though even slower. データを(COPYではなく)INSERTコマンドとしてダンプします。 これを行うとリストアが非常に遅くなります。 主にPostgreSQL以外のデータベースにロード可能なダンプを作成する時に有用です。 列の順序を変更した場合はリストアが失敗する可能性があることに注意してください。 さらに低速になりますが、--column-insertsオプションの方が安全です。

--load-via-partition-root

When dumping data for a table partition, make the <command>COPY</command> or <command>INSERT</command> statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column. テーブルパーティションに対するデータをダンプするとき、COPYINSERT文をパーティション自体ではなく、それを含むパーティション階層のルートに向けさせます。 これにより、データが読み込まれるときに各行に対して適切なパーティションが再判断されるようになります。 これは、行が必ずしも元のサーバと同じパーティションに落ちないようなサーバにデータをリストアするときに有用でしょう。 例えば、パーティション列がtext型で二つのシステムがパーティション列をソートするのに使われる照合順序の異なった定義を持っている場合に、これは起こりえることです。

--lock-wait-timeout=timeout

Do not wait forever to acquire shared table locks at the beginning of the dump. Instead, fail if unable to lock a table within the specified <replaceable class="parameter">timeout</replaceable>. The timeout may be specified in any of the formats accepted by <command>SET statement_timeout</command>. ダンプ開始時に共有テーブルロックの獲得のために永遠に待機しません。 指定したtimeoutの間にテーブルをロックすることができない場合は失敗します。 タイムアウトはSET statement_timeoutで受け付けられる任意の書式で指定できます。

--no-comments

Do not dump comments. コメントをダンプしません。

--no-publications

Do not dump publications. パブリケーションをダンプしません。

--no-role-passwords

Do not dump passwords for roles. When restored, roles will have a null password, and password authentication will always fail until the password is set. Since password values aren't needed when this option is specified, the role information is read from the catalog view <structname>pg_roles</structname> instead of <structname>pg_authid</structname>. Therefore, this option also helps if access to <structname>pg_authid</structname> is restricted by some security policy. ロールのパスワードをダンプしません。 リストア時にロールのパスワードはNULLになるため、パスワードが設定されるまでは、パスワード認証は常に失敗します。 このオプションが指定された場合、パスワードの値が不要となるので、ロール情報はpg_authidではなく、カタログビューのpg_rolesから読み取られます。 従って、pg_authidへのアクセスが何らかのセキュリティーポリシーによって制限されている場合にも、このオプションは役立ちます。

--no-security-labels

Do not dump security labels. セキュリティラベルをダンプしません。

--no-subscriptions

Do not dump subscriptions. サブスクリプションをダンプしません。

--no-sync

By default, <command>pg_dumpall</command> will wait for all files to be written safely to disk. This option causes <command>pg_dumpall</command> to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation. デフォルトでは、pg_dumpallはすべてのファイルが確実にディスクに書き込まれるまで待機します。 このオプションを使うとpg_dumpallは待機せずに戻るため、より高速になりますが、これは、その後にオペレーティングシステムがクラッシュすると、ダンプが破損する可能性があることを意味します。 一般的に言って、このオプションはテスト用には有用ですが、実運用の環境からデータをダンプするときには使用しないほうが良いでしょう。

--no-table-access-method

Do not output commands to select table access methods. With this option, all objects will be created with whichever table access method is the default during restore. セレクトテーブルアクセスメソッドにコマンドを出力しません。 このオプションを使用すると、リストア中にどのテーブルアクセスメソッドがデフォルトであっても、すべてのオブジェクトが作成されます。

--no-tablespaces

Do not output commands to create tablespaces nor select tablespaces for objects. With this option, all objects will be created in whichever tablespace is the default during restore. オブジェクト用にテーブル空間を作成または選択するコマンドを出力しません。 このオプションを付けると、すべてのオブジェクトはリストア時のデフォルトのテーブル空間内に作成されます。

--no-toast-compression

Do not output commands to set <acronym>TOAST</acronym> compression methods. With this option, all columns will be restored with the default compression setting. TOAST圧縮手法を設定するコマンドを出力しません。 このオプションにより、列はすべてデフォルトの圧縮の設定でリストアされます。

--no-unlogged-table-data

Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. ログを取らないテーブルの内容をダンプしません。 このオプションはテーブル定義(スキーマ)をダンプするかどうかには影響しません。 そのテーブルデータのダンプを抑制するだけです。

--on-conflict-do-nothing

Add <literal>ON CONFLICT DO NOTHING</literal> to <command>INSERT</command> commands. This option is not valid unless <option>&#45;-inserts</option> or <option>&#45;-column-inserts</option> is also specified. INSERTコマンドにON CONFLICT DO NOTHINGを追加します。 このオプションは、--insertsまたは--column-insertsが同時に指定されていなければ、有効ではありません。

--quote-all-identifiers

Force quoting of all identifiers. This option is recommended when dumping a database from a server whose <productname>PostgreSQL</productname> major version is different from <application>pg_dumpall</application>'s, or when the output is intended to be loaded into a server of a different major version. By default, <application>pg_dumpall</application> quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using <option>&#45;-quote-all-identifiers</option> prevents such issues, at the price of a harder-to-read dump script. 強制的にすべての識別子に引用符を付与します。 このオプションは、pg_dumpallのメジャーバージョンとは異なるメジャーバージョンのPostgreSQLのサーバーからデータベースをダンプするとき、あるいは出力を異なるメジャーバージョンのサーバにロードする予定であるときに推奨されます。 デフォルトでは、pg_dumpallは、それ自身のメジャーバージョンにおける予約語である識別子に対してのみ引用符を付与します。 これは、他のバージョンのサーバを処理するときに互換性の問題を引き起こす場合があります。 他のバージョンのサーバでは予約語の集合が多少、異なる場合があるからです。 --quote-all-identifiersを使用することで、ダンプのスクリプトが読みにくくなりますが、このような問題を防ぐことができます。

--rows-per-insert=nrows

Dump data as <command>INSERT</command> commands (rather than <command>COPY</command>). Controls the maximum number of rows per <command>INSERT</command> command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic <command>INSERT</command> to be lost, rather than the entire table contents. (COPYではなく)INSERTコマンドでデータをダンプします。 INSERTコマンド1つあたりの最大行数を制御します。 指定する値は0より大きくなければなりません。 リストア中のエラーでは、テーブルの内容がまるごと失われることはなく、問題のあるINSERTの一部の行が失われるだけです。

--use-set-session-authorization

Output SQL-standard <command>SET SESSION AUTHORIZATION</command> commands instead of <command>ALTER OWNER</command> commands to determine object ownership. This makes the dump more standards compatible, but depending on the history of the objects in the dump, might not restore properly. ALTER OWNERコマンドの代わりに標準SQLのSET SESSION AUTHORIZATIONコマンドを出力します。 これにより、ダンプの標準への互換性が高まりますが、ダンプ内のオブジェクトの履歴によっては正しくリストアされない可能性があります。

-?
--help

Show help about <application>pg_dumpall</application> command line arguments, and exit. pg_dumpallコマンドライン引数の使用方法を表示し、終了します。

The following command-line options control the database connection parameters. 以下のコマンドラインオプションは、データベース接続パラメータを制御します。

-d connstr
--dbname=connstr

Specifies parameters used to connect to the server, as a <link linkend="libpq-connstring">connection string</link>; these will override any conflicting command line options. サーバに接続するために使用されるパラメータを接続文字列として指定します。これは衝突するコマンドラインオプションよりも優先します。

The option is called <literal>&#45;-dbname</literal> for consistency with other client applications, but because <application>pg_dumpall</application> needs to connect to many databases, the database name in the connection string will be ignored. Use the <literal>-l</literal> option to specify the name of the database used for the initial connection, which will dump global objects and discover what other databases should be dumped. このオプションは、他のクライアントアプリケーションとの一貫性のために--dbnameと呼ばれます。 しかしpg_dumpallは多くのデータベースに接続しなければなりませんので、接続文字列内のデータベース名は無視されます。 グローバルオブジェクトをダンプするために使用されるデータベースの名前を指定するため、または他のどのデータベースをダンプしなければならないかを見つけるためには-lを使用してください。

-h host
--host=host

Specifies the host name of the machine on which the database server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket. The default is taken from the <envar>PGHOST</envar> environment variable, if set, else a Unix domain socket connection is attempted. データベースサーバが稼働しているマシンのホスト名を指定します。 この値がスラッシュから始まる場合、Unixドメインソケット用のディレクトリとして使用されます。 デフォルトは、設定されていれば環境変数PGHOSTから取得されます。設定されていなければ、Unixドメインソケット接続とみなされます。

-l dbname
--database=dbname

Specifies the name of the database to connect to for dumping global objects and discovering what other databases should be dumped. If not specified, the <literal>postgres</literal> database will be used, and if that does not exist, <literal>template1</literal> will be used. グローバルオブジェクトをダンプし、他のどのデータベースをダンプすべきかを見つけるために接続するデータベースの名前を指定します。 指定されなかった場合、postgresが使用されます。 もしこれも存在しない場合はtemplate1が使用されます。

-p port
--port=port

Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the <envar>PGPORT</envar> environment variable, if set, or a compiled-in default. サーバが接続を監視するTCPポートもしくはローカルUnixドメインソケットファイルの拡張子を指定します。 デフォルトは、設定されている場合、環境変数PGPORTの値になります。設定されていなければ、コンパイル時のデフォルト値となります。

-U username
--username=username

User name to connect as. 接続ユーザ名です。

-w
--no-password

Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a <filename>.pgpass</filename> file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password. パスワードの入力を促しません。 サーバがパスワード認証を必要とし、かつ、.pgpassファイルなどの他の方法が利用できない場合、接続試行は失敗します。 バッチジョブやスクリプトなどパスワードを入力するユーザが存在しない場合にこのオプションは有用かもしれません。

-W
--password

Force <application>pg_dumpall</application> to prompt for a password before connecting to a database. データベースに接続する前に、pg_dumpallは強制的にパスワード入力を促します。

This option is never essential, since <application>pg_dumpall</application> will automatically prompt for a password if the server demands password authentication. However, <application>pg_dumpall</application> will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing <option>-W</option> to avoid the extra connection attempt. サーバがパスワード認証を要求する場合pg_dumpallは自動的にパスワード入力を促しますので、これが重要になることはありません。 しかし、pg_dumpallは、サーバにパスワードが必要かどうかを判断するための接続試行を無駄に行います。 こうした余計な接続試行を防ぐために-Wの入力が有意となる場合もあります。

Note that the password prompt will occur again for each database to be dumped. Usually, it's better to set up a <filename>~/.pgpass</filename> file than to rely on manual password entry. パスワードの入力はダンプするデータベース毎に繰り返し促されます。 通常は、手作業のパスワード入力に依存するよりも~/.pgpassを設定する方が良いでしょう。

--role=rolename

Specifies a role name to be used to create the dump. This option causes <application>pg_dumpall</application> to issue a <command>SET ROLE</command> <replaceable class="parameter">rolename</replaceable> command after connecting to the database. It is useful when the authenticated user (specified by <option>-U</option>) lacks privileges needed by <application>pg_dumpall</application>, but can switch to a role with the required rights. Some installations have a policy against logging in directly as a superuser, and use of this option allows dumps to be made without violating the policy. ダンプを作成する際に使用するロール名を指定します。 このオプションによりpg_dumpallはデータベースに接続した後にSET ROLE rolenameコマンドを発行するようになります。 認証に使用したユーザ(-Uで指定されたユーザ)がpg_dumpallで必要とされる権限を持たないが、必要な権限を持つロールに切り替えることができる場合に有用です。 一部のインストレーションではスーパーユーザとして直接ログインさせないポリシーを取ることがありますが、このオプションを使用することでポリシーに反することなくダンプを作成することができます。

環境

<title>Environment</title>
PGHOST
PGOPTIONS
PGPORT
PGUSER

Default connection parameters デフォルトの接続パラメータです。

PG_COLOR

Specifies whether to use color in diagnostic messages. Possible values are <literal>always</literal>, <literal>auto</literal> and <literal>never</literal>. 診断メッセージで色を使うかどうかを指定します。 可能な値はalwaysautoneverです。

This utility, like most other <productname>PostgreSQL</productname> utilities, also uses the environment variables supported by <application>libpq</application> (see <xref linkend="libpq-envars"/>). また、このユーティリティは、他のほとんどのPostgreSQLユーティリティと同様、libpqでサポートされる環境変数を使用します(34.15を参照してください)。

注釈

<title>Notes</title>

Since <application>pg_dumpall</application> calls <application>pg_dump</application> internally, some diagnostic messages will refer to <application>pg_dump</application>. pg_dumpallは、内部でpg_dumpを呼び出すので、診断メッセージの一部ではpg_dumpを参照しています。

The <option>&#45;-clean</option> option can be useful even when your intention is to restore the dump script into a fresh cluster. Use of <option>&#45;-clean</option> authorizes the script to drop and re-create the built-in <literal>postgres</literal> and <literal>template1</literal> databases, ensuring that those databases will retain the same properties (for instance, locale and encoding) that they had in the source cluster. Without the option, those databases will retain their existing database-level properties, as well as any pre-existing contents. --cleanオプションは、ダンプスクリプトを新しいクラスタにリストアする意図のときであっても、有用なことがあります。 --cleanの使用は、スクリプトに組み込みのpostgresおよびtemplate1データベースを削除して再作成する権限を与え、これらのデータベースが元のクラスタに持っていたものと同じ属性(例えばロケールやエンコーディング)を保つことを保証します。 このオプションが無いと、これらのデータベースは既存のデータベースレベルの属性を維持します。

Once restored, it is wise to run <command>ANALYZE</command> on each database so the optimizer has useful statistics. You can also run <command>vacuumdb -a -z</command> to analyze all databases. オプティマイザが正確な統計情報を使用できるように、リストア後は、リストアしたテーブルそれぞれに対してANALYZEを実行することを勧めます。 また、vacuumdb -a -zを実行すると、全てのデータベースを解析することができます。

The dump script should not be expected to run completely without errors. In particular, because the script will issue <command>CREATE ROLE</command> for every role existing in the source cluster, it is certain to get a <quote>role already exists</quote> error for the bootstrap superuser, unless the destination cluster was initialized with a different bootstrap superuser name. This error is harmless and should be ignored. Use of the <option>&#45;-clean</option> option is likely to produce additional harmless error messages about non-existent objects, although you can minimize those by adding <option>&#45;-if-exists</option>. ダンプスクリプトはエラー無しに完全に実行すると期待すべきではありません。 特にスクリプトは存在する全てのロールに対してCREATE ROLEを発行するので、宛先のクラスタが異なるブートストラップスーパーユーザ名で初期化されていない限り、ブートストラップスーパーユーザについてrole already existsエラーを受け取ることは確実です。 このエラーは無害であり、無視してください。 --cleanオプションの使用は、追加で無害な存在しないオブジェクトについてのエラーメッセージを発生させますが、--if-existsを加えることでエラー発生を最小化できます。

<application>pg_dumpall</application> requires all needed tablespace directories to exist before the restore; otherwise, database creation will fail for databases in non-default locations. pg_dumpallでは、必要なテーブル空間用のディレクトリがリストア前に存在していることを要求します。 存在しないと、デフォルト以外の場所にあるデータベースに関して、そのデータベース生成が失敗します。

<title>Examples</title>

To dump all databases: 全てのデータベースを書き出す場合、以下のようにします。

$ pg_dumpall > db.out

To restore database(s) from this file, you can use: 上記のファイルからデータベースをリストアする場合、以下のようにします。

$ psql -f db.out postgres

It is not important to which database you connect here since the script file created by <application>pg_dumpall</application> will contain the appropriate commands to create and connect to the saved databases. An exception is that if you specified <option>&#45;-clean</option>, you must connect to the <literal>postgres</literal> database initially; the script will attempt to drop other databases immediately, and that will fail for the database you are connected to. ここではどのデータベースに接続するかということは重要ではありません。なぜならpg_dumpallが作成するスクリプトファイルには、保存されたデータベースの作成および接続のための適切なコマンドが含まれているからです。 例外は--cleanを指定した場合で、最初にpostgresデータベースに接続しなければなりません。 このときのスクリプトは即座に他のデータベースを削除しようとし、接続中のデータベースに対しては失敗するでしょう。

関連項目

<title>See Also</title>

Check <xref linkend="app-pgdump"/> for details on possible error conditions. 発生し得るエラーの原因については、pg_dumpを参照してください。