遺失或變更設定檔

本文會討論如何解決您的設定檔遭到變更或遺失的問題。

受影響的產品和版本

  • 雲端基礎結構上的Adobe Commerce,所有版本

問題

組態檔config.php及/或env.php變更錯誤或遺失。

解決方案

部署程式會為每個組態檔建立一個備份檔案:

  • app/etc/config.php.bak — 包含系統特定的設定,若不存在,則會在建置期間自動產生
  • app/etc/env.php.bak — 包含敏感的設定資料

您可以使用ECE-tools backup:restore命令將它們還原。

BAK檔案是部署程式的產物。 如果您在部署後手動變更組態檔,您的變更不會反映在現有的BAK檔案中。

若要還原組態檔:

  1. 使用SSH登入您的遠端存放庫。

  2. 列出可用的備份檔案。

    code language-none
    ./vendor/bin/ece-tools backup:list
    
    code language-none
    The list of backup files:
    app/etc/env.php
    app/etc/config.php
    
  3. 還原組態檔。

    code language-none
    ./vendor/bin/ece-tools backup:restore
    

    您會收到受還原影響的現有組態檔清單。

    code language-none
    app/etc/env.php file exists! If you want to rewrite existed files use --force
    app/etc/config.php file exists! If you want to rewrite existed files use --force
    
  4. 使用--force選項覆寫所有檔案。

    code language-none
    ./vendor/bin/ece-tools backup:restore --force
    
    code language-none
    Command backup:restore with option --force will rewrite your existed files. Do you want to continue [y/N]?y
    Backup file app/etc/env.php was restored.
    Backup file app/etc/config.php was restored.
    
  5. 您可以選擇還原特定的組態檔。

    code language-none
    ./vendor/bin/ece-tools backup:restore --force --file=app/etc/config.php
    
    code language-none
    Command backup:restore with option --force will rewrite your existed files. Do you want to continue [y/N]?y
    Backup file app/etc/config.php was restored.
    
recommendation-more-help
8bd06ef0-b3d5-4137-b74e-d7b00485808a