Backup and recovery
YDB is initially designed for data safety in case of hardware failures: redundancy options are available for different numbers of availability zones, racks, hosts, disks, and other components (see cluster operating modes). This reduces the risk of data loss due to hardware failures.
However, data can be lost or corrupted logically: errors or malicious actions can lead to mass deletion/corruption of data by operations legitimate for the DBMS. In such cases, cluster fault tolerance does not replace a separate copy of data outside the cluster.
Backup is used to protect against such scenarios and allows restoring data from a backup. It is recommended to store copies on a separate medium or in cloud object storage (for example, via export to files or export to S3).
YDB provides several solutions for performing backup and recovery. For conceptual information and comparison of backup methods, see backup concepts.
- Backup to files and recovery using the YDB CLI.
- Backup to S3-compatible storage and recovery using the YDB CLI.
- Backup of system tablets to the local file system of cluster hosts.
YDB CLI
Files
The following commands are used for backup to files:
ydb admin cluster dump— for backing up cluster metadataydb admin database dump— for backing up the databaseydb tools dump— for backing up individual schema objects or directories
Learn more about these commands in Exporting data to the file system.
The following commands are used for restoration from a file backup:
ydb admin cluster restore— for restoring cluster metadata from a backupydb admin database restore— for restoring the database from a backupydb tools restore— for restoring individual schema objects or directories from a backup
Learn more about these commands in Importing data from the file system.
S3-compatible storage
To perform backup to an S3-compatible storage (for example, AWS S3), the ydb export s3 command is used. Follow the link to the YDB CLI reference for information about this command.
To perform restoration from a backup created in an S3-compatible storage, the ydb import s3 command is used. Follow the link to the YDB CLI reference for information about this command.
NFS
To perform backup to NFS on hosts where YDB is running, the ydb export nfs command is used. Follow the link to the YDB CLI reference for information about this command.
To perform restoration from a backup created in NFS on hosts where YDB is running, the ydb import nfs command is used. Follow the link to the YDB CLI reference for information about this command.
For more details on configuring NFS for backup and recovery, see the recipe Backup and recovery via NFS.
Note
The speed of backup and restore operations to/from S3-compatible storage or NFS is tuned to minimize the impact on user load. To control the operation speed, configure limits for the corresponding queue of the resource broker.
Note
When performing an export, a directory named export_* is created in the root directory of the database, where * is the numeric part of the export identifier. This directory contains tables that hold a consistent snapshot of the exported data at the time the export started. After the backup operation completes successfully, the export_* directory along with its contents is deleted.
Backup collections
Backup collections provide incremental backup and point-in-time recovery for production workloads. For conceptual information and architecture details, see Backup collections.
Backup collections are recommended for production environments with a regular backup schedule and large datasets where incremental changes are significantly smaller than the total volume. For simpler scenarios (one-time migrations, development environments, small databases), consider using export/import or dump/restore.
For step-by-step instructions on configuring and using backup collections, see:
- Backup collections — architecture, concepts, and limitations
- Recipes for backup collections — typical scenarios and examples
Backup of system tablets
The system tablet backup mechanism provides incremental copying of cluster metadata to the local file system of the cluster hosts.
For conceptual information and how it works, see Backup concepts.
For step-by-step instructions on enabling and restoring, see Recipes for system tablet backup.