Including a subset of a folder in nextcloud

Sorry if this is in the wrong category: please feel free to move it if I’ve put it in the wrong place.

I’d like to include a (large) subset of a folder inside the nextcloud files area. The reason I want to do this is to allow me to maintain a list on my server of the music that I want on my phone (which will never be all of the music as it wouldn’t fit) so that I can use foldersync-pro to copy stuff to my phone. When I get a new phone, putting the same music on would just be a case of running foldersync-pro again, rather than having to manually go through and select the albums I want.

Nextcloud is running in a docker container (wonderfall/docker in case it matters) on my server. I use the volumes bit of docker-compose.yml to put folders into the files area and then as far as nextcloud is concerned they are in the right place and that all works really well. There’s no risk of nextcloud getting at stuff elsewhere on the server due to the docker isolation. However, this won’t work for this use-case as it would put all of the music in the Nextcloud folder rather than just the albums I want.

I currently have the list of music in a text file, so my first attempt at this was to mount the music folder into the docker container but not in the nextcloud area and use a simple bash script to maintain the local copy:


# At the moment this isn't working as nextcloud won't follow links...

# Clean up existing links and directories
find . -type l -print0 | xargs -0 rm
find . -type d | grep -v '^.$' | tac | xargs rmdir

# Create new links
for line in $(cat phone-music-list.txt | sed 's@^./@@')
    if [ ! -e $(dirname $line) ]
        mkdir -p $(dirname $line)

    ln -s /home/music/$line $line

This didn’t work as nextcloud doesn’t support symbolic links.

The only thought I’ve had so far is to create bind mounts within the docker container. However, there are 342 entries in my phone-music-list.txt, so that’s a heck of a lot of bind mounts. It would also be much more difficult to remove them all and update them as this would have to be done within the docker container rather than just working on the file system itself.

Is there a better way of achieving what I’m hoping to do?

For now I’ve solved this by setting up another docker container with samba running and using that instead of nextcloud.