Recent Posts


Headless linux google photos sync (nasty and dirty)


Google Photos is a marvelous service! You can store all of your photos for free (if you'd agree to compress them) and have them on the go on every device. It has it's downsides: sharing all photos to your wife is not an option and managing them (folders, mass actions, etc.) is not there. But hey, it comes at the low, low, low price of FREE.

Google did release a simple and effective tool for Mac and Windows that syncs all the photos you have available on your computer to their service. They did not release this for Linux. So people who have thousands of photos on their drives are left only with the possibility of dragging them to the browser window. And if you want to do this for 35000 images - this is going to be a wild ride.

Of course you can have a virtual machine with Windows and put the Google Sync Tool there, but let's ignore this option :) It needs at least 2G of ram and a Windows licence.

You can run the sync tool on Wine, as discussed here:, but you still run this manually and need X. If you wanted to run this on a server that you use to store all of your photos you were out of luck.



Let's get the authentication key first

So just do what the howto mentioned above tells you to. You can use a friends Windows PC or download Windows ISO from Microsoft pages and run this as a trial under KVM or other virtualization solution of your choice. 

Install the Google Photos Sync Tool, fully authorize and export the regedit key that should contain the data below:
Location: HKEY_CURRENT_USER\Software\Google\Picasa\Picasa2\Preferences
[HKEY_CURRENT_USER\Software\Google\Picasa\Picasa2\Preferences]"GoogleOAuth"=hex:xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,\ xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx"GoogleOAuthEmail"="""GoogleOAuthServices"="mail,lh2,cp,cp.manager,mailrelay,,,,,,,plus.settings,youtube,""GoogleOAuthVersion"=dword:00000005
Get this file (lets call it gphotos.reg) to the server and you can delete the Windows virtual machine.

Let's install wine and prepare

We won't be needing X on the remote server, so login there with SSH and X forwarding:
ssh user@server -X
if you run now (remotely)
you should see the xclock window showing up on your workstation. If it does not you'd need to google to enable this, but this should work out of the box on most recent Linux distros.

Steps to be carried out:
  • install wine (as root)
sudo apt install wine
  • create a separate user for the sync tool (let's call it gphotos)
  • upload the sync tool exe and registry file from windows to the gphotos home directory
  • as the gphotos user start winecfg (using a remote SSH connection with X forwarding)
  • switch the Windows version to Windows 7

Let's install Google Photos Sync Tool

Steps to be carried out:
  • simply run (using a remote SSH connection with X forwarding)
wine gpautobackup_setup.exe
  • proceed with default installation options until you will see that the installer is trying to open something up and it will just keep a blank white window open. (it tries to start up IE to let you log in to Google Photos),
  • kill the wine processes, shut the window
  • run regedit to install the gphotos.reg file and import
  • run the Google Photos Sync Tool again (but installed on your drive)
cd "/home/gphotos/.wine/dosdevices/c:/users/gphotos/Local Settings/Application Data/Programs/Google/Google Photos Backup"
wine "Google Photos Backup.exe"
  • it will now run from the moment after the authorization tool place and you will be able to select the folders you'd want to sync (be sure to check read permissions before this step).
  • finish, the sync tool started syncing your photos
Now the sync tool runs, but is still connected with your X session over SSH. Kill it and move on.

Start up at boot time

We'll be using xvfb-run, so be sure to make sure you have it on your system. This is used to start up a X session, without any X on the server.

  • Let's create a startup file for the service, located in /home/gphotos/gphotossync with the following contents:
cd "/home/gphotos/.wine/dosdevices/c:/users/gphotos/Local Settings/Application Data/Programs/Google/Google Photos Backup"xvfb-run -a -e /home/gphotos/log.log -s "-screen 0 1280x800x16" wine "Google Photos Backup.exe" & &>/tmp/gphotos.log

  • a few remarks here:
    • this assumes you did not customize any paths and run this as gphoto user,
    • -a makes xvfb-run select a display ID if the default one is busy,
    • /home/gphotos/log.log is a log for xfvb-run issues,
    • /tmp/gphotos.log for any issues wine might pop up with,
  • this script just runs the Google Photo Sync tool in the background and allows it to do it's job.
  • Let's just add this to the /etc/rc.local file, by adding the following line BEFORE the line with exit 0:
sudo -u gphotos -i /home/gphotos/gphotossync
  • and that's it. After reboot you should see your Google Photos Sync tool running and syncing photos.

Logs and monitoring

You might want to know what Google Photos Sync is actually doing, so:
  • you can see this in the process list or htop or other tools of choice if it is running or not,
  • you can access the logs to see what JPG files were processed when:
grep -i jpg "/home/gphotos/.wine/dosdevices/c:/users/gphotos/Local Settings/Application Data/Google/Google Photos Backup/network.log"
And that's it. I've managed to sync nearly 40 thousand family pictures, using Google's free Photos, from my Linux's server drive. If I add anything to the pictures folder, the Sync tool picks up straight away and uploads.

So good luck!