This is a text-only version of the following page on https://raymii.org:
---
Title       : 	Local incremental backups of Google Photos on Ubuntu with gphotos-sync
Author      : 	Remy van Elst
Date        : 	24-08-2020
URL         : 	https://raymii.org/s/tutorials/Local_incremental_Google_Photos_backup_on_Ubuntu.html
Format      : 	Markdown/HTML
---



'Google Photos' no longer syncs with `Google Drive` or with their `Backup and Sync`
desktop software. There used to be a checkbox to get your `Google Photos` pictures
in `Google Drive` but [that has been disabled][1]. I used that feature together
with their `Backup and Sync` tool to sync all the photos in `Google Photos` to
my local Windows computer. From there I used `DigiKam` to manage the photos
and backup them offline and offsite. Due to Google removing that feature, I had
to go find another way to get the pictures out of `Google Photos`, which, after
a few months of (automated) use, `gphotos-sync` on Ubuntu seems to be the best,
stable choice. In this guide I'll show you how to setup incremental backups 
from `Google Photos` on Ubuntu. My `DigiKam` database moved over without problems,
and now I'm glad I don't have to use Windows for picture managemant anymore.

<p class="ad"> <b>Recently I removed all Google Ads from this site due to their invasive tracking, as well as Google Analytics. Please, if you found this content useful, consider a small donation using any of the options below:</b><br><br> <a href="https://leafnode.nl">I'm developing an open source monitoring app called  Leaf Node Monitoring, for windows, linux & android. Go check it out!</a><br><br> <a href="https://github.com/sponsors/RaymiiOrg/">Consider sponsoring me on Github. It means the world to me if you show your appreciation and you'll help pay the server costs.</a><br><br> <a href="https://www.digitalocean.com/?refcode=7435ae6b8212">You can also sponsor me by getting a Digital Ocean VPS. With this referral link you'll get $100 credit for 60 days. </a><br><br> </p>


[gphotos-sync][2] describes itself as:

> Google Photos Sync downloads your Google Photos to the local file system. 
It will backup all the photos the user uploaded to Google Photos, but also 
the album information and additional Google Photos 'Creations' (animations, 
panoramas, movies, effects and collages). It is only for Google Photos download 
/ backup purposes. It cannot upload photos to Google Photos.

### gphotos-sync installation

[gphotos-sync][2] is a command line python application that uses the Google Photos
API. Installation is not very complex since there is a `pip` package. First make 
sure you have `pip` installed:

    apt install python3-pip

Install `gphotos-sync` wih `pip`:

    python3 -m pip install gphotos-sync

Now follows a complex part on getting credentials. It's not as simple as just 
logging in with a username and password.

### Google API authentication setup

The [gphotos-sync manual][2] has an up to date version of these instructions.
At the time of writing this article they were working, but with Google you
can never be sure what happens and when [stuff is deprecated][3].

Start by going to [console.cloud.google.com][4].

Create a new project. Name and location don't matter.

Go to [console.cloud.google.com/projectselector2/apis/library][5], select your
new project, then select the `Photos Library API`. Click the big blue Enable 
button.

Go to [console.cloud.google.com/apis][6], select your project and go to 
`OAuth Consent Screen`. Select `External`. 

Fill in a name and click `Save`.

In the menu bar, go to `Credentials`, `Create Credentials`, `OAuth ClientID`.

Select type `Desktop Application` and give the client a name. I used `gp_client`.

You'll see a confirmation screen. Afterwards, use the download arrow button to 
save the file as `client_secret.json`:

![download secrets][7]

I saved it in my `~/Downloads` folder and then moved it to the correct folder for
gphotos-sync, creating it if it does not exist:

    mkdir -p ~/.config/gphotos-sync/
    cp ~/Downloads/client_secret.json ~/.config/gphotos-sync/client_secret.json

Once you login to Google you might get an 'Unverified' warning, which, in this
case, is fine.

After this, rather complex process, you can start using the software.

### gphotos-sync usage

Create a folder where your pictures are going to be synced to:

    mkdir -p ~/gphotos-sync/

Also authorize the client, it will ask you the first time you sync:

    gphotos-sync ~/gphotos-sync/ --progress
    08-23 14:10:31 WARNING  gphotos-sync 2.14.2 2020-08-23 14:10:31.372785 
    Please go here and authorize, https://accounts.google.com/o/oauth2/v2/[...]
    Paste the response token here:

It will tell you the application is not verified by google, which we know because
we just created it. In this case that is fine. I received a few emails after
logging in from Google as well, which is nice. 

You only need to do that the first time you sync.  

Now, you can just sync with the following command:

    gphotos-sync ~/gphotos-sync/ --progress

Output:

    08-23 14:12:24 WARNING  Indexing Google Photos Files ... 
    08-23 14:13:56 WARNING  Listed 80 items ...
    08-23 14:17:38 WARNING  indexed 100 items ..
    08-23 14:17:38 WARNING  Downloading Photos ... 
    08-23 14:19:07 WARNING  Downloaded 90 items ...

I like to have interactive progress, but you can omit the parameter if you are 
using cron or a script. Logging will be done to a file instead of `STDOUT`.

Your pictures will be in `~/gphotos-sync/photos`.

The next time you sync, only new photos will be downloaded. The tool is not able
to detect changed photos, due to API limitations, so changes will not be detected.
It will also not delete local pictures, 

[1]:http://web.archive.org/web/20200823113853/https://blog.google/products/photos/simplifying-google-photos-and-google-drive/
[2]:https://github.com/gilesknap/gphotos-sync/
[3]:https://killedbygoogle.com/
[4]:https://console.cloud.google.com
[5]:https://console.cloud.google.com/projectselector2/apis/library
[6]:https://console.cloud.google.com/apis/
[7]:/s/inc/img/gp_secret.png

---

License:
All the text on this website is free as in freedom unless stated otherwise. 
This means you can use it in any way you want, you can copy it, change it 
the way you like and republish it, as long as you release the (modified) 
content under the same license to give others the same freedoms you've got 
and place my name and a link to this site with the article as source.

This site uses Google Analytics for statistics and Google Adwords for 
advertisements. You are tracked and Google knows everything about you. 
Use an adblocker like ublock-origin if you don't want it.

All the code on this website is licensed under the GNU GPL v3 license 
unless already licensed under a license which does not allows this form 
of licensing or if another license is stated on that page / in that software:

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

Just to be clear, the information on this website is for meant for educational 
purposes and you use it at your own risk. I do not take responsibility if you 
screw something up. Use common sense, do not 'rm -rf /' as root for example. 
If you have any questions then do not hesitate to contact me.

See https://raymii.org/s/static/About.html for details.