Photo Library On Synology Nas

  • Import photos already on the NAS. I updated to DSM 7. I have a DSM local account for myself (admin) my wife and daughter. I’ve been manually copy photos to the NAS for years to the /photos share. I’ve give each user permissions to their own folders. Now I’d like them each to have their own Synology Photos library.
  • Call it gphoto-sync and hit create. In order to enable access we need to go to the photo api. Click on the project you just created. In the search box type photos. Pick photos library api. This allows your account to use the photos API. We still need to authorize our app to access that API though.

One of the main purposes of your NAS can be to support data backup. Even if you are backing up from a computer into your NAS, I still recommend having an offsite or cloud backup solution.

Mac photo library on synology nas

Both my wife and I use google photos which is nice because picture and movies taken on your phone are automatically backed up in google photos and are available online.

However, we recently lost a bunch of data from google photos. An accident deleted a years worth of photos and unfortunately, there’s now no way to get them back. I decided that it would be worth it to have a NAS backup of that data, which is inline with my vision of having one set of data on the device (phone, laptop or desktop), one version on the NAS and one version in the Cloud (google or in our case, backblaze which I’ll cover in another article).

The Code Repository

I found a docker based task which will log into your google photo account, pull down anything it finds there and copy it to your NAS. The code repository is here and it has the documentation.

In this case, we’re using a Synology DS-1517+ 5-bay unit (See on Amazon), that also features 10-Gigabit connectivity for high-speed access to our photo library locally. However, you can use just.

Setting Up Your NAS

Photo Library On Synology Nas

You’ll need to make some new directories

Nas

Setup Google to Allow Access

I’m actually following the directions here. I’m going to copy them here to make it easier to read and follow along. There have also been some updates which I’ll cover in my docs.

Go to google cloud platform. You automatically have an account as a google service user. Just log in with the same account you use on your phone.

Click Create Project button

Call it gphoto-sync and hit create

In order to enable access we need to go to the photo api. Click on the project you just created

In the search box type photos

Pick photos library api

Select Enable

This allows your account to use the photos API. We still need to authorize our app to access that API though.

Go the the consoles api page. (make sure that gphoto project is active in the dropdown).

Click OAuth consent screen. Select External and hit Create

Type a name for the app and select an email from the dropdown

Photo Library On Synology Nasdaq

You’ll need to add another email for the developer contact info. Then hit Save and continue.

Don’t set any scopes and hit Save and Continue.

Don’t set any test users and hit save and continue

On the summary page hit back to dashboard. Now select Credentials, select create credentials and select OAuth Id from the dropdown

Photo Library On Synology Nasal

Select Desktop Application as the application type. Use gphoto-sync as the app name. Hit Create

When you get back to the main screen hit download secret file.

Go back to Oauth consent screen and hit publish app

You should see that it has been published.

Start Docker and Authorize Your App

Copy your secrets file up into your /volume1/docker/gphotosync directory. Rename it to client_secret.json

Its not going to sync the first time. You need to actually authorize your client to access that API.

First, start up docker. You need to do this via SSH. We’re using interactive mode (-it) so that we can interact with the application as its running.

you should see a message similar to this:

copy the url from the screen and paste it into a browser. You’ll see a google OAuth window. Select your account (that you want to get the photos from)

You’ll see a warning window. Click Advanced and Go to gphoto-sync

You’ll see two permissions windows. Click Allow on both

Click Allow on the next confirmation window

Grab the token from the sign in page. Copy it into your clipboard

and paste it into your SSH prompt and hit enter. You should see it start to process your images

Automating the Backup

This script only executes once. It will download all of your photos (unless there’s a failure and the container stops), but it won’t pick up any new ones since the last time it ran. Now we need a way to tell the container to run daily (or weekly, etc…). You can write a cron to schedule the container to run, but I actually like the Synology Task Scheduler for this.

Photo Library On Synology Nascar

Go to the DSM and open up the Control Panel (make sure Advanced Mode is enabled) and open Task Scheduler.

Create a new Scheduled Task for a User-defined Script

Give the task a name (I use Google Photo Sync) and run as root

Schedule to run daily at some time (I use the default of midnight)

On Task Settings you can set a notification email (but this can get noisy). Make sure to set User-defined script to run your docker container with the name of the container you just created

Conclusion

Apple Photos Library On Synology Nas

You’ll need to repeat this process for each account you want to backup. This means generating a client secrets for each user, creating a separate docker container (with a unique name) and separate scheduled task.

Please let me know how this worked for you in the comments. I would like to hear if it worked exactly as I described or if there are modifications that you needed to make in order to get it going so that I can update the documentation if needed.

Also, please checkout my other projects and courses related to using your synology and other backup solutions.

Finally, if you’re having issues with google permissions (or rate limiting?) I have an alternate method that you can use with the DSFile application and Google takeout.