SyndrDB provides comprehensive backup and restore capabilities for database disaster recovery, migration, and environment cloning. Backups are created as compressed archives containing all bundles, indexes, documents, and metadata.
Creates a compressed backup archive of a database including all bundles, indexes, documents, and metadata.
BACKUP DATABASE "database_name" TO "backup_path" [WITH options]
| Component | Description | Required |
|---|---|---|
| database_name | Name of the database to backup | Yes |
| backup_path | Path where backup file will be saved | Yes |
| WITH options | Optional backup configuration | No |
The backup path can be:
./backups).sdb extension if not providedOptions are specified in the WITH clause:
| Option | Values | Default | Description |
|---|---|---|---|
| COMPRESSION | 'gzip', 'zstd', 'none' |
'gzip' |
Compression algorithm |
| INCLUDE_INDEXES | true, false |
true |
Include index files in backup |
Controls the compression algorithm used for the backup archive:
gzip: Standard compression, good compatibilityzstd: Modern compression, better ratio and speednone: No compression (fastest, largest files)Controls whether index files are included in the backup:
true: Backup includes all index files (faster restore)false: Indexes excluded (smaller backup, slower restore)-- Simple backup with defaults (gzip compression, includes indexes)
BACKUP DATABASE "MyApp" TO "myapp_backup.sdb"
-- Saves to: ./backups/myapp_backup.sdb
-- Backup to specific location
BACKUP DATABASE "analytics" TO "/backups/production/analytics_2024_01_15.sdb"
-- Use zstd compression for better ratio
BACKUP DATABASE "BigData" TO "bigdata_backup.sdb"
WITH COMPRESSION = 'zstd'
-- No compression for fastest backup
BACKUP DATABASE "SmallDB" TO "small_backup.sdb"
WITH COMPRESSION = 'none'
-- Smaller backup without indexes (will rebuild on restore)
BACKUP DATABASE "TempData" TO "temp_backup.sdb"
WITH INCLUDE_INDEXES = false
-- Combine multiple options
BACKUP DATABASE "Production" TO "prod_backup.sdb"
WITH COMPRESSION = 'zstd', INCLUDE_INDEXES = true
The backup operation performs these steps:
Each backup archive contains:
.bnd bundle definition filesINCLUDE_INDEXES = true)manifest.json with metadata and file checksumsAdmin| Error | Cause | Solution |
|---|---|---|
database not found |
Database doesn't exist | Use SHOW DATABASES to verify database name |
invalid backup path |
Path is invalid or inaccessible | Check path permissions and directory existence |
invalid compression type |
Unknown compression value | Use 'gzip', 'zstd', or 'none' |
backup failed |
File system error or insufficient space | Check disk space and permissions |
DO:
db_2024_01_15.sdb)zstd compression for production backups (best ratio)DON'T:
none compression for large databases-- Daily backup with timestamp
BACKUP DATABASE "production" TO "prod_2024_01_15.sdb"
WITH COMPRESSION = 'zstd', INCLUDE_INDEXES = true
-- Response: Database 'production' backed up successfully to './backups/prod_2024_01_15.sdb' in 2.5s
-- Quick backup without indexes (smaller size)
BACKUP DATABASE "development" TO "dev_quick.sdb"
WITH COMPRESSION = 'gzip', INCLUDE_INDEXES = false
-- Full backup with absolute path
BACKUP DATABASE "analytics" TO "/mnt/backups/analytics_full.sdb"
WITH COMPRESSION = 'zstd', INCLUDE_INDEXES = true
Restores a database from a backup archive created by the BACKUP DATABASE command.
RESTORE DATABASE FROM "backup_path" AS "database_name" [WITH options]
| Component | Description | Required |
|---|---|---|
| backup_path | Path to the backup file (.sdb) | Yes |
| database_name | Name for the restored database | Yes |
| WITH options | Optional restore configuration | No |
Options are specified in the WITH clause:
| Option | Values | Default | Description |
|---|---|---|---|
| FORCE | true, false |
false |
Overwrite existing database |
Controls whether to overwrite an existing database:
false: Restore fails if database already exists (safe default)true: Overwrites existing database with backup (destructive)-- Restore backup to new database
RESTORE DATABASE FROM "myapp_backup.sdb" AS "MyApp"
-- Restore from specific location
RESTORE DATABASE FROM "/backups/production/analytics_2024_01_15.sdb" AS "analytics"
-- Overwrite existing database (DANGEROUS!)
RESTORE DATABASE FROM "prod_backup.sdb" AS "production"
WITH FORCE = true
-- Restore production backup to test environment
RESTORE DATABASE FROM "prod_2024_01_15.sdb" AS "production-test"
-- Original database name in backup: "production"
-- Restored as: "production-test"
The restore operation performs these steps:
IMPORTANT: After restore, the database is in LOCKED state:
UNLOCK DATABASE "name" to enable writesAdmin| Error | Cause | Solution |
|---|---|---|
backup file not found |
Backup path doesn't exist | Verify backup file path |
database already exists |
Database name is in use | Use different name or WITH FORCE = true |
checksum verification failed |
Backup file is corrupted | Use different backup file |
incompatible backup version |
Backup from different server version | Check backup metadata |
restore failed |
File system error | Check disk space and permissions |
DO:
FORCE = false (default) to prevent accidental overwritesDON'T:
FORCE = true without verifying you want to overwrite-- Restore production backup to test environment
RESTORE DATABASE FROM "/backups/prod_2024_01_15.sdb" AS "production-test"
-- Response: Database 'production-test' restored successfully from '/backups/prod_2024_01_15.sdb' in 3.2s.
-- Database is LOCKED - use UNLOCK DATABASE to enable writes.
-- Verify the restore
USE "production-test";
SHOW BUNDLES;
-- If verification passes, unlock the database
UNLOCK DATABASE "production-test";
-- Now you can use the restored database
ADD DOCUMENT TO BUNDLE "Users" WITH VALUES (...);
-- Production database is corrupted, restore from last known good backup
RESTORE DATABASE FROM "/backups/prod_2024_01_14.sdb" AS "production-recovery"
-- Verify the data
USE "production-recovery";
SELECT COUNT(*) FROM BUNDLE "Users";
SELECT COUNT(*) FROM BUNDLE "Orders";
-- If data looks good, can rename and use
-- (rename operations TBD in future SyndrDB version)
Last updated: March 2026