user3212757
user3212757

Reputation: 73

How to preform restore - docker based exists dB

We are running the existdb from the image (existdb/existdb:5.3.0-SNAPSHOT).

I am trying to follow information from herre to run restore: https://github.com/eXist-db/docker-existdb/issues/40

However the container based on that image does not seem to be containing the start.jar file.So cmdlike this fails:

docker exec myexistdbconatinername java -jar start.jar client --no-gui --xpath "system:restore('/mylocationwithbackupsinsideconatiner', '', '')"

with "unable to access start.jar". I tried to search the whole container file system -> but the start.jar is not there...

Furthermore the image is distroless - so there is no bash. So I guess the documentation here (using backup.sh) is not relevant ...

http://exist-db.org/exist/apps/doc/backup.xml

What is the recommended way how to run the restore in a automated way using cmd line when running the existdb from docker image ?. Can you point me to documentation or advise steps.

Many thanks

Upvotes: 6

Views: 209

Answers (1)

Marinos An
Marinos An

Reputation: 10818

Without having any prior experience with existdb, I would propose two different solutions to your problem:

1. If the distroless you are trying to run a shell, supports a :debug tag, you can create a new container with that tag (and same version). This will contain the shell. Then just copy (using docker cp) the /bin/sh from there into the host machine and from the host machine to the original container. Regarding the jar or anyother tool, you can upload it with docker cp again from your host into the container and execute it inside the container.

2. What you are tying to perform inside the container, you could equally perform it outside of it onto your host. Docker containers filesystem exists also on the host machine (at least on linux). There are two ways to print the path to which you can access the filesystem of the container:

  • a. docker inspect your-container-name | jq '.[0].GraphDriver.Data.MergedDir'
    • example result: var/lib/docker/overlay2/800fd7f2187cbd0be9d1e430ac34efc431c6efb183be45a59c705a4821d362da/merged
  • b. echo "/proc/$(docker inspect -f '{{.State.Pid}}' your-container-name )/root"
    • example result: /proc/3446/root

To access the above directories you will most probably need to switch to root.

(Before the step below you can first backup the contents from one of the two directories above.)

Then execute the command (from your host) e.g.:

java -jar start.jar client --no-gui --xpath "system:restore('/lib/docker/overlay2/800fd7f2187cbd0be9d1e430ac34efc431c6efb183be45a59c705a4821d362da/merged/mylocationwithbackupsinsideconatiner', '', '')"

Now I guess there is a default url to which the tool connects for adding the data from the backup directory. This can change with -ouri flag. In any case the port of the database to which the start.jar or any other script connects needs to be exposed to the host.

P.S. if you know that the file you want to restore from, exists inside a volume, you can simply print the path of that volume on the host with:

  • docker inspect -f '{{ .Mounts }}' your-container-name
    • possible result: /var/lib/docker/volumes/7492ae0c0198d18d0954c834d5bba3167d0f162868e7271d571ff62fb1f5b034/_data /mountpath

P.S 2

I don't know up to which version the start.jar was used for backup/restore. In the latest version (https://github.com/eXist-db/exist/releases (exist-distribution-6.2.0-unix.tar.bz2 )) I see that there is a script: bin/backup.sh supporting both backup and restore (-r flag) and by default reads configuration from etc/backup.properties. It is also mentioned here: https://exist-db.org/exist/apps/doc/backup (section: using the command line utility)

Upvotes: 1

Related Questions