Back to Questdb

BACKUP keyword

documentation/query/sql/backup.md

latest2.9 KB
Original Source

import { EnterpriseNote } from "@site/src/components/EnterpriseNote"

<EnterpriseNote> Object storage backups with incremental and point-in-time recovery support. </EnterpriseNote>

BACKUP - start and abort incremental backups to object storage.

Looking for a detailed guide on backup creation and restoration? Check out our Backup and Restore guide!

Syntax

questdb-sql
BACKUP DATABASE;

BACKUP ABORT;

BACKUP DATABASE

Starts a new incremental backup. Returns immediately with the backup timestamp. The backup runs asynchronously in the background.

BACKUP ABORT

Aborts a running backup. Returns a single row:

ColumnTypeDescription
statusVARCHARaborted or not running
backup_idTIMESTAMPTimestamp of aborted backup, or NULL

Example when backup was running:

statusbackup_id
aborted2024-01-15T10:30:00.000000Z

Example when no backup was running:

statusbackup_id
not runningNULL

Monitoring backups

Use the backups() table function to monitor backup progress and history:

questdb-sql
SELECT * FROM backups();

Returns:

ColumnTypeDescription
statusVARCHARCurrent status (see below)
progress_percentINTCompletion percentage (0-100)
start_tsTIMESTAMPWhen the backup started
end_tsTIMESTAMPWhen the backup completed (NULL if running)
backup_errorVARCHARError message if backup failed
cleanup_errorVARCHARError message if cleanup failed

Status values

backup in progress, backup complete, backup failed, cleanup in progress, cleanup complete, cleanup failed

See status values in the Backup guide for descriptions and recommended actions.

Examples

Start a backup:

questdb-sql
BACKUP DATABASE;

Result:

backup_timestamp
2024-08-24T12:34:56.789123Z

Check current backup status:

questdb-sql
SELECT status, progress_percent FROM backups() ORDER BY start_ts DESC LIMIT 1;

Configuration

Backups must be configured before use. At minimum:

conf
backup.enabled=true
backup.object.store=s3::bucket=my-bucket;region=eu-west-1;...

See the Backup and Restore guide for full configuration options.

Limitations

  • Only one backup can run at a time
  • Primary and replica backups are separate (each has its own backup_instance_name)

See also