[HOW TO] Synchronize Google Photo using "gphotos-sync" on QNAP TS-231P3 (and maybe others)

Post Reply
lukenpi
New here
Posts: 2
Joined: Thu Feb 25, 2021 12:47 am

[HOW TO] Synchronize Google Photo using "gphotos-sync" on QNAP TS-231P3 (and maybe others)

Post by lukenpi »

Hello!

Just spend few hours trying to figure out how to configure gphotos-sync on my brand new QNAP. I'd like to share you how did I succeeded, hoping this will save you some headhaces.

I won't explain how to configure gphotos-sync itself, there's a ton of topics out there which explain how to do that.

What you need:
  1. A configured app in your Google Developer Console
  2. The client_secret.json of the app
  3. SSH Enabled in QNAP Config
  4. Confidence with console. You could do serious damages if you don't know what you're doing, like delete your data or scrambling the QNAP config
So, let's start:
  1. Install Entware from App Center (this will enable OPKG)
  2. Login via SSH with admin, press Q then Y to go to the real console
  3. Run the following commands (to install dependencies, gphotos-sync and prepare the config folder)

    Code: Select all

    opkg install gcc pyhton3 python3-dev python3-pip
    pip3 install gphotos-sync
    mkdir -p /share/homes/admin/.config/gphotos-sync
  4. Paste your JSON file copied from Google Developer Console into

    Code: Select all

    /share/homes/admin/.config/gphotos-sync/client_secret.json
  5. Test it up by running

    Code: Select all

    HOME=/share/homes/admin gphotos-sync /share/YOUR_BACKUP_PATH
If you want (like me) schedule it via cron
  1. Edit /etc/config/crontab and add the following line (replace the real path)

    Code: Select all

    0 * * * * /opt/bin/gphotos-sync /share/YOUR_BACKUP_PATH >/share/YOUR_BACKUP_PATH/cron.log 2>/share/YOUR_BACKUP_PATH/cron.err.log
  2. Restart the crontab daemon with

    Code: Select all

    crontab /etc/config/crontab && /etc/init.d/crond.sh restart
And that's it! Easy-peasy... Sort of.
Last edited by lukenpi on Thu Feb 25, 2021 2:01 am, edited 1 time in total.
Mousetick
Experience counts
Posts: 1081
Joined: Thu Aug 24, 2017 10:28 pm

Re: [HOW TO] Synchronize Google Photo using "gphotos-sync" on QNAP TS-231P3 (and maybe others)

Post by Mousetick »

/root is volatile. Anything you put in there won't be there any more after restarting the NAS.

You can work around that by storing stuff in /share/homes/admin, ignoring /root entirely:

Code: Select all

# opkg install gcc pyhton3 python3-dev python3-pip
# pip3 install gphotos-sync
# mkdir -p /share/homes/admin/.config/gphotos-sync
Then put client-secret.json in /share/homes/admin/.config/gphotos-sync.

Then to run via cron: no changes to your instructions but skip symlink creation (#1).

Or to run via SSH logged in as admin user:

Code: Select all

# HOME=/share/homes/admin gphotos-sync /share/YOUR_BACKUP_PATH
lukenpi
New here
Posts: 2
Joined: Thu Feb 25, 2021 12:47 am

Re: [HOW TO] Synchronize Google Photo using "gphotos-sync" on QNAP TS-231P3 (and maybe others)

Post by lukenpi »

Mousetick wrote: Thu Feb 25, 2021 1:55 am /root is volatile. Anything you put in there won't be there any more after restarting the NAS.

You can work around that by storing stuff in /share/homes/admin, ignoring /root entirely:

Code: Select all

# opkg install gcc pyhton3 python3-dev python3-pip
# pip3 install gphotos-sync
# mkdir -p /share/homes/admin/.config/gphotos-sync
Then put client-secret.json in /share/homes/admin/.config/gphotos-sync.

Then to run via cron: no changes to your instructions but skip symlink creation (#1).

Or to run via SSH logged in as admin user:

Code: Select all

# HOME=/share/homes/admin gphotos-sync /share/YOUR_BACKUP_PATH
Just rebooted and found it out. Thanks for the tips, I'll update the original post ;)
datavortex
New here
Posts: 7
Joined: Thu Jun 30, 2022 9:40 am

Re: [HOW TO] Synchronize Google Photo using "gphotos-sync" on QNAP TS-231P3 (and maybe others)

Post by datavortex »

Thanks for these instructions! Very handy.

I did have to make a couple of small adjustments to get things working for me. I did this on QuTS Hero.

The main change I had to make was to make sure I was using the version of Python's `psutil` from Entware. The version installed by pip3 was not compatible with QNAP and the library wouldn't import or load. Assuming you already got the pip3 version of the library you can just do this to remove the PIP one and install the Entware one:

Code: Select all

sudo /opt/bin/pip uninstall psutil
sudo /opt/bin/opkg install python3-psutil
I had to do this twice, using --force-reinstall the second time, for some reason. No idea why.

The other change I had to make was to specify a port to use, since the default port (I assume 80) was already in use. So the command becomes:

Code: Select all

HOME=/share/homes/admin gphotos-sync --port 1234 /share/YOUR_BACKUP_PATH
Also note there's a typo in the top post, just fix "pyhton3" to instead be "python3".
Koramchad
Starting out
Posts: 23
Joined: Tue Dec 10, 2013 4:32 am
Location: Mountain View, CA

Re: [HOW TO] Synchronize Google Photo using "gphotos-sync" on QNAP TS-231P3 (and maybe others)

Post by Koramchad »

How do you get past the User Login OAuth Flow? It requires a browser and I have no way to connecting the response to my Qnap, since it needs to be done via localhost.

The official guide says:

Code: Select all

If you are running on a NAS or other headless server you will first need to run locally so that you can do initial login flow with a browser. Then copy <TARGET>/.gphotos.token to the server. For this first run you could use the following options so that no backup is performed:

--skip-files --skip-albums --skip-index
But I don't know what that means...
toldyou
First post
Posts: 1
Joined: Wed Mar 09, 2022 2:57 am

Re: [HOW TO] Synchronize Google Photo using "gphotos-sync" on QNAP TS-231P3 (and maybe others)

Post by toldyou »

I have same trouble with OAuth flow as user post above. Can some help?

Thank you
Post Reply

Return to “Google Cloud Storage”