sync_google_photos_to_local_linux_server

This is an old revision of the document!


Sync Google Photos to loacl Linux server

i finally gave in to the amazing functionality that google photos provides using AI for object detection as well as location data and much more to help you find a picture you're looking for. Also the way it integrates with android superb. If I switch to a new phone or use my tablet every now and then, my photos are just there and I don't need to worry anmore about syncing anything.. Even though i generally like to stay on top of my data and manage myself what is synced to where, it is nice to have somthing that is just there and works automatically for once :)

Howevever, I want my data secured on my own Server so I can take responsibility for backups.. Should i ever loose data, i want it to be my fault entirely so i have nobody else to blame than myself for losing my data.. i believe with local backups reaching fare back in time and a current dataset backed up to an offsite server i keep my data pretty save, so i want to be able to use this infrastructure also for the pictures i store on google photos.

I'm using a tool called gphotos-sync. It syncs all your pictures to a local folder, or to be more precise, to a local foder structure and it also syncs albums by symlinking the photos that are contained in the album. so in the end you have a nice sleek directory structure which is perfect for further backups and to eventually move to something else if I don't like google photos anymore in the future :)

first i needed to install python 3 PIP

apt install python3-pip 

followed by gphotos-sync (i've installed this as an unprivileged user)

pip3 instal gphotos-sync

add the ~/.local/bin folder to your user's PATH environment variable (i.e. in .bashrc)

now we need to create our own client id with google for our instance of gphotos-sync:

  • go to Google Developer Console and create a new project
  • within this project, click on the libraries menu on the left and search for “Photos Library API” and enable it
  • click on “Credentials” on the left side menu and then choose “Create Credentials” to create a new OAuth client ID
  • I then got an error telling me I need to set an applicaton name first, that's when i got a new menu item on the left “OAuth consent screen” where i could set the name.
  • now go again to create credentials and for the application type choose “Other”
  • you will then be presented with your client-id and secret.. just click okay.. now you can download the client-id as a json file from your credentials screen. save the file to ~/.config/gphotos-sync/client_secret.json (I had to create the directory first)
  • now run gphotos-sync and pass the folder where you want to keep your local copy of your photos as argument:
    gphotos-sync /data/google-photos/
  • it will now ask you to open a link and allow the app to access your google photos.. do that and paste back the code that you are given after the login.
  • sync_google_photos_to_local_linux_server.1565543447.txt.gz
  • Last modified: 11.08.2019 19:10
  • by Pascal Suter