Use BR to back up data¶

After the BR is compiled, you can back up data of specified graph spaces. This article introduces how to use the BR to back up data.

Prerequisites¶

To back up data with the BR, do a check of these:

Note

If you want to store the backup files locally, we recommend that you compile the BR on one meta server of the target Nebula Graph cluster where you will perform data restoration. For more information, see Restore data from backup files.

• The Nebula Graph services are running and we recommend that the backup is performed when the application request traffic is very low.
• Get the names of the specified graph spaces. In this example, basketballplayer is used.
• Get the Nebula Graph installation directory. In this example, /usr/local/nebula/ is used.
• From the nebula-metad.conf and nebula-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 files.

• Your account on the BR machine can log on via SSH to the meta and the storage servers without a password. Here is a configuration reference. In this example, such an account named nebula on the BR machine is used.
• If you use Amazon S3 or Alibaba Cloud OSS to store the backup files, 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 the ossutil command effective.

• If you store the backup files locally, create a directory with the same absolute path on the meta and the storage servers and the BR machine for the backup files and get the absolute path. In this example, /home/user/backup/ is used.

Note

In the production environment, we recommend that you mount Network File System (NFS) storage to the meta and the storage servers and the BR machine for local backup, or use S3 or OSS for remote backup. When you restore the data from local files, you must manually move these backup files to a specified directory, which causes redundant data and troubles. For more information, see Restore data from backup files.

Procedure¶

To back up data of the specified graph spaces:

1. 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
# Set the absolute path of the Nebula Graph installation directory
root: "/usr/local/nebula/"
# Set the absolute path of the data directory of this 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 without a password
user: "nebula"
#- # If more than one metad process runs, refer to the preceding configuration to add more
#  root: "/usr/local/nebula/"
#  data: "/usr/local/nebula/data/meta"
#  user: "nebula"
#  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
# 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 on the BR machine that is authorized to log on to the storage server via SSH without a password
user: "nebula"
#- If more than one storaged processes run, refer to the preceding configuration to add more
#  root: "/usr/local/nebula/"
#  data: "/usr/local/nebula/data/storage"
#  user: "nebula"
#  root: "/usr/local/nebula/"
#  data: "/usr/local/nebula/data/storage"
#  user: "nebula"

# Set the store directory for the backup files.
# If the backup files are stored locally, set
backend: "local:///absolute/path/to/the/store/directory"
# If Alibaba Cloud OSS is used, set
# backend: "oss://nebulabackup"
# If Amazon S3 is used, set
# backend: "s3://nebulabackup"

# Set the graph spaces to be backed up.
# If more than one graph spaces are necessary, set
# space_names: ["space_name1", "space_name2", ..., "space_name"]

2. Run the command to change to the nebula-storage/util/br/bin/ directory.

cd nebula-storage/util/util/br/bin/

3. Run the command to back up data.

./br backup full --config "/absolute/path/to/the/backup/configuration/file.yaml"


In this command:

• backup full: Backs up data.
• --config "/absolute/path/to/the/backup/configuration/file.yaml": Sets the absolute path of the configuration file.

Note

During the backup process, if the leader changes, an error occurs. You can clean the temporary files with the br cleanup command as in Step 4, and then run the br backup command again.

When the backup is successful, you can find a backup folder with a name in the BACKUP_YY_MM_DD_HH_mm_SS format in the backup store directory on the BR machine and all the servers of the cluster. In this example, in the /home/user/backup/ directory, you can find a folder named BACKUP_2020_11_30_20_47_44. All these backup files on all the machines are required for data restoration.

4. (Optional) By default, all the snapshots will be deleted when the backup is done. If errors occur during the deletion of these files, run this command to delete them.

./br cleanup --backup_name [backup file name] --meta 192.168.8.161:9559


In this command: - cleanup: Deletes all the temporary files on the meta and the storage servers. - --backup_name BACKUP_YY_MM_DD_HH_mm_SS: Sets a backup folder name, indicating the command is run to delete the temporary files that were generated when this backup folder was generated. - --meta <IP address:port>: Sets the IP address and the port of a meta server.

Next to do¶

After the backup files are generated, you can use the BR to restore them for Nebula Graph. For more information, see Use BR to restore data.

Last update: April 22, 2021