Ultipa GQL provides built-in commands and functions for backing up and restoring your graph data. You can back up individual graphs or an entire database, create incremental backups to save space, and verify backup integrity before relying on them.
GQL-- Back up the current graph BACKUP GRAPH TO '/backups/my_backup' -- List available backups SHOW BACKUPS -- Restore from a backup (replaces existing graph data) RESTORE GRAPH FROM '/backups/my_backup.gqlbackup.tar.gz' OVERWRITE -- Verify a backup file is valid VERIFY BACKUP '/backups/my_backup.gqlbackup.tar.gz'
Use BACKUP GRAPH to create a backup of a single graph as a compressed archive.
GQLBACKUP GRAPH [<graphName>] TO '<path>'
| Argument | Description |
|---|---|
<graphName> | Optional. The name of the graph to back up. If omitted, backs up the current (active) graph |
<path> | The destination file path for the backup. This is an absolute filesystem path (e.g., /backups/my_backup); the .gqlbackup.tar.gz extension is added automatically. The parent directory must already exist |
Back up the current graph:
GQLBACKUP GRAPH TO '/backups/my_backup'
Back up a specific graph without switching to it:
GQLBACKUP GRAPH analytics TO '/backups/analytics_backup'
NOTEThe database remains available for reads and writes while a backup is in progress.
Use RESTORE GRAPH to restore a graph from a backup archive.
GQLRESTORE GRAPH FROM '<path>' [OVERWRITE]
| Argument | Description |
|---|---|
<path> | The full path to the backup file, including the .gqlbackup.tar.gz extension |
OVERWRITE | Optional. If specified, replaces the existing graph data. Without it, the command fails if the target graph already exists |
Restore a graph from a backup:
GQLRESTORE GRAPH FROM '/backups/my_backup.gqlbackup.tar.gz'
Restore and overwrite an existing graph:
GQLRESTORE GRAPH FROM '/backups/my_backup.gqlbackup.tar.gz' OVERWRITE
NOTEAfter an overwrite restore, the graph reflects exactly the state captured in the backup. Any data added after the backup was taken is lost.
Incremental backups capture only the changes made since a base (full) backup. They are smaller and faster to create, but require the base backup to be available during restoration.
First, create a full backup, then reference it as the base:
GQL-- Step 1: Create a full backup BACKUP GRAPH TO '/backups/full' -- Step 2: Make data changes INSERT (:Person {name: 'NewUser'}) -- Step 3: Create an incremental backup referencing the full backup BACKUP GRAPH TO '/backups/incr' INCREMENTAL BASE '/backups/full.gqlbackup.tar.gz'
Incremental backup files use the extension .gqlbackup.inc.tar.gz.
Restore the full backup first, then apply the incremental backup on top:
GQLRESTORE GRAPH FROM '/backups/full.gqlbackup.tar.gz' OVERWRITE RESTORE GRAPH FROM '/backups/incr.gqlbackup.inc.tar.gz' OVERWRITE
Use BACKUP DATABASE and RESTORE DATABASE to back up and restore all graphs in a database at once.
GQLBACKUP DATABASE TO '/backups/db_snapshot'
This creates a directory containing a separate backup file for each graph along with a metadata manifest.
GQLRESTORE DATABASE FROM '/backups/db_snapshot' OVERWRITE
GQL-- Set up two graphs with data INSERT (:Person {name: 'Alice'}) CREATE GRAPH analytics USE GRAPH analytics INSERT (:Metric {name: 'clicks', value: 1000}) USE GRAPH default -- Back up the entire database BACKUP DATABASE TO '/backups/full_db' -- Later, restore all graphs RESTORE DATABASE FROM '/backups/full_db' OVERWRITE -- Verify data in both graphs USE GRAPH default MATCH (p:Person) RETURN p.name -- Result: Alice USE GRAPH analytics MATCH (m:Metric) RETURN m.name, m.value -- Result: clicks, 1000
Use SHOW BACKUPS to view recorded backups from the catalog or scan a directory:
GQL-- Show all entries from the backup catalog SHOW BACKUPS -- Filter by graph name SHOW BACKUPS FOR GRAPH analytics -- Scan a directory for backup files SHOW BACKUPS FROM '/backups/directory'
Use SHOW BACKUP with a file path to retrieve metadata for a specific backup:
GQLSHOW BACKUP '/backups/my_backup.gqlbackup.tar.gz'
Use VERIFY BACKUP to check that a backup archive is structurally valid before relying on it:
GQLVERIFY BACKUP '/backups/my_backup.gqlbackup.tar.gz'
The result includes a valid field (true or false) and an errors field listing any issues found.
NOTEAlways verify backups before using them for disaster recovery.
As an alternative to the DDL statements above, you can use built-in functions that return backup metadata as map values. These are useful when you need to process backup information programmatically within a query.
Creates a backup of the current graph.
GQL-- Basic backup RETURN DB.BACKUP('/path/to/backup') -- With options RETURN DB.BACKUP('/path/to/backup', {compress: true}) -- Incremental backup RETURN DB.BACKUP('/path/to/backup', {incremental: true})
| Option | Type | Default | Description |
|---|---|---|---|
compress | BOOL | true | Enable gzip compression |
incremental | BOOL | false | Only capture changes since the last checkpoint |
Returns a map containing status, path, type, graphName, nodeCount, edgeCount, size, walSequence, timestamp, and compressed.
Restores a graph from a backup file.
GQL-- Restore (fails if graph exists) RETURN DB.RESTORE('/path/to/backup.gqlbackup.tar.gz') -- Restore with overwrite RETURN DB.RESTORE('/path/to/backup.gqlbackup.tar.gz', {overwrite: true})
| Option | Type | Default | Description |
|---|---|---|---|
overwrite | BOOL | false | Replace existing graph data |
Returns a map containing status, graphName, nodeCount, edgeCount, type, and timestamp.
Lists backup files found in a directory.
GQLRETURN DB.BACKUPS('/backups/directory')
Returns a list of maps, each containing path, type, graphName, nodeCount, edgeCount, size, walSequence, timestamp, and compressed.
A backup captures the complete state of a graph, including:
The following are not included in the backup but are rebuilt automatically on restore:
| Type | Extension |
|---|---|
| Full graph backup | .gqlbackup.tar.gz |
| Incremental backup | .gqlbackup.inc.tar.gz |
NOTEDo not include the extension when specifying the destination path in
BACKUP GRAPH-- it is added automatically.
OVERWRITE replaces the entire graph with the backup contents. Without it, the restore fails if the target graph already exists.