Creates a backup for one, several, or all database tables.
The BACKUP statement is deprecated since QuestDB version 7.3.3 on all operating systems except Windows. We recommend the SNAPSHOT statements instead.
The backup directory can be on a disk local to the server, a remote disk or
a remote filesystem. QuestDB will enforce that the backup is only written in a
location relative to the
backup directory. This is a security feature to
disallow random file access by QuestDB.
The tables will be written in a directory with today's date with the default
2020-04-20). A custom date format can be specified
BACKUP query run on
2021-02-25, the data and metadata files will be
written following the
db directory structure
If a user performs several backups on the same date, each backup will be written a new directory. Subsequent backups on the same date will look as follows:
When creating a backup in QuestDB, you can specify that the whole database or
specific tables should be backed up. This process will create a backup in the
A backup can then be triggered via SQL command and the backup is complete as soon as the SQL query has finished executing:
Note that calling
BACKUP TABLE <table_name> will only copy table data and
metadata to the destination folder. This form of backup will not copy entire
database configuration files required to perform a complete database restore.
Alternatively, the REST API can be used to execute the SQL for a database backup:
In order to restore a backup, the QuestDB executable must be provided with the
directory location of an existing backup as the root directory. This can
done via the
-d flag as
-d /path/to/backup when starting up QuestDB.
Users who are starting QuestDB via
systemd or the official AWS AMI may refer
for reference. To verify that database information has been successfully
imported, check logs via
journalctl -u questdb which will contain a list
Docker instances may have a backup directory mounted to the root directory as follows:
The following example sets up a cronjob which triggers a daily backup via REST API:
This example shows how to compress a backup using the
tar utility. An archive
questdb_backup.tar.gz will be created in the directory that the command
The backup file can be expanded using the same utility: