I'm having a problem with ownership of files that are outside of my Memgraph container. I can't find a way to give a ownership attributes to the file outside of container. I need this to test out the restore process from snapshot backup.
You need to copy the snapshot file into the directory after creating the container and start the database. If your folder is called snapshots
the command should look like this:
docker create -p 7687:7687 -p 7444:7444 -v `snapshots`:/var/lib/memgraph/snapshots --name memgraphDB memgraph/memgraph
tar -cf - snapshot_file | docker cp -a - memgraphDB:/var/lib/memgraph/snapshots
The snapshot_file
is the snapshot file you want to use to restore the data. Due to the nature of Docker file ownership, you need to use tar
to copy the file as STDIN into the non-running container. It will allow you to change the ownership of the file to the memgraph
user inside the container.
After that, start the database with:
docker start -a memgraphDB
The -a
flag is used to attach to the container's output so you can see the logs.
Once memgraph is started, change the snapshot directory ownership to the memgraph
user by running the following command:
docker exec -it -u 0 memgraphDB bash -c "chown memgraph:memgraph /var/lib/memgraph/snasphots"
If you don't change the ownership Memgraph will not be able to write the future snapshot files and will fail.