Skip to content

备份

您可以为 PostgreSQL 数据库和 Coolify 本身配置定时备份。

这些备份计划基于 cron 表达式,因此您可以根据需要配置它们的运行频率。

您还可以使用简单的 cron 表达式,如:

js
const VALID_CRON_STRINGS = [
    'every_minute' => '* * * * *',
    'hourly' => '0 * * * *',
    'daily' => '0 0 * * *',
    'weekly' => '0 0 * * 0',
    'monthly' => '0 0 1 * *',
    'yearly' => '0 0 1 1 *',
];

PostgreSQL

Coolify 会为您的 PostgreSQL 数据库创建完整备份。您可以通过逗号分隔的列表指定要备份的数据库。

提示

Coolify 自己的数据库也使用这种方法进行备份。

备份命令

bash
pg_dump --format=custom --no-acl --no-owner --username <用户> <数据库>

恢复命令

备份采用自定义格式,因此您可以使用以下命令(或任何等效工具)恢复它:

bash
pg_restore --verbose --clean -h localhost -U postgres -d postgres pg-dump-postgres-1697207547.dmp

MySQL

bash
mysqldump -u root -p <> <数据库>

MariaDB

bash
mariadb-dump -u root -p <> <数据库>

MongoDB

bash
mongodump --authenticationDatabase=admin --uri=<uri> --gzip --archive=<archive>

如果您要排除某些集合:

bash
mongodump --authenticationDatabase=admin --uri=<uri> --gzip --archive=<archive> --excludeCollection=<集合名> --excludeCollection=<集合名>

S3 备份

您还可以定义自己的 兼容 S3 的 存储来存储备份。