Use BR to restore data¶
If you use the BR to back up data, you can use it to restore the data to Nebula Graph. This article introduces how to use the BR to restore data from backup files.
NOTE: The restoration process is performed OFFLINE.
CAUTION: During the restoration process, the data on the target Nebula Graph cluster is removed and then is replaced with the data from the backup files. If necessary, back up the data on the target cluster.
Prerequisites¶
To restore data with the BR, do a check of these:
- The BR is compiled. For more information, see Compile BR.
- No application is connected to the target Nebula Graph cluster.
- Make sure that the target and the source Nebula Graph clusters have the same topology, which means that they have exactly the same number of hosts.
- Get the backup folder names to do the restoration. In this example,
BACKUP_2020_12_21_01_17_53
is used.
- From the
nebula-metad.conf
andnebula-storaged.conf
files, get the IP addresses and ports of the meta and the storage servers. Both files are in the<nebula_installation_path>/nebula/etc
directory. In this example,- For the meta server:
192.168.8.161:9559
- For the storage server:
192.168.8.161:9779
NOTE: Make sure that the actual IP addresses instead of
127.0.0.1
are used in the configuration file.
- For the meta server:
- Your account on the BR machine can log on to the meta and the storage servers via SSH without a password. Here is a configuration reference. This account must have the write permission to the installation directory of Nebula Graph. In this example, such an account named
nebula
on the BR machine is used.
- If the backup files are stored on Alibaba Cloud OSS or Amazon S3, make sure that the S3 CLI client or ossutil is installed and configured on the meta servers, the storage servers, and the BR machine. For more information, see Amazon S3 CLI Documentation and Alibaba Cloud ossutil Documentation.
NOTE: Run
ln -s /<ossutil_tool_installation_path>/<ossutil64 or ossutil> /usr/local/bin/ossutil
to make theossutil
command effective.
- If the backup files are stored locally on the servers, create a directory with the same absolute path on the BR machine and all the servers of the target Nebula Graph cluster, and then manually move these backup files to this directory. Such file movement causes redundant data and troubles.
Procedure¶
To restore data from some backup files:
-
Edit the configuration file as follows. You can find an example configuration in the
nebula-storage/util/br/
directory.meta_nodes: - # Set the IP address and the port of one meta server addrs: "192.168.8.161:9559" # Set the absolute path of the Nebula Graph installation directory root: "/usr/local/nebula/" # Set the absolute path of the data directory of the metad process data: "/usr/local/nebula/data/meta" # Set the account of the BR machine that is authorized to log on to the meta server via SSH user: "nebula" #- # If more than one metad processes run, refer to the preceding configuration to add more #- addrs: "192.168.8.161:9559" # root: "/usr/local/nebula/" # data: "/usr/local/nebula/data/meta" # user: "nebula" #- addrs: "192.168.8.161:9559" # root: "/usr/local/nebula/" # data: "/usr/local/nebula/data/meta" # user: "nebula" storage_nodes: - # Set the IP address and the port of one storage server addrs: "192.168.8.161:9779" # Set the absolute path of the Nebula Graph installation directory root: "/usr/local/nebula/" # Set the absolute path of the data directory of the storaged process data: "/usr/local/nebula/data/storage" # Set the account of the BR machine that is authorized to log on to the storage server via SSH user: "nebula" #- If more than one storaged processes run, refer to the preceding configuration to add more #- addrs: "192.168.8.161:9779" # root: "/usr/local/nebula/" # data: "/usr/local/nebula/data/storage" # user: "nebula" #- addrs: "192.168.8.161:9779" # root: "/usr/local/nebula/" # data: "/usr/local/nebula/data/storage" # user: "nebula" # Set the directory where the backup files are located. # If the backup files are stored locally backend: "local:///absolute/path/to/the/store/directory" # If Alibaba Cloud OSS is used # backend: "oss://nebulabackup" # If Amazon S3 is used # backend: "s3://nebulabackup" # Set the backup files to be restored backup_name: "BACKUP_2020_12_21_01_17_53"
-
Run the command to change to the
nebula-storage/util/br/bin/
directory.cd nebula-storage/util/util/br/bin/
-
Run the command to restore data.
./br restore full --config "/absolute/path/to/the/restore/configuration/file.yaml"
In this command:
-
restore full
: Restores data. ---config "/absolute/path/to/the/restore/configuration/file.yaml"
: Sets the absolute path of the configuration file.NOTE: During the restoration process, if the leader changes, an error occurs. To prevent data corruption, when an error occurs, you must run the
br restore
command to perform the restoration again.When the restoration is successful, you can find the data in the
<nebula_installation_path>/data/storage
directory under the Nebula Graph installation directory. -
Wait about several seconds until the metadata and the schema are synchronized, and then verify the data. For example, on the nebula-console, run
SHOW STATS
to verify the number of vertices and edges in the restored graph space.NOTE: After restoration,
- if no records are returned for the
USE <space_name>
statement, we recommend that you restart the Graph Service. - if the
Storage Error: part: 2, error code: -3.
error occurs when you query the restored data, do a check of the status of the Storage Service. If necessary, restart the Storage Service.
- if no records are returned for the