# データベースバックアップリストア手順

## **バッチコマンドを利用したバックアップ、リストア**

### **バックアップ**

* 実行環境\
  postgresSQLがインストールされているサーバー端末<br>
* 実行コマンド\
  pg\_dump<br>
* バックアップコマンド\
  "\[postgresSQLインストールフォルダ]\bin\pg\_dump" -h localhost -U postgres -c irepodb > \[バックアップファイルパス]

pg\_dumpコマンドを使用してConMasデータベースをバックアップできます。

{% hint style="info" %}
pg\_dumpコマンドの詳細については、以下URL（外部サイト）をご参照ください。

▼「PostgreSQL 9.2.4文書」 ＞ 「pg\_dump」\
[http://www.postgresql.jp/document/9.2/html/app-pgdump.html](<http://www.postgresql.jp/document/9.2/html/app-pgdump.html&#xD;&#xA;>)
{% endhint %}

{% hint style="success" %}
【補足】\
パスワードの指定方法については、postgresSQL標準で持っているパスワードファイルを使用する、もしくはpg\_dumpコマンド実行前に次の一行を記述して指定できます。\
　SET PGPASSWORD=\[パスワード]
{% endhint %}

{% hint style="success" %}
予め上記バックアップコマンドを使用してバッチファイルを作成し、タスクスケジューラに登録しておく事で、定期的なバックアップを行う事ができます。
{% endhint %}

### **リストア**

* 実行環境\
  postgresSQLがインストールされているサーバー端末<br>
* 実行コマンド\
  psql<br>
* バックアップコマンド\
  "\[postgresSQLインストールフォルダ]\bin\psql" -h localhost -U postgres -d irepodb < \[バックアップファイル]<br>

psqlコマンドを使用してConMasデータベースをレストアできます。

{% hint style="info" %}
psqlコマンドの詳細については、以下URL（外部サイト）をご参照ください。

▼「PostgreSQL 9.2.4文書」 ＞ 「psql」\
<http://www.postgresql.jp/document/9.2/html/app-psql.html>
{% endhint %}

{% hint style="success" %}
【補足】\
パスワードの指定方法については、postgresSQL標準で持っているパスワードファイルを使用する、もしくはpsqlコマンド実行前に次の一行を記述して指定出来ます。\
　SET PGPASSWORD=\[パスワード]
{% endhint %}

{% hint style="warning" %}
【注意点】

* バッチコマンドで出力したバックアップファイルをレストアする場合は、バッチコマンドでリストアしてください。
* irepodb は空である必要があります。\
  irepodb がある場合は削除し、irepodb を新規作成後、リストアしてください。
  {% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://manuals.i-reporter.jp/server-construction-maintenance/restoring-a-database/database-backup-restore.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
