Edge for Private Cloud 4.18.01 版
本文說明如何使用 Postgres pg_dump 和 pg_restore 指令,在地端部署入口網站中執行備份和還原工作。
備份前
您可以使用入口網站安裝設定檔中的 PG_NAME 屬性,指定資料庫名稱。入口網站的安裝操作說明會指定將資料庫命名為 devportal。如果不確定資料庫名稱,請查看設定檔,或使用下列 psql 指令顯示資料庫清單:
psql -h localhost -d apigee -U postgres -l
其中 -U 指定入口網站用來存取資料庫的 Postgres 使用者名稱,如入口網站安裝設定檔中的 DRUPAL_PG_USER 屬性所指定。系統會提示您輸入資料庫密碼。
這個指令會顯示下列資料庫清單:
Name | Owner | Encoding | Collate | Ctype | Access privileges
-------------+--------+----------+-------------+-------------+---------------------
apigee | apigee | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/apigee +
| | | | | apigee=CTc/apigee +
| | | | | postgres=CTc/apigee
devportal | apigee | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
newportaldb | apigee | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | apigee | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | apigee | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/apigee +
| | | | | apigee=CTc/apigee
template1 | apigee | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/apigee +
| | | | | apigee=CTc/apigee備份入口網站
如要備份入口網站:
- 切換至 Drupal 目錄 (預設為
/opt/apigee/apigee-drupal):cd /opt/apigee/apigee-drupal
- 備份 Drupal 資料庫執行個體。
pg_dump指令會建立資料庫副本:pg_dump --dbname=devportal --host=host_IP_address --username=drupaladmin --password --format=c > /tmp/portal.bak
其中:
dbname指定入口網站安裝設定檔中PG_NAME屬性指定的資料庫名稱。host指定入口網站節點的 IP 位址。username指定入口網站用來存取資料庫的 Postgres 使用者名稱,如入口網站安裝設定檔中的DRUPAL_PG_USER屬性所指定。- 系統會提示您輸入 Postgres 使用者密碼,該密碼是由入口網站安裝設定檔中的
DRUPAL_PG_PASS屬性定義。
- 備份整個 Drupal 網站根目錄。預設的 webroot 位置為
/opt/apigee/apigee-drupal/wwwroot。 - 備份公開檔案。根據預設,這些檔案位於
/opt/apigee/apigee-drupal/wwwroot/sites/default/files。如果位置正確,系統會在步驟 3 備份這些檔案。只有在您將這些檔案從預設位置移出時,才需要明確備份。 - 備份
/opt/apigee/data/apigee-drupal-devportal/private中的私人檔案。如果不確定這個目錄的位置,請使用
drush status指令判斷私人檔案系統的位置。
還原入口網站
如要從備份還原至現有資料庫,請使用下列指令:
pg_restore --clean --dbname=devportal --host=localhost --username=apigee < /tmp/portal.bak
如要從備份還原並建立新的資料庫,請使用下列指令:
pg_restore --clean --create --dbname=devportal --host=localhost --username=apigee < /tmp/portal.bak
您也可以將備份檔案還原至 Drupal 網頁根目錄和私人檔案。