How can I backup all my Google Photos / Google Drive automatically on linux?

9,774

Solution 1

Finally it seems google has fixed the Photos access from drive, so your google drive can now view all your google photos - for some users this was incredibly buggy before, sometimes not showing any photos, sometimes not showing some.

To make use of this:

  • Go to https://drive.google.com/ and hit the 'cog' to open the settings. Eenable "Create a Google Photos folder", which creates a folder that'll appear in your root 'drive' folder. It looks like this:

Google Photos folder within Root Folder

  • This now starts syncing your photos into a folder in your google drive, called 'Google Photos' - this is not the same as the 'Google Photos' which is listed below 'My Drive', 'My Computers' and so on.

Old Google Photos link

  • Once you've allowed this some time to sync, use rclone from https://github.com/ncw/rclone to pull down a copy of your Google Photos folder from your drive:

rclone copy --config /home/<user>/.rclone.cf GDrive:Google\ Photos/ ./googlePhotos/ ./googlePhotos/

/home/<user>/.rclone.conf should be created using rclone config at the command line and following the instructions.

Once completed, the rclone copy --config /home/<user>/.rclone.cf GDrive:Google\ Photos/ ./googlePhotos/ can be placed into a cronjob, or as part of a larger backup script. You can also set it to sync your whole google drive by using GDrive: as the source instead, or use sync instead of copy to pull down all changes including deletions.

Solution 2

For automatically backing up a Google Drive directory on linux (unix in general), rclone (https://github.com/ncw/rclone) is your solution. Here is an article explaining how to do this at home using a Raspberry Pi.

For Google Photos, the Google Photos REST API is the only valid solution I can think of, but would require you to program your own app consuming it.

Side note: because Google has now stopped synchronising Google Photos in Google Drive, using rclone is no longer possible for Photos.

Side note 2: I am now working on building a simple web application (that you can run at home) using the Google Photos API to easily back up your Google Photos account and media to various destinations (including Google Drive). I can give an update as progress is made. Also: contributions are welcome.

Share:
9,774
djsmiley2kStaysInside
Author by

djsmiley2kStaysInside

I'm Tim, a Gamer, hacker, father. Consumer of Worlds, nom nom nom. Tell me why. Live life like you might die tomorrow, dream like you'll live forever. Sometimes found broadcasting my PS4 gaming on Twitch TV as "The Worlds Worst Gamer The views I express here are mine alone and do not necessarily reflect the views of my employer.

Updated on September 18, 2022

Comments

  • djsmiley2kStaysInside
    djsmiley2kStaysInside almost 2 years

    I have around 40Gb of photos in google photos, along with a lot of other stuff in google drive, which I'd like to back up automatically.

    Right now I'm having to go into my profile and create a takeout, which has two issues.

    • It's a manual process and I can't see how to automate it easily
    • It provides the files in 10, 20 or 50Gb chunks, which I then have to extract and combine into the 'full backup'

    I'd like to simply have something I can call via cron which takes a copy of all my google photos, and puts them into a folder somewhere.

  • Anthony Foschini
    Anthony Foschini almost 6 years
    Does this still works? Because currently it appears that photos that I've uploaded in the Google Photos folder are visible in Google Drive, but not in Google Photos :/
  • djsmiley2kStaysInside
    djsmiley2kStaysInside almost 6 years
    @J4N I don't know what happens if you do it the way you have - My photos upload automatically in Google Photos, and appear in drive - for a long time (over a year) this wasn't working at all, then suddenly one day it started working and I came up with the above solution.
  • Anthony Foschini
    Anthony Foschini almost 6 years
    This way it works, I see the pictures that are in GPhotos also in the drive, but if I add to the drive(which I taught that was what you were doing), doesn't work for me :/
  • djsmiley2kStaysInside
    djsmiley2kStaysInside almost 6 years
    No sorry, I only download from the 'normal' drive, not the special folder that appears on the left. I've added an image showing where the Google Photos folder should appear.
  • Anthony Foschini
    Anthony Foschini almost 6 years
    In my case, I was hopping to do the inverse of what requested the OP: Backup my pictures ON google photos, but doesnt work for now.
  • djsmiley2kStaysInside
    djsmiley2kStaysInside almost 6 years
    I don't know for sure, but if you use my instructions (re: the bits about enabling options in google photos and google drive) you might be able to sync a file into the correct folder on gDrive, and have it appear? I shall try it now.
  • djsmiley2kStaysInside
    djsmiley2kStaysInside almost 6 years
    Also, note there's an option to show your Google Drive images in Google photos too, I believe this appears in the google photos options.
  • Anthony Foschini
    Anthony Foschini almost 6 years
    Really??? I've searched extensively for this but didn't found it! That would be a life saver for me, where did you found it?
  • djsmiley2kStaysInside
    djsmiley2kStaysInside almost 6 years
    Google Photos settings -> i.imgur.com/sfAeK54.png
  • djsmiley2kStaysInside
    djsmiley2kStaysInside almost 5 years
    Hi! - I did try doing the rest stuff myself, but with no experience in doing so, little experience of python, and googles seemingly changing views of their own API's I ended up giving up. I do hope you can get something working (and my account might be a great test for it, with 40k+ photos...)
  • Bastien
    Bastien almost 5 years
    Hey @bertieb , thanks for the feedback and the welcome. I did think of just writing a comment rather than an answer, but I thought it was important to point that the current top answer is no longer valid, and that the REST API is the only official solution as of now (and indeed sneak an invitation to contribute on a project using it). I have now edited my answer to rather be: "The REST API is a valid solution today. As a side note, the Google Drive feature no longer exists." Hopefully this is more proper.
  • Bastien
    Bastien almost 5 years
    Cheers @djsmiley2k , I'll keep you posted.
  • bertieb
    bertieb almost 5 years
    @Bastien My pleasure, hope you'll stick around :) Looking good now, and as someone futzing with Google's APIs at the moment- good luck! :D