# 備份

定期備份對於保護您的 Chamilo 資料至關重要。本頁涵蓋要備份的內容以及如何進行備份。

## 要備份的內容

### 1. 資料庫

Chamilo 資料庫包含所有平台資料：使用者、課程、追蹤、成績、訊息以及設定。這是最關鍵的備份元件。

**備份方式：**

```bash
mysqldump -u username -p chamilo_database > chamilo_backup_$(date +%Y%m%d).sql
```

### 2. 檔案

Chamilo 將上傳的檔案（文件、圖像、SCORM 套件）儲存在檔案系統中。要備份的關鍵目錄：

* `var/` — 上傳的檔案和資源
* `public/plugin/` — 外掛檔案（僅在您新增自訂外掛時）

如果您使用雲端儲存（S3、Azure Blob），請確保您的雲端提供者的備份/版本控制已啟用。

### 3. 設定

* `.env` — 您的環境設定
* `config/` — 任何自訂設定檔案

## 備份排程

| 元件  | 建議頻率           |
| --- | -------------- |
| 資料庫 | 每日             |
| 檔案  | 每日或每週（視上傳活動而定） |
| 設定  | 任何設定變更後        |

## 還原

要從備份還原：

1. 從 SQL 傾印還原資料庫
2. 還原檔案目錄
3. 還原設定檔案
4. 清空 Symfony 快取：`php bin/console cache:clear`

## 提示

* **自動化備份** — 使用 cron 工作自動執行備份
* **異地儲存** — 在獨立的伺服器或雲端儲存中保留備份副本
* **測試還原** — 定期測試您是否能夠成功從備份還原
* **記錄您的程序** — 保留還原程序的書面指示，以便團隊中的任何人皆可執行


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.chamilo.org/2.x-zh-tw/guan-li-zhi-nan/admin-guide/maintenance/backups.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
