如何备份 Memgraph 数据库?

发布于 2025-01-17 06:25:01 字数 240 浏览 4 评论 0原文

我正在 Ubuntu WSL 中运行 Memgraph。我想备份我的数据库。我无法找到数据库文件。

我发现了解决Memgraph 平台,但我需要一些 WSL 解决方案。

I'm running a Memgraph within Ubuntu WSL. I want to make a backup of my database. I'm having trouble locating the database files.

I've found the question that addresses Memgraph platform, but I need some solution for WSL.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

机场等船 2025-01-24 06:25:01

运行时,Memgraph 在其数据目录中生成几个不同的文件。这是 Memgraph 保存所有永久数据的位置。默认数据目录是/var/lib/memgraph

如果要触发创建当前数据库状态的快照,请在 mgconsole 或 Memgraph Lab 中运行以下查询:

CREATE SNAPSHOT;

创建 Memgraph 实例的备份只需复制数据目录。如果没有额外的帮助,这是不可能的,因为当触发事件(快照数量超过允许的最大数量)时,可以删除持久性文件。

要禁用此行为,您可以在 mgconsole 或 Memgraph Lab 中使用以下查询:

LOCK DATA DIRECTORY;

如果您使用 Linux 运行 Memgraph,则复制文件的步骤如下:

  1. 启动 Memgraph 实例。
  2. 打开一个新的 Linux 终端并检查永久数据目录的位置:

grep -A 1 'permanent data' /etc/memgraph/memgraph.conf

  1. 将文件从快照目录复制到备份文件夹,例如:

cp /var/lib/memgraph/snapshots/20220325125308366007_timestamp_3380 ~/backup/

到允许删除文件,请在 mgconsole 或 Memgraph Lab 中运行以下查询::

UNLOCK DATA DIRECTORY;

Memgraph 将删除之前应删除的文件,并允许将来删除其中包含的文件数据目录。

While running, Memgraph generates several different files in its data directory. This is the location where Memgraph saves all permanent data. The default data directory is /var/lib/memgraph.

If you want to trigger creating a snapshot of the current database state, run the following query in mgconsole or Memgraph Lab:

CREATE SNAPSHOT;

Creating a backup of a Memgraph instance would consist of simply copying the data directory. This is impossible without additional help because the durability files can be deleted when an event is triggered (the number of snapshots exceeded the maximum allowed number).

To disable this behavior, you can use the following query in mgconsole or Memgraph Lab:

LOCK DATA DIRECTORY;

If you are using Linux to run Memgraph, here are the steps for copying files:

  1. Start your Memgraph instance.
  2. Open a new Linux terminal and check the location of the permanent data directory:

grep -A 1 'permanent data' /etc/memgraph/memgraph.conf

  1. Copy a file from the snapshot directory to the backup folder, e.g.:

cp /var/lib/memgraph/snapshots/20220325125308366007_timestamp_3380 ~/backup/

To allow the deletion of the files, run the following query in mgconsole or Memgraph Lab::

UNLOCK DATA DIRECTORY;

Memgraph will delete the files which should have been deleted before and allow any future deletion of the files contained in the data directory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文