Adobe Commerce:遺失或變更設定檔

本文說明如何解決遺失或變更的組態檔。

說明 description

環境

  • 雲端基礎結構上的Adobe Commerce

問題/症狀

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

解決方法 resolution

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

  • 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
experience-cloud-kcs-help-kbarticles