Skip to content

Backup and restore data with snapshots

Nebula Graph supports using snapshots to backup and restore data.

Authentication and snapshots

Nebula Graph authentication is disabled by default. In this case, All users can use the snapshot feature.

If authentication is enabled, only the GOD-role user can use the snapshot function. For more information about roles, see Roles and privileges.

Precautions

  • To prevent data loss, create a snapshot as soon as the system structure changes, for example, after operations such as ADD HOST, DROP HOST, CREATE SPACE, DROP SPACE, and BALANCE are performed.
  • Nebula Graph cannot automatically delete the invalid files created by a failed snapshot task, you have to manually delete them by using DROP SNAPSHOT.
  • Customizing the storage path for the snapshots is not supported for now.

Snapshot form and path

Nebula Graph snapshots are in the form of directories with names like SNAPSHOT_2021_03_09_08_43_12. The suffix 2021_03_09_08_43_12 is generated automatically based on the creation time.

When a snapshot is created, snapshot directories will be automatically created in the checkpoints directory on the leader Meta server and each Storage server.

To fast locate the path where the snapshots are stored, you can use the Linux command find. For example:

$ find |grep 'SNAPSHOT_2021_03_11_07_30_36'
./data/meta2/nebula/0/checkpoints/SNAPSHOT_2021_03_11_07_30_36
./data/meta2/nebula/0/checkpoints/SNAPSHOT_2021_03_11_07_30_36/data
./data/meta2/nebula/0/checkpoints/SNAPSHOT_2021_03_11_07_30_36/data/000081.sst
...

Note

For how to get the snapshot name, see View snapshots.

Create a snapshot

Run CREATE SNAPSHOT to create a snapshot for all the graph spaces based on the current time for Nebula Graph.

Note

Creating a snapshot for a specific graph space is not supported yet.

If the creation fails, delete the snapshot and try again. If it still fails, go to the Nebula Graph community for help.

View snapshots

To view all existing snapshots, run SHOW SNAPSHOTS.

nebula> SHOW SNAPSHOTS;
+--------------------------------+---------+------------------+
| Name                           | Status  | Hosts            |
+--------------------------------+---------+------------------+
| "SNAPSHOT_2021_03_09_08_43_12" | "VALID" | "127.0.0.1:9779" |
+--------------------------------+---------+------------------+
| "SNAPSHOT_2021_03_09_09_10_52" | "VALID" | "127.0.0.1:9779" |
+--------------------------------+---------+------------------+

The parameters in the return information are described as follows.

Parameter Description
Name Name of the snapshot directory.
Status Status of the snapshot. VALID indicates that the creation succeeded and INVALID indicates that it failed.
Hosts IP addresses and ports of all Storage servers at the time the snapshot was created.

Delete a snapshot

To delete a snapshot, use the following syntax:

DROP SNAPSHOT <snapshot_name>;

Example:

nebula> DROP SNAPSHOT SNAPSHOT_2021_03_09_08_43_12;
nebula> SHOW SNAPSHOTS;
+--------------------------------+---------+------------------+
| Name                           | Status  | Hosts            |
+--------------------------------+---------+------------------+
| "SNAPSHOT_2021_03_09_09_10_52" | "VALID" | "127.0.0.1:9779" |
+--------------------------------+---------+------------------+

Restore data with a snapshot

  1. Find the snapshot directories you want to use for data restoration.

  2. Choose an approach to restore the data files:

    • Change the data_path in the Meta configuration and Storage configuration to the snapshot path.
    • Copy the snapshot directories to other locations, and change the data_path to these locations.
    • Copy all the content in the snapshot directories into the directories where the checkpoints directories are located, and cover the existing files that have duplicate names with them. For example, cover /usr/local/nebula/data/meta/nebula/0/data with /usr/local/nebula/data/meta/nebula/0/checkpoints/SNAPSHOT_2021_03_09_09_10_52/data.
  3. Restart Nebula Graph.


Last update: September 1, 2021
Back to top