Tuesday, October 10, 2017

Getting Synology PhotoStation to use the same directory as Lightroom


Photo Station does exactly I want. It provides a web interface to look at all of my pictures and also provides iOS and Android apps. I already use it for my iPhone and iPad automatic photo backups, so I wanted to use it for all my pictures imported with Lightroom as well.


The difficulty comes in that Photo Station is very strict where photos can be stored. They can either be in the Shared Folder /photo or in the photo folder of user home directories. I was already using the photo directory from my home directory for my mobile photo backups. With this I encounter a problem. Photo Station only allows photos to be in /photo or /volume1/homes/user/photo. And Cloud Station only allows syncs to /directory style top Shared folders or /volume1/homes/user/Cloud Station. Luckily there is a way to trick it.

Mount bind /Backup to /volume1/homes/user/photo


The first thing I needed to do was to mount bind the Cloud Station directory to the a directory inside the Photo Station directory. This tricks the software into thinking the files are actually in that directory although they may be somewhere else. I SSH into my machine and ran the following fter creating the directory /volume1/homes/user/photo/Pictures/ first:
mount --bind /volume2/Media/Pictures /volume1/homes/user/photo/Pictures/
Now I had that folder pointing to the Pictures directory that is synced my Cloud Station. But this is only temporary, as upon reboot the mount will no longer exist and /volume1/homes/user/photo/Pictures/ will go back to to being an empty directory.

I created a script and placed it in /usr/syno/etc/rc.d which will be executed upon boot:
#!/bin/sh
mount --bind /volume2/Media/Pictures /volume1/homes/user/photo/Pictures/
I called this script S00mountPictures.sh and made sure it was executable with the command
chmod +x ./S00mountPictures.sh
 Now after rebooting, the Cloud Station directory was still linked to a directory in the Photo Station directory.

In order to work with Photo Station, the right permissions need to be set. I just gave it full permissions (drwxrwxrwx) to the Pictures directory:
chmod 777 -R /volume1/homes/user/photo/Pictures/
Because Photo Station is user http, and it is not under the default users group, the permissions need to be for everyone.


My pictures do not show up on Photo Station?


Unfortunately even though the photos are in a location where Photo Station can see it now, it will simply ignore it. I needed to manually add the directory as a location to be indexed with the following command:
synoindex -A /volume1/homes/user/photo/Pictures/
After running this command, I headed over to www.domain.com/~user/photo and all my pictures slowly but surely started showing up on Photo Station. Success!

But then I discovered another problem. New pictures were not being recognized and added to Photo Station. After some testing, I learned that I needed to reindex the directory each time. The problem is that reindexing the entire Pictures directory will take a very long time, depending how many photos you have. So I will need to reindex only specific folders.

Because I am using the default Lightroom photo structure, my setup is /Pictures/2016/2016-01-31. So I just need to reindex the folder for each new day only. Using the Task Scheduler from the Control Panel on the Synology NAS, I created a new User-defined script that runs the following command every hour:
/usr/syno/bin/synoindex -R /volume1/homes/user/photo/Pictures/`date +"%Y"`/`date +"%Y-%m-%d"`
Those date commands within the ` ticks are executed and return the correct dates. So the first date command will return the current year, 2016 for the first folder, and then second command will return the current date for the second folder, formatted 2016-01-31. Now only new folders for each day will end up being reindexed instead of the entire Pictures folder or the entire year. And if the folder does not exist, it will just error out. No big deal.



If you also have different folders you want to be reindexed, you can create new User-defined scripts with the synoindex -R command.

To debug whether the task ran successfully, run the following command and check the status result:
/tmp/synoschedtask --get

Took some effort, but I got it running


After doing all of this, I finally had my setup how I want. Cloud Station syncs my Lightroom photo imports from my PC to my NAS and Photo Station provides me the ability to share those pictures online and easily access them with my mobile devices. This is now very close to my previous setup where I would use Apple Photos for managing my photos and used Photo Stream to have the pictures accessible from my iPhone and iPad.

1 comment:

  1. Very interesting! I will try that this weekend on my own Synology/LR configuration. I'm looking exactly to overcome the same issue. Thanks a lot.

    ReplyDelete