Syntax

Flow chart showing the syntax of the BACKUP keyword

Description

Creates a backup for one, several, or all database tables.

Backup directory

:::tip

BACKUP TABLE requires a backup directory which is set using the configuration key cairo.sql.backup.root in the server.conf file.

:::

  1. cairo.sql.backup.root=/Users/UserName/Desktop

The backup directory can be on a local disk to the server, on a remote disk, or a remote filesystem. QuestDB will enforce that the backup are 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. By default, the format is yyyy-MM-dd, for example 2020-04-20.

:::tip

You can define a custom format using the cairo.sql.backup.dir.datetime.format configuration key like the example below

:::

  1. cairo.sql.backup.dir.datetime.format=yyyy-dd-MM

The data and meta files will be written following the db directory structure

  1. 'backup directory/'
  2. 2020-04-20
  3. ├── table1
  4. ├── table2
  5. └── ...

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:

  1. 'backup directory/'
  2. ├── 2020-04-20 'first'
  3. ├── 2020-04-20.1 'second'
  4. ├── 2020-04-20.2 'third'
  5. ├── 2020-04-21 'first new date'
  6. ├── 2020-04-21.1 'first new date'
  7. └── ...

Examples

  1. BACKUP TABLE table1;
  1. BACKUP TABLE table1, table2, table3;
  1. BACKUP DATABASE;