# 备份

定期备份对于保护您的 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-cn/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.
