> For the complete documentation index, see [llms.txt](https://manuals.i-reporter.jp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://manuals.i-reporter.jp/server-construction-maintenance/restoring-a-database/database-backup-restore.md).

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

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

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

* 実行環境\
  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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
