| 格式 | 建立指令範例 | 恢復指令範例 | 優點 | 缺點 |
|---|---|---|---|---|
| Plain (純文字) | pg_dump mydb > dump.sql |
psql -U user -d targetdb -f dump.sql |
- 可讀性高,直接是 SQL 語句 - 可用文字編輯器檢查或修改 - 最簡單直觀 |
- 檔案通常較大 - 無法選擇性恢復特定物件 - 恢復速度較慢 |
| Custom (自訂格式, -Fc) | pg_dump -Fc mydb > dump.dump |
pg_restore -U user -d targetdb dump.dump |
- 支援壓縮,檔案較小 - 可用 pg_restore 選擇性恢復特定資料表或模式- 恢復速度快 |
- 需用 pg_restore,不能直接用 psql
|
| Directory (目錄格式, -Fd) | pg_dump -Fd mydb -f dumpdir |
pg_restore -U user -d targetdb dumpdir |
- 適合大型資料庫,支援平行處理 (parallel restore) - 可選擇性恢復 - 檔案分散在目錄中,易於管理 |
- 備份結果是一個目錄而非單一檔案 - 傳輸或壓縮不如單檔方便 |
| Tar (壓縮包格式, -Ft) | pg_dump -Ft mydb > dump.tar |
pg_restore -U user -d targetdb dump.tar |
- 單一檔案,方便傳輸 - 可用 pg_restore 選擇性恢復
|
- 不支援平行恢復 - 壓縮效率不如 Custom 格式 |
文章標籤

留言功能已依作者設定調整顯示方式