私有雲 v4.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 網路根目錄和私人檔案。