Hi!
I wanted to share a setup which I have come to like a lot. Maybe others find this useful and I am sure there are points to improve.
I absolute love the cabinet and index mirror feature from Mayan…but there was a problem for me with it which is the FUSE dependency. The FUSE stuff is probably great to do the mirroring, but the fact that it is FUSE limits its usability. For example, I want to re-export the mirrors via Samba on TrueNAS or I would like to re-distribute the mirrors via Syncthing to other locations. This is not possible with a FUSE based view into the Mayan database.
Thus, I figured one could make a one-way mirror as hard file copy rather than a logical FUSE link. The solution I came up with slightly modifies the example FUSE based mirrors by abusing things a bit in that I install rsync on container start and then create a cron job inside the container which rsyncs in regular intervals the FUSE file system to the mounted docker directory.
Here it goes, this is the entry in the docker-compose.yaml
file making this container copy a cabinet as files to disk:
cabinet_mirror_3:
<<: [*mayan-container, *mayan-dependencies]
cap_add:
- SYS_ADMIN
devices:
- "/dev/fuse:/dev/fuse"
entrypoint:
- /bin/sh
- -c
- 'apt-get update && apt-get install rsync && printf "#! /bin/bash\nYM=\$(date +%%Y/%%m)\n# DISABLED: rsync -ax --delete /mnt/cabinet-${MAYAN_MIRROR_CABINET_NAME_3}/\$$YM/ /mnt/target/\$$YM/\n" > /etc/cron.hourly/update && chmod +x /etc/cron.hourly/update && printf "#! /bin/bash\nYM=\$(date +%%Y/%%m)\nrsync -ax --delete /mnt/cabinet-${MAYAN_MIRROR_CABINET_NAME_3}/ /mnt/target/\n" > /etc/cron.daily/sync && chmod +x /etc/cron.daily/sync && service cron start && mkdir --parents /mnt/cabinet-${MAYAN_MIRROR_CABINET_NAME_3} && chown mayan:mayan /mnt/cabinet-${MAYAN_MIRROR_CABINET_NAME_3} && /usr/local/bin/entrypoint.sh run_command "mirroring_mount_cabinet --allow-other ${MAYAN_MIRROR_CABINET_NAME_3} /mnt/cabinet-${MAYAN_MIRROR_CABINET_NAME_3}"'
profiles:
- cabinet_mirror_3
security_opt:
- apparmor:unconfined
volumes:
- ${MAYAN_APP_VOLUME:-app}:/var/lib/mayan
- /mnt/media/mayan/cabinet/${MAYAN_MIRROR_CABINET_NAME_3}:/mnt/target
This is not something for everyone as the mirror is slow in updates and creates a full copy of the documents, but escaping FUSE gives me more flexibility in using the mirror and what is also nice is that the FUSE stuff stays inside the container and there is no need to bind the FUSE to a host directory - I always had issues with those binds not being cleaned up.
Any comments / suggestions / improvements are welcome.
Best,
Sebastian