Menu

HOW-TO

Krzysztof Osmulski

Tool allow you to backup your photos and videos from google photos to your local machine or NAS.

This tool is self packaged jar file that works with no GUI from commandline, so you can run it directly via:

./gphotosbackup-x.y.z.jar -h

or with:

java -jar ./gphotosbackup-x.y.z.jar -h

the above will printout basic help:

usage: gphotosbackup-x.y.z.jar [OPTIONS]... [SYNC DIRECTORY]
version: 0.0.1
 -c,--credentials <credentials file>   specify credentials file - the one
                                       with token and refresh token; if
                                       missing will be created and will
                                       hold credentials; default
                                       './credentials.json'
 -h,--help                             print help and exit
 -l,--limit <limit files to sync>      specify limit of files to download;
                                       default no limit so all files will
                                       be downloaded; this help apply to
                                       google api limits
 -s,--client-secret <secrets file>     specify secret file - app
                                       description from google; default
                                       './client_secret.json'

client-secret

This is a file containing app secrets that You create to access your google photos from google services via API
It is described for instance here: https://developers.google.com/photos/library/guides/get-started
There is no application secrets that are provided with this tool.
There is a good description how to do it in context of other python tool that do it:
https://www.linuxuprising.com/2019/06/how-to-backup-google-photos-to-your.html

When you have the client_secret.json file you have to specify it with -s option

credentials

This file is generated when you agree with your google account to access google photos with google API.
when invoking command line you should specify -c option. Once You athorize app with google account this tool will download credentials and store in specified file.

how to call

normal call should looks like this:

java -jar ./gphotosbackup-x.y.z.jar -s path/to/client_secret.json -c path/to/credentials.json path/to/backupDirectory

Once this is called and credentials.json does not exist You will enter auth procedure:

2019-09-24 11:34:48.693  INFO 21384 --- [           main] c.c.g.GphotosbackupApplicationKt         : Started GphotosbackupApplicationKt in 1.808 seconds (JVM running for 2.257)
Follow that link, accept all
https://accounts.google.com/o/oauth2/auth?client_id=1045711100111-epgp47u7j2c403hd9v5qm37ppmqiq93m.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=https://www.googleapis.com/auth/photoslibrary.readonly&state=4gmcssq7vk162n9dnh3dlmu9u
Enter auth code here and press enter:

When you follow the link in your browser and proceed with allow of access of your google api in a result you will see google auth key that you should paste to terminal and hit enter. Once credentials are obtained there will be stored in specified credentials.json file and later calls will be done headles without manual entries to system input.


Related

Wiki: Home