I want to do two things with my digital photos. First, keep them safe, especially all those precious memories of random parking meters and unfathomable HVAC mechanisms. Second, enjoy looking at the small subset that are precious family moments. I'm not a special snowflake, these basic requirements should represent a large and competitive market. Unfortunately I'm not holding my breath for much in the way of consumer friendly regulation for the next four years in the US.
Google is making some changes to their Photos API next month, which amount to "Get the fuck out of our Photos API". They're a polite organization so they phrase it a little differently: "We're excited to see the creative solutions developers will build using the new Picker API and the updated Library API.". The developer documentation is a little more pointed: "If your app relies on accessing the user's entire library, you may need to re-evaluate your app or consider alternative approaches."
I have an Aura Carver Mat, a nice digital photo frame that I synced to a shared Google Photos album. Easy for me to add photos, way too easy for the kids to add photos - a fantastic device. As of next month it's ewaste though. I'm not going to upload photos slowly through some picker API like an animal. I'm going to end up building something complicated out of a Raspberry Pi (adds to actuarially unrealistic to do list).
This change doesn't impact backup, because that was already broken. For a while Google Photos nicely integrated with Google Drive and I ended up with a local copy of everything that I could then backup through other means. I'm never going to trust any one company to look after important files and so my philosophy is to backup twice online and once to an external hard drive that lives in a fire safe. (At one point I even built a backup company based on this model).
Google killed the Drive integration and so I MacGyvered together an apps script based solution that used the Google Photos API. This revealed to me that the Photos API would not return location information. Even worse it was impossible to get the full resolution version of a video to download. So it's not like I was in love with the API before this most recent change.
My current approach is a mix of sad and awesome. The sad part is that I use Google Takeout once a month to get an archive of all my online photos. Thankfully this still works. The awesome - I wrote this photo sorter tool that takes the messy download and organizes it by year and month. And I also wrote a volume shadow copy tool that lets you backup a drive without getting hung up on locked files. Those pieces get my photos safely to an external drive, and I upload to Amazon Photos too (the third leg of my backup stool).
Warning - I no longer recommend using this script to backup Google Photos. The Google Photos API has too many bugs that Google doensn't seem interested in fixing. My personal approach at this point is to use Google Takeout to get a periodic archive of my most recent year of photos and videos. I have a tool that does some deduplication and puts everything in year/month folders. See Photo Sorter for more details.
Google has decided that backing up your photos via Google Drive is 'confusing' and so Drive based backup is going away this month. I love Google Photos but I don't trust it - I pull everything into Drive and then I stick a monthly backup from there onto an external drive in a fire safe. There is a way to get Drive backup working again using Google Apps Script and the Google Photos API. There are a few steps to follow but it's pretty straightforward - you should only need to change two lines in the script to get this working for your account.
First two four caveats to be aware of. Apps Script has a time limit and so it's possible that it could fail if moving a large number of photos. You should get an email if the script ever fails so watch out for that. Secondly and more seriously you could end up with two copies of your photos. If you use Backup and Sync to add photos from Google Drive then these photos will be downloaded from Google Photos by the script and added to Drive again. You need to either upload directly to Google Photos (i.e. from the mobile app or web site) or handle the duplicates in some way. If you run Windows then I have released a command line tool that sorts photos into year+month taken folders and handles de-duplication.
One more limitation. After a comment by 'Logan' below I realized that Apps Script has a 50MB limitation for adding files to Google Drive. The latest version of the script will detect this and send you an email listing any files that could not be copied automatically.
And a fourth limitation after investigating a comment by 'Tim' it turns out there is a bug in the Google Photos API that means it will not download original quality video files. You get some lower resolution version instead. Together with the file size limit this is a bit of a deal breaker for most videos. Photos will be fine, but videos will need a different fix.
On to the script. In Google Drive create a new spreadsheet. This is just a host for the script and makes it easy to authorize it to access Google Photos. Select 'Script editor' from the Tools menu to create a new Apps Script project.
In the script editor select 'Libraries...' from the Resources menu. Enter 1B7FSrk5Zi6L1rSxxTDgDEUsPzlukDsi4KGuTMorsTQHhGBzBkMun4iDF next to 'Add a library' and click add. This will find the Google OAuth2 library Pick the most recent version and click Save.
Select 'Project properties' from the File menu and copy the Script ID (a long sequence of letters and numbers). You'll need this when configuring the Google Photos API.
In a new window open the Google API Console, part of the Google Cloud Platform. Create a new project, click Enable APIs and Services and find and enable the Google Photos API. Then go to the Keys section and create an OAuth Client ID. You'll need to add a consent screen, the only field you need to fill out is the product name. Choose Web Application as the application type. When prompted for the authorized redirect URL enter https://script.google.com/macros/d/{SCRIPTID}/usercallback and replace {SCRIPTID} with the Script ID you copied above. Copy the Client ID and Client Secret which will be used in the next step.
Go back to the Apps Script project and paste the code below into the Code.gs window:
Enter the Client ID and Client Secret inside the empty quotes at the top of the file. You also need to add an email address to receive alerts for large files. There is a BackupFolder option at the top as well - the default is 'Google Photos' which will mimic the old behavior. You can change this if you like but make sure that the desired folder exists before running the script. Save the script.
Go back to the spreadsheet you created and reload. After a few seconds you will have a Google Photos Backup menu (to the right of the Help menu). Choose 'Authorize' from this menu. You will be prompted to give the script various permissions which you should grant. After this a sidebar should appear on the spreadsheet (if not choose 'Authorize' from the Google Photos Backup menu again). Click the authorize link from the sidebar to grant access to Google Photos. Once this is done you should be in business - choose Backup Now from the Google Photos Backup menu and any new items from yesterday should be copied to the Google Photos folder in Drive (or the folder you configured above if you changed this).
Finally you should set up a trigger to automate running the script every day. Choose 'Script editor' from the Tools menu to re-open the script, and then in the script window choose 'Current project's triggers' from the Edit menu. This will open yet another window. Click 'Add Trigger' which is cunningly hidden at the bottom right of the window. Under 'Choose which function to run' select 'runBackup'. Then under 'Select event source' select 'Time-driven'. Under 'Select type of time based trigger' select 'Day timer'. Under 'Select time of day' select the time window that works best for you. Click Save. The backup should now run every day.
The way the script is written you'll get a backup of anything added the previous day each time it runs. If there are any duplicate filenames in the backup folder the script will save a new copy of the file with (1) appended in front of the filename. Let me know in the comments if you use this script or have any suggestions to improve it.