Skip to content

Backup your latest modified Google Drive files using the Google Cloud API

Notifications You must be signed in to change notification settings

rcaldas-com/google-drive-dump

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Drive Dump

Download your latest modified Google Drive files using the Google Cloud API.

As I couldn't find a Google sync app for Linux, I made this Python3 script that uses the Google API to get your last modified Drive files since the last execution with automated backup purposes, recreating the directory tree locally.


What it needs:

  • Google API Credentials json file named credentials.json (get yours from gcloud)
  • MongoDB URI connection to control execution and store token, in format mongodb://user:pwd@server/database
  • Disk space to store the files mounted in files directory
  • Variables in a .env file like that:
    MONGO_URI=mongodb://user:pwd@server:port/database
    [email protected]
    MAIL_SERVER=mail.server.com
    [email protected]
    MAIL_PASSWORD=password
    

What it does:

  • Search for new modified files since last run;
  • Recreate the directory tree of files in "/files" volume;
  • Convert Google Documents to MS Office related format;
  • Recover the list of remaining files if some file don't get downloaded in last sync (so we can debug fails not treated before).

First run:

In first run google Token must be created and stored in database

  • This need to be done interactivelly by running docker-compose run --rm python
    • It will permit you insert the authorization code generated in the link that will appers on screen.

You credential's account must have "Drive API" enabled, a message will tell you if API is disabled providing a link to enable.

Another runs can be with just docker-compose up. Stop with docker-compose down


To do:

  • Alert fails sending email.
  • Make GridFS more efficient, it is creating a new file with each run
  • Put more info in database to check through a web monitor.
  • Tell me you... Any improvements are welcome.

About

Backup your latest modified Google Drive files using the Google Cloud API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published