Google Photos Backup Assistant

My wife and I have been travelling around the world for the past two years. This means we take a lot of photos. Since we're Android users, we use Google Photos as our primary photo editing and storage solution. The sync feature keeps our phone's storage free to take lots of pictures, knowing Google has a copy of them as a moment's notice. There is a problem with this however, putting all our photos in once place means we could loose them at any time for many reasons. For this reason, I wanted to get a second backup solution put in place.

Google Takeout will allow you to get your photos in a compressed file (zip). We have around 100 GBs of photos so this can amount to one of several zip files. If you're storage constrained, like me, you have to download a few zip files at a time, expand those files, merge them, and delete the original download to make room for more downloads. I wanted a way to automate this process so I could just download files at my own pace and let some code handle putting it all together to backup to a service like Backblaze. Since I'm trying to learn Rust I decided this would be a good starter project.

The steps

  • Create the directories to place the compressed files into
  • Decompress the files
  • Merge the files
  • Optionally delete file compressed and expanded files
  • Do it all sequentially so we keep used disk space to a minimum

What you get from Google Takeout

The layout of the compressed file looks like the following

The code is a basic CLI executable called gpba, short for Google Photos Backup Assistant. This is the first tool I have ever written in Rust so it isn't as idiomatic as it could be but it is a good start.

The real power of the tool is being able to automatically de-dupe the data into a single directory. We can then delete the downloaded data. This helps conserve disk space locally and make the backup as efficient as possible.

After a full run (with the --keep flag enabled) the file structure looks like the image below.

If you want to take a look at the code you can find it here.